Documentation
¶
Overview ¶
Package renderer provides the core rendering components
Index ¶
- type RenderQueue
- func (rq *RenderQueue) AddCircle(cx, cy int, radius float32, c color.Color, segments int) graphics.Shape
- func (rq *RenderQueue) AddDynamicRenderable(vertexData []byte, layout graphics.VertexBufferLayout, shaderHandle int, ...) graphics.ShaderRenderable
- func (rq *RenderQueue) AddLine(x1, y1, x2, y2 int, width float32, c color.Color) graphics.Shape
- func (rq *RenderQueue) AddPolygon(cx, cy int, width float32, c color.Color, sides int) graphics.Shape
- func (rq *RenderQueue) AddPolygonFromVertices(cx, cy int, width float32, vertices []graphics.Vertex) graphics.Shape
- func (rq *RenderQueue) AddRectangle(x, y, width, height int, c color.Color) graphics.Shape
- func (rq *RenderQueue) AddRoundedRectangle(x, y, width, height, radius int, c color.Color) graphics.Shape
- func (rq *RenderQueue) AddToRenderQueue(r graphics.Renderable)
- func (rq *RenderQueue) AddTriangle(x1, y1, x2, y2, x3, y3 int, c color.Color) graphics.Shape
- func (rq *RenderQueue) CompileShader(code string) graphics.ShaderHandle
- func (rq *RenderQueue) CreateMSDFAtlas() graphics.MSDFAtlas
- func (rq *RenderQueue) CreateTexture(img image.Image) graphics.Texture
- func (rq *RenderQueue) CreateTextureFromImage(img image.Image) (graphics.Texture, error)
- func (rq *RenderQueue) Dispose()
- func (rq *RenderQueue) DisposeTexture(h uintptr)
- func (rq *RenderQueue) DrawPrimitiveBuffer(vertices []graphics.PrimitiveVertex)
- func (rq *RenderQueue) DrawPrimitiveBufferWithClipRects(vertices []graphics.PrimitiveVertex, clipRects []*[4]int)
- func (rq *RenderQueue) DrawPrimitives(primitives []graphics.Primitive)
- func (rq *RenderQueue) EnableSnapMSDFToPixels(enable bool)
- func (rq *RenderQueue) FlushPrimitiveBuffer()
- func (rq *RenderQueue) GetCurrentClipRect() *[4]int
- func (rq *RenderQueue) GetGL() *glapi.Context
- func (rq *RenderQueue) GetPrimitiveBuffer() *pipelines.PrimitiveBuffer
- func (rq *RenderQueue) GetSurfaceSize() (int, int)
- func (rq *RenderQueue) PopClipRect()
- func (rq *RenderQueue) PrepareFrame()
- func (rq *RenderQueue) Present()
- func (rq *RenderQueue) PushClipRect(x, y, width, height int)
- func (rq *RenderQueue) RenderFrame()
- func (rq *RenderQueue) SetMSDFAtlas(atlasImg image.Image, pxRange float64)
- func (rq *RenderQueue) SetMSDFMode(mode int)
- func (rq *RenderQueue) SetOnBeforeAddToQueue(fn func())
- func (rq *RenderQueue) SetPriority(priority int)
- type Renderer
- func (r *Renderer) AddRenderQueue(rq *RenderQueue)
- func (r *Renderer) Clear(c color.Color)
- func (r *Renderer) CreateMSDFAtlas() graphics.MSDFAtlas
- func (r *Renderer) CreateRenderQueue() *RenderQueue
- func (r *Renderer) Dispose()
- func (r *Renderer) GetContext() *glapi.Context
- func (r *Renderer) GetCurrentClipRect() *[4]int
- func (r *Renderer) GetSurface() *Surface
- func (r *Renderer) PopClipRect()
- func (r *Renderer) PrepareFrame()
- func (r *Renderer) PushClipRect(x, y, width, height int)
- func (r *Renderer) Render(getFramebufferSize func() (int, int))
- func (r *Renderer) Resize(width, height int)
- type Surface
- type Texture
- func (t *Texture) Clip(minX, minY, maxX, maxY float32)
- func (t *Texture) Dispose()
- func (t *Texture) FlipHorizontal()
- func (t *Texture) FlipVertical()
- func (t *Texture) GLRender()
- func (t *Texture) Handle() uintptr
- func (t *Texture) IsDisposed() bool
- func (t *Texture) Move(x, y float32)
- func (t *Texture) Render()
- func (t *Texture) RenderToQueue(rq graphics.RenderQueue)
- func (t *Texture) Resize(width, height float32)
- func (t *Texture) Rotate(a, pivotX, pivotY float32)
- func (t *Texture) Scale(x, y float32)
- func (t *Texture) SetFlipHorizontal(shouldFlip bool)
- func (t *Texture) SetFlipVertical(shouldFlip bool)
- func (t *Texture) SetHandle(h textureHandle)
- func (t *Texture) SetShouldBeRendered(shouldRender bool)
- func (t *Texture) UpdateImage(img image.Image) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RenderQueue ¶
type RenderQueue struct {
ShaderManager *shader.ShaderManager
Textures map[textureHandle]*Texture
// contains filtered or unexported fields
}
RenderQueue manages rendering operations for OpenGL
func NewRenderQueue ¶
func NewRenderQueue(ctx *glapi.Context, surface *Surface) *RenderQueue
NewRenderQueue creates a new render queue
func (*RenderQueue) AddCircle ¶
func (rq *RenderQueue) AddCircle(cx, cy int, radius float32, c color.Color, segments int) graphics.Shape
AddCircle creates a new circle shape
func (*RenderQueue) AddDynamicRenderable ¶
func (rq *RenderQueue) AddDynamicRenderable(vertexData []byte, layout graphics.VertexBufferLayout, shaderHandle int, uniforms map[string]graphics.Uniform, dataMap map[string][]byte) graphics.ShaderRenderable
AddDynamicRenderable creates a new dynamic renderable
func (*RenderQueue) AddPolygon ¶
func (rq *RenderQueue) AddPolygon(cx, cy int, width float32, c color.Color, sides int) graphics.Shape
AddPolygon creates a new polygon shape
func (*RenderQueue) AddPolygonFromVertices ¶
func (rq *RenderQueue) AddPolygonFromVertices(cx, cy int, width float32, vertices []graphics.Vertex) graphics.Shape
AddPolygonFromVertices creates a new polygon from vertices
func (*RenderQueue) AddRectangle ¶
AddRectangle creates a new rectangle shape
func (*RenderQueue) AddRoundedRectangle ¶
func (rq *RenderQueue) AddRoundedRectangle(x, y, width, height, radius int, c color.Color) graphics.Shape
AddRoundedRectangle creates a new rounded rectangle shape
func (*RenderQueue) AddToRenderQueue ¶
func (rq *RenderQueue) AddToRenderQueue(r graphics.Renderable)
AddToRenderQueue adds a renderable to the queue
func (*RenderQueue) AddTriangle ¶
AddTriangle creates a new triangle shape
func (*RenderQueue) CompileShader ¶
func (rq *RenderQueue) CompileShader(code string) graphics.ShaderHandle
CompileShader compiles a shader
func (*RenderQueue) CreateMSDFAtlas ¶
func (rq *RenderQueue) CreateMSDFAtlas() graphics.MSDFAtlas
CreateMSDFAtlas creates a new MSDF font atlas
func (*RenderQueue) CreateTexture ¶
func (rq *RenderQueue) CreateTexture(img image.Image) graphics.Texture
CreateTexture creates a new texture from an image
func (*RenderQueue) CreateTextureFromImage ¶
CreateTextureFromImage creates a texture from an image
func (*RenderQueue) DisposeTexture ¶
func (rq *RenderQueue) DisposeTexture(h uintptr)
DisposeTexture disposes a texture by handle
func (*RenderQueue) DrawPrimitiveBuffer ¶
func (rq *RenderQueue) DrawPrimitiveBuffer(vertices []graphics.PrimitiveVertex)
DrawPrimitiveBuffer draws vertices to the primitive buffer
func (*RenderQueue) DrawPrimitiveBufferWithClipRects ¶
func (rq *RenderQueue) DrawPrimitiveBufferWithClipRects(vertices []graphics.PrimitiveVertex, clipRects []*[4]int)
DrawPrimitiveBufferWithClipRects draws vertices with per-vertex clip rects
func (*RenderQueue) DrawPrimitives ¶
func (rq *RenderQueue) DrawPrimitives(primitives []graphics.Primitive)
DrawPrimitives draws primitives to the buffer
func (*RenderQueue) EnableSnapMSDFToPixels ¶
func (rq *RenderQueue) EnableSnapMSDFToPixels(enable bool)
EnableSnapMSDFToPixels enables pixel snapping for MSDF
func (*RenderQueue) FlushPrimitiveBuffer ¶
func (rq *RenderQueue) FlushPrimitiveBuffer()
FlushPrimitiveBuffer forces immediate render of pending primitives
func (*RenderQueue) GetCurrentClipRect ¶
func (rq *RenderQueue) GetCurrentClipRect() *[4]int
GetCurrentClipRect returns the current clip rectangle
func (*RenderQueue) GetGL ¶
func (rq *RenderQueue) GetGL() *glapi.Context
GetGL returns the GL context
func (*RenderQueue) GetPrimitiveBuffer ¶
func (rq *RenderQueue) GetPrimitiveBuffer() *pipelines.PrimitiveBuffer
GetPrimitiveBuffer returns the primitive buffer
func (*RenderQueue) GetSurfaceSize ¶
func (rq *RenderQueue) GetSurfaceSize() (int, int)
GetSurfaceSize returns the surface size
func (*RenderQueue) PopClipRect ¶
func (rq *RenderQueue) PopClipRect()
PopClipRect pops a clip rectangle
func (*RenderQueue) PrepareFrame ¶
func (rq *RenderQueue) PrepareFrame()
PrepareFrame clears the render queue for a new frame
func (*RenderQueue) Present ¶
func (rq *RenderQueue) Present()
Present renders this queue's contents immediately
func (*RenderQueue) PushClipRect ¶
func (rq *RenderQueue) PushClipRect(x, y, width, height int)
PushClipRect pushes a clip rectangle
func (*RenderQueue) RenderFrame ¶
func (rq *RenderQueue) RenderFrame()
RenderFrame renders all queued items
func (*RenderQueue) SetMSDFAtlas ¶
func (rq *RenderQueue) SetMSDFAtlas(atlasImg image.Image, pxRange float64)
SetMSDFAtlas sets the MSDF atlas texture
func (*RenderQueue) SetMSDFMode ¶
func (rq *RenderQueue) SetMSDFMode(mode int)
SetMSDFMode sets the MSDF rendering mode
func (*RenderQueue) SetOnBeforeAddToQueue ¶
func (rq *RenderQueue) SetOnBeforeAddToQueue(fn func())
SetOnBeforeAddToQueue sets a callback to be called before adding to queue
func (*RenderQueue) SetPriority ¶
func (rq *RenderQueue) SetPriority(priority int)
SetPriority sets the render priority (lower values render first)
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer manages OpenGL rendering state
func NewRenderer ¶
NewRenderer creates a new renderer
func (*Renderer) AddRenderQueue ¶
func (r *Renderer) AddRenderQueue(rq *RenderQueue)
AddRenderQueue adds a render queue to be rendered
func (*Renderer) CreateMSDFAtlas ¶
CreateMSDFAtlas creates a new MSDF atlas
func (*Renderer) CreateRenderQueue ¶
func (r *Renderer) CreateRenderQueue() *RenderQueue
CreateRenderQueue creates and registers a new render queue
func (*Renderer) GetContext ¶
GetContext returns the GL context
func (*Renderer) GetCurrentClipRect ¶
GetCurrentClipRect returns the current clip rectangle or nil if none
func (*Renderer) GetSurface ¶
GetSurface returns the surface
func (*Renderer) PopClipRect ¶
func (r *Renderer) PopClipRect()
PopClipRect pops a clip rectangle from the stack
func (*Renderer) PrepareFrame ¶
func (r *Renderer) PrepareFrame()
PrepareFrame prepares all render queues for a new frame
func (*Renderer) PushClipRect ¶
PushClipRect pushes a clip rectangle onto the stack
type Surface ¶
type Surface struct {
// contains filtered or unexported fields
}
Surface represents the rendering surface (shared between platforms)
func NewSurface ¶
NewSurface creates a new surface with the given dimensions
func (*Surface) GetSurfaceSize ¶
GetSurfaceSize returns the logical surface size (coordinate system dimensions)
func (*Surface) SetSurfaceSize ¶
SetSurfaceSize sets the logical surface size and locks it Once locked, Resize() will not change the size
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture represents an OpenGL texture
func NewTexture ¶
func NewTexture(rq *RenderQueue, img image.Image) *Texture
NewTexture creates a new texture from an image
func (*Texture) FlipHorizontal ¶
func (t *Texture) FlipHorizontal()
FlipHorizontal flips the texture horizontally
func (*Texture) FlipVertical ¶
func (t *Texture) FlipVertical()
FlipVertical flips the texture vertically
func (*Texture) IsDisposed ¶
IsDisposed returns whether the texture has been disposed
func (*Texture) RenderToQueue ¶
func (t *Texture) RenderToQueue(rq graphics.RenderQueue)
RenderToQueue adds the texture to a specific render queue
func (*Texture) SetFlipHorizontal ¶
SetFlipHorizontal sets horizontal flip state
func (*Texture) SetFlipVertical ¶
SetFlipVertical sets vertical flip state
func (*Texture) SetHandle ¶
func (t *Texture) SetHandle(h textureHandle)
SetHandle sets the texture handle
func (*Texture) SetShouldBeRendered ¶
SetShouldBeRendered sets whether the texture should be rendered