Documentation ¶
Overview ¶
Package gfx provides APIs for shaders, VAO creation, and text rendering.
Index ¶
- func Alpha() (alpha float32)
- func InitProgram() error
- func SetAlpha(alpha float32)
- func SetModelMatrixRect(r image.Rectangle)
- func SetModelMatrixRotatedRect(r image.Rectangle, radians float32)
- func SetProjectionViewMatrix(m matrix.Matrix4)
- func TextRenderMaxWidth(w int) func(s *textRenderSettings)
- type TextColor
- type TextRenderOpt
- type TextRenderer
- type VAO
- type VAODrawMode
- type VAOVertexData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetModelMatrixRect ¶
SetModelMatrixRect sets the model matrix to the rectangle.
func SetModelMatrixRotatedRect ¶
SetModelMatrixRotatedRect sets the model matrix to the rotated rectangle.
func SetProjectionViewMatrix ¶
SetProjectionViewMatrix sets the projection view matrix.
func TextRenderMaxWidth ¶ added in v1.1.0
func TextRenderMaxWidth(w int) func(s *textRenderSettings)
TextRenderMaxWidth is an option
Types ¶
type TextRenderOpt ¶ added in v1.1.0
type TextRenderOpt func(f *textRenderSettings)
TextRenderOpt is an option to pass to Render.
type TextRenderer ¶
type TextRenderer struct {
// contains filtered or unexported fields
}
A TextRenderer measures and renders text. It is designed to render single lines of [A-Z0-9] characters.
func NewTextRenderer ¶
func NewTextRenderer(ttfBytes []byte, size int) *TextRenderer
NewTextRenderer creates a new TextRenderer from a TTF font file and a size.
func (*TextRenderer) LineHeight ¶
func (t *TextRenderer) LineHeight() int
LineHeight returns the line height. Useful for measurements.
func (*TextRenderer) Measure ¶
func (t *TextRenderer) Measure(text string) image.Point
Measure returns an image.Point with the width and height of the given text.
func (*TextRenderer) Render ¶
func (t *TextRenderer) Render(text string, pt image.Point, color TextColor, opts ...TextRenderOpt) (dx int)
Render renders color text at the given point that points at the origin (baseline).
type VAO ¶
type VAO struct {
// contains filtered or unexported fields
}
VAO is a Vertex Array Object for one element type (lines, triangles, etc).
func NewVAO ¶
func NewVAO(data *VAOVertexData) *VAO
NewVAO creates a VAO with the given vertex data.
Since NewVAO defers the creation of the actual OpenGL VAO till the first rendering, callers may call NewVAO at the package scope to simplify code.
func NewVAOLoadData ¶
func NewVAOLoadData(loadData func() *VAOVertexData) *VAO
NewVAOLoadData creates a VAO with a data loader function that provides vertex data.
Use this over NewVAO at the package scope if loading the vertex data requires flags to be parsed or some other requirement.
func TexturedPLYVAO ¶
TexturedPLYVAO returns a VAO decoded from a PLY Reader and a texture from another Reader.
type VAODrawMode ¶
type VAODrawMode int
VAODrawMode is analogous to the mode argument to gl.DrawElements.
const ( Triangles VAODrawMode = gl.TRIANGLES Lines = gl.LINES )
Enum values for VAODrawMode.
type VAOVertexData ¶
type VAOVertexData struct { // Mode is the mode like triangles or lines. Mode VAODrawMode // Vertices is a required slice of flattened (x, y, z) vertices. Vertices []float32 // TexCoords is an optional slice of flattened (s, t) coords. TexCoords []float32 // Colors is an optional slice of flattened (r, g, b) values. Colors []float32 // Indices is a required slice of indices into all the buffers. Indices []uint16 // TextureRGBA is the optional texture to use. TextureRGBA *image.RGBA }
VAOVertexData is a bunch of slices filled with vertex data to create a VAO.