Documentation ¶
Overview ¶
Package resources defines and loads shader and mesh resources.
Index ¶
- func Load() error
- func Release()
- type CellMesh
- type GridMesh
- type Mesh
- type QuadMesh
- type Shader
- func (s *Shader) Release()
- func (s *Shader) Set1f(name string, v float32) error
- func (s *Shader) Set1i(name string, v int) error
- func (s *Shader) Set2f(name string, a, b float32) error
- func (s *Shader) Set4f(name string, a, b, c, d float32) error
- func (s *Shader) SetMat16(name string, m []float32) error
- func (s *Shader) Unuse()
- func (s *Shader) Use()
- type TextureAtlas
- func (ta *TextureAtlas) Allocate(width, height int) (image.Rectangle, bool)
- func (ta *TextureAtlas) Bind()
- func (ta *TextureAtlas) Clear()
- func (ta *TextureAtlas) Release()
- func (a *TextureAtlas) Save(file string) error
- func (ta *TextureAtlas) Set(region image.Rectangle, src *image.RGBA)
- func (ta *TextureAtlas) Size() (int, int)
- func (ta *TextureAtlas) Unbind()
- type TexturedQuadMesh
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CellMesh ¶
type CellMesh struct {
// contains filtered or unexported fields
}
CellMesh defines a set of simulation cells.
type GridMesh ¶
type GridMesh struct {
// contains filtered or unexported fields
}
GridMesh defines a grid.
type QuadMesh ¶
type QuadMesh struct {
// contains filtered or unexported fields
}
QuadMesh defines a simple, untextured quad.
type Shader ¶
type Shader struct {
// contains filtered or unexported fields
}
Shader loads GLSL shader sources and facilitates setting uniform values.
func CompileShader ¶
CompileShader loads the given vertex-, geometry- and fragment shader sources and compiles them into a single program. The name value is used in error emssages to more easily identify the source of a problem.
type TextureAtlas ¶
type TextureAtlas struct {
// contains filtered or unexported fields
}
A texture atlas is used to tightly pack arbitrarily many small images into a single texture.
The actual implementation is based on the article by Jukka Jylänki: "A Thousand Ways to Pack the Bin - A Practical Approach to Two-Dimensional Rectangle Bin Packing", February 27, 2010.
More precisely, this is an implementation of the 'Skyline Bottom-Left' algorithm.
func NewTextureAtlas ¶
func NewTextureAtlas(width, height int) *TextureAtlas
NewAtlas creates a new texture atlas.
The given width, height determine the size of the underlying texture. The values are scaled up to the nearest power-of-two value, if they are not already a power-of-two.
func (*TextureAtlas) Allocate ¶
func (ta *TextureAtlas) Allocate(width, height int) (image.Rectangle, bool)
Allocate allocates a new region of the given dimensions in the atlas. It returns false if the allocation failed. This can happen when the specified dimensions exceed atlas bounds, or the atlas is full.
func (*TextureAtlas) Bind ¶
func (ta *TextureAtlas) Bind()
Bind binds the atlas texture, so it can be used for rendering. This implictely commits the texture data to the GPU if it has changed since the last Bind call.
func (*TextureAtlas) Clear ¶
func (ta *TextureAtlas) Clear()
Clear removes all allocated regions from the atlas. This invalidates any previously allocated regions.
func (*TextureAtlas) Release ¶
func (ta *TextureAtlas) Release()
Release clears all atlas resources.
func (*TextureAtlas) Save ¶
func (a *TextureAtlas) Save(file string) error
Save saves the texture image as a PNG file with the given name.
func (*TextureAtlas) Set ¶
func (ta *TextureAtlas) Set(region image.Rectangle, src *image.RGBA)
Set draws the given image into the given region of the atlas. It assumes there is enough space available for the data to fit.
func (*TextureAtlas) Size ¶
func (ta *TextureAtlas) Size() (int, int)
Size returns the texture dimensions.
func (*TextureAtlas) Unbind ¶
func (ta *TextureAtlas) Unbind()
Unbind unbinds the current texture. Note that this applies to any texture currently active. If this is not the atlas texture, it will still perform the action.
type TexturedQuadMesh ¶
type TexturedQuadMesh struct {
// contains filtered or unexported fields
}
TexturedQuadMesh defines a simple quad.
func (*TexturedQuadMesh) CommitTexture ¶
func (m *TexturedQuadMesh) CommitTexture(img *image.RGBA, w, h int)
CommitTexture uploads the given texture and sets UV coordinates for the given size. This size is not necessarily the same as the size of img. Meaning w/h define a subset of img.
func (*TexturedQuadMesh) Commitfv ¶
func (m *TexturedQuadMesh) Commitfv([]float32, uint32)
func (*TexturedQuadMesh) Commitiv ¶
func (m *TexturedQuadMesh) Commitiv([]int32, uint32)
func (*TexturedQuadMesh) Release ¶
func (m *TexturedQuadMesh) Release()
Release clears mesh resources.