opengl

package
v0.0.0-...-5202d7a Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AtlasWidth  = 512
	AtlasHeight = 512
	MaxTextures = 100
	MaxVertices = 600000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttribLocation

type AttribLocation uint32
const (
	ATTRIB_POS_LOCATION           AttribLocation = 0
	ATTRIB_SHAPE_POS_LOCATION     AttribLocation = 1
	ATTRIB_LOCAL_POS_LOCATION     AttribLocation = 2
	ATTRIB_OPCODE_LOCATION        AttribLocation = 3
	ATTRIB_RADIUS_LOCATION        AttribLocation = 4
	ATTRIB_COLOR_LOCATION         AttribLocation = 5
	ATTRIB_WIDTH_LOCATION         AttribLocation = 6
	ATTRIB_HEIGHT_LOCATION        AttribLocation = 7
	ATTRIB_TEX_COORD_LOCATION     AttribLocation = 8
	ATTRIB_RESOLUTION_LOCATION    AttribLocation = 9
	ATTRIB_TEXTURE_INDEX_LOCATION AttribLocation = 10
	ATTRIB_FONT_INDEX_LOCATION    AttribLocation = 11
)

type Framebuffer

type Framebuffer struct {
	ID         uint32
	TextureID  uint32
	RenderID   uint32
	Width      int
	Height     int
	ClearColor [4]float32
	// contains filtered or unexported fields
}

func NewFramebuffer

func NewFramebuffer(width, height int, textureManager *TextureManager, mainRenderer *Renderer) (*Framebuffer, error)

func (*Framebuffer) Bind

func (fb *Framebuffer) Bind()

func (*Framebuffer) Clear

func (fb *Framebuffer) Clear(c color.Color)

func (*Framebuffer) Destroy

func (fb *Framebuffer) Destroy()

func (*Framebuffer) Draw

func (fb *Framebuffer) Draw(x, y, width, height int)

func (*Framebuffer) GetHeight

func (fb *Framebuffer) GetHeight() int

func (*Framebuffer) GetID

func (fb *Framebuffer) GetID() uint32

func (*Framebuffer) GetTextureID

func (fb *Framebuffer) GetTextureID() uint32

func (*Framebuffer) GetWidth

func (fb *Framebuffer) GetWidth() int

func (*Framebuffer) Resize

func (fb *Framebuffer) Resize(width, height int)

func (*Framebuffer) Unbind

func (fb *Framebuffer) Unbind()

type FramebufferRenderer

type FramebufferRenderer struct {
	*Renderer
	// contains filtered or unexported fields
}

func NewFramebufferRenderer

func NewFramebufferRenderer(renderer *Renderer, framebuffer *Framebuffer) (*FramebufferRenderer, error)

func (*FramebufferRenderer) Bind

func (fr *FramebufferRenderer) Bind()

func (*FramebufferRenderer) Clear

func (fr *FramebufferRenderer) Clear(c color.Color)

func (*FramebufferRenderer) Draw

func (fr *FramebufferRenderer) Draw(x, y, width, height int)

func (*FramebufferRenderer) Unbind

func (fr *FramebufferRenderer) Unbind()

type GraphicsBackend

type GraphicsBackend struct {
	*window.Window
	*Renderer
}

func NewGraphicsBackend

func NewGraphicsBackend(width, height int) (*GraphicsBackend, error)

func (*GraphicsBackend) Close

func (backend *GraphicsBackend) Close()

func (*GraphicsBackend) PollEvents

func (backend *GraphicsBackend) PollEvents() bool

type Renderer

type Renderer struct {
	Vertices       []graphics.Vertex
	Framebuffers   []*Framebuffer
	VertexCount    int
	Textures       []TextureAtlas
	TextureCount   int
	VAO            uint32
	VBO            uint32
	BufferCapacity int
	ShaderProgram  uint32
	Font           *font.Font
	FontTextureID  uint32
	*TextureManager
}

func NewRenderer

func NewRenderer() *Renderer

func (*Renderer) AddFramebuffer

func (renderer *Renderer) AddFramebuffer(width, height int) (graphics.Framebuffer, error)

func (*Renderer) Begin

func (renderer *Renderer) Begin()

func (*Renderer) BindFramebuffer

func (renderer *Renderer) BindFramebuffer(fb graphics.Framebuffer)

func (*Renderer) Clear

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

func (*Renderer) Destroy

func (renderer *Renderer) Destroy()

func (*Renderer) Draw

func (renderer *Renderer) Draw()

func (*Renderer) End

func (renderer *Renderer) End()

func (*Renderer) GetViewportSize

func (renderer *Renderer) GetViewportSize() (int, int)

func (*Renderer) Init

func (renderer *Renderer) Init()

func (*Renderer) LoadFont

func (renderer *Renderer) LoadFont(fontData []byte) (graphics.Font, error)

func (*Renderer) Render

func (renderer *Renderer) Render(shape graphics.Renderable)

func (*Renderer) RenderFramebuffer

func (renderer *Renderer) RenderFramebuffer(fb graphics.Framebuffer, options *graphics.TextureRenderOptions)

func (*Renderer) RenderText

func (renderer *Renderer) RenderText(text string, options *graphics.TextRenderOptions)

func (*Renderer) RenderTexture

func (renderer *Renderer) RenderTexture(textureID uint32, options *graphics.TextureRenderOptions)

func (*Renderer) UnbindFramebuffer

func (renderer *Renderer) UnbindFramebuffer()

type TextureAtlas

type TextureAtlas struct {
	ID     uint32
	Width  int
	Height int
	Image  *image.RGBA
}

type TextureManager

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

func NewTextureManager

func NewTextureManager(renderer *Renderer) *TextureManager

func (*TextureManager) GetManagerID

func (tm *TextureManager) GetManagerID(textureID uint32) (uint32, bool)

func (*TextureManager) RegisterFramebufferTexture

func (tm *TextureManager) RegisterFramebufferTexture(textureID uint32, width, height int)

func (*TextureManager) RegisterTexture

func (tm *TextureManager) RegisterTexture(textureID uint32) uint32

func (*TextureManager) UpdateTexture

func (tm *TextureManager) UpdateTexture(textureID uint32, img image.Image, xOffset, yOffset int)

func (*TextureManager) UploadTexture

func (tm *TextureManager) UploadTexture(img image.Image) uint32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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