renderer

package
v0.0.0-...-f65bbdb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package renderer provides the core rendering components

Index

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) AddLine

func (rq *RenderQueue) AddLine(x1, y1, x2, y2 int, width float32, c color.Color) graphics.Shape

AddLine creates a new line shape

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

func (rq *RenderQueue) AddRectangle(x, y, width, height int, c color.Color) graphics.Shape

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

func (rq *RenderQueue) AddTriangle(x1, y1, x2, y2, x3, y3 int, c color.Color) graphics.Shape

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

func (rq *RenderQueue) CreateTextureFromImage(img image.Image) (graphics.Texture, error)

CreateTextureFromImage creates a texture from an image

func (*RenderQueue) Dispose

func (rq *RenderQueue) Dispose()

Dispose cleans up resources

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

func NewRenderer(ctx *glapi.Context, surface *Surface) *Renderer

NewRenderer creates a new renderer

func (*Renderer) AddRenderQueue

func (r *Renderer) AddRenderQueue(rq *RenderQueue)

AddRenderQueue adds a render queue to be rendered

func (*Renderer) Clear

func (r *Renderer) Clear(c color.Color)

Clear clears the screen with the given color

func (*Renderer) CreateMSDFAtlas

func (r *Renderer) CreateMSDFAtlas() graphics.MSDFAtlas

CreateMSDFAtlas creates a new MSDF atlas

func (*Renderer) CreateRenderQueue

func (r *Renderer) CreateRenderQueue() *RenderQueue

CreateRenderQueue creates and registers a new render queue

func (*Renderer) Dispose

func (r *Renderer) Dispose()

Dispose cleans up renderer resources

func (*Renderer) GetContext

func (r *Renderer) GetContext() *glapi.Context

GetContext returns the GL context

func (*Renderer) GetCurrentClipRect

func (r *Renderer) GetCurrentClipRect() *[4]int

GetCurrentClipRect returns the current clip rectangle or nil if none

func (*Renderer) GetSurface

func (r *Renderer) GetSurface() *Surface

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

func (r *Renderer) PushClipRect(x, y, width, height int)

PushClipRect pushes a clip rectangle onto the stack

func (*Renderer) Render

func (r *Renderer) Render(getFramebufferSize func() (int, int))

Render renders all queued objects

func (*Renderer) Resize

func (r *Renderer) Resize(width, height int)

Resize updates the surface size

type Surface

type Surface struct {
	// contains filtered or unexported fields
}

Surface represents the rendering surface (shared between platforms)

func NewSurface

func NewSurface(width, height int) *Surface

NewSurface creates a new surface with the given dimensions

func (*Surface) GetSurfaceSize

func (s *Surface) GetSurfaceSize() (int, int)

GetSurfaceSize returns the logical surface size (coordinate system dimensions)

func (*Surface) IsLocked

func (s *Surface) IsLocked() bool

IsLocked returns whether the surface size is locked

func (*Surface) Resize

func (s *Surface) Resize(width, height int)

Resize updates the surface size if it's not locked

func (*Surface) SetSurfaceSize

func (s *Surface) SetSurfaceSize(width, height int)

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) Clip

func (t *Texture) Clip(minX, minY, maxX, maxY float32)

Clip sets the clip rectangle in pixel coordinates

func (*Texture) Dispose

func (t *Texture) Dispose()

Dispose cleans up texture resources

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) GLRender

func (t *Texture) GLRender()

GLRender performs the OpenGL rendering

func (*Texture) Handle

func (t *Texture) Handle() uintptr

Handle returns the texture handle

func (*Texture) IsDisposed

func (t *Texture) IsDisposed() bool

IsDisposed returns whether the texture has been disposed

func (*Texture) Move

func (t *Texture) Move(x, y float32)

Move moves the texture to a new position

func (*Texture) Render

func (t *Texture) Render()

Render adds the texture to the render queue

func (*Texture) RenderToQueue

func (t *Texture) RenderToQueue(rq graphics.RenderQueue)

RenderToQueue adds the texture to a specific render queue

func (*Texture) Resize

func (t *Texture) Resize(width, height float32)

Resize resizes the texture to fit specific dimensions

func (*Texture) Rotate

func (t *Texture) Rotate(a, pivotX, pivotY float32)

Rotate rotates the texture (currently not implemented)

func (*Texture) Scale

func (t *Texture) Scale(x, y float32)

Scale scales the texture

func (*Texture) SetFlipHorizontal

func (t *Texture) SetFlipHorizontal(shouldFlip bool)

SetFlipHorizontal sets horizontal flip state

func (*Texture) SetFlipVertical

func (t *Texture) SetFlipVertical(shouldFlip bool)

SetFlipVertical sets vertical flip state

func (*Texture) SetHandle

func (t *Texture) SetHandle(h textureHandle)

SetHandle sets the texture handle

func (*Texture) SetShouldBeRendered

func (t *Texture) SetShouldBeRendered(shouldRender bool)

SetShouldBeRendered sets whether the texture should be rendered

func (*Texture) UpdateImage

func (t *Texture) UpdateImage(img image.Image) error

UpdateImage updates the texture with a new image

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL