glutil

package
v0.0.0-...-793ea6c Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CoordSys is a coordinate system matrix converting from a right-handed Z
	// up coordinate system to a right-handed Y up coordinate system.
	CoordSys = lmath.CoordSysZUpRight.ConvertMat4(lmath.CoordSysYUpRight)
)
View Source
var DefaultBlendState = gfx.BlendState{
	gfx.Color{R: 0, G: 0, B: 0, A: 0},
	gfx.BOne,
	gfx.BZero,
	gfx.BOne,
	gfx.BZero,
	gfx.BAdd,
	gfx.BAdd,
}
View Source
var DefaultCommonState = &CommonState{
	DefaultState,
	image.Rect(0, 0, 0, 0),
	gfx.Color{R: 0.0, G: 0.0, B: 0.0, A: 0.0},
	1.0,
	0,
	false,
	false,
	false,
	false,
	0,
}
View Source
var DefaultStencilState = gfx.StencilState{
	0xFFFF,
	0xFFFF,
	0,
	gfx.SKeep,
	gfx.SKeep,
	gfx.SKeep,
	gfx.Always,
}

Functions

func ConvertRect

func ConvertRect(rect, bounds image.Rectangle) (x, y, width, height int)

func ParseVersionString

func ParseVersionString(ver string) (major, minor, release int, vendor string)

ParseVersionString parses a OpenGL version string and returns it's components.

The string returned may be 'major.minor' or 'major.minor.release' and may be followed by a space and any vendor specific information. For more information see:

http://www.opengl.org/sdk/docs/man/xhtml/glGetString.xml

func PreLoadShader

func PreLoadShader(s *gfx.Shader, done chan *gfx.Shader) (doLoad bool, err error)

PreLoadShader implements the precusor to gfx.Canvas.LoadShader; it returns a boolean value whether or not loading of the given shader should continue, and a (warning) error, if any.

func UnconvertRect

func UnconvertRect(bounds image.Rectangle, x, y, width, height int) (rect image.Rectangle)

Types

type CommonState

type CommonState struct {
	*gfx.State
	Scissor               image.Rectangle
	ClearColor            gfx.Color
	ClearDepth            float64
	ClearStencil          int
	Blend                 bool
	ScissorTest           bool
	Multisample           bool
	SampleAlphaToCoverage bool
	ShaderProgram         uint32
}

CommonState represents a set of common OpenGL state properties not covered by gfx.State.

type Extensions

type Extensions map[string]struct{}

Extensions represents a set of OpenGL extensions. If an extension is present it is in the map.

func ParseExtensions

func ParseExtensions(s string) Extensions

ParseExtensions parses the space-seperated list of OpenGL extensions and returned them.

func (Extensions) Present

func (e Extensions) Present(s string) bool

Present tells if the given extension string is present or not.

func (Extensions) Slice

func (e Extensions) Slice() []string

Slice returns the extensions as a slice of strings.

type IndexStr

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

IndexStr generates index strings with the given prefix, for example:

Texture0
Texture1
Texture2

func NewIndexStr

func NewIndexStr(prefix string) *IndexStr

NewIndexStr returns a new index string generator with the given prefix.

func (IndexStr) Name

func (i IndexStr) Name(n int) string

Name returns the index string for the given index.

type LocationCache

type LocationCache struct {
	GetAttribLocation, GetUniformLocation func(name string) int
	// contains filtered or unexported fields
}

LocationCache caches GLSL uniform and attribute locations.

func (*LocationCache) FindAttrib

func (l *LocationCache) FindAttrib(name string) int

FindAttrib finds the named attribute location in the cache, if it's not in the cache it is queried from l.GetAttribLocation directly and cached for later.

func (*LocationCache) FindUniform

func (l *LocationCache) FindUniform(name string) int

FindUniform finds the named uniform location in the cache, if it's not in the cache it is queried from l.GetUniformLocation directly and cached for later.

type MVPCache

type MVPCache struct {

	// The cached pre-calculated matrices to feed directly into shaders.
	Model, View, Projection, MVP gfx.Mat4
	// contains filtered or unexported fields
}

MVPCache caches a gfx.Object's Model, View, Projection and MVP matrices.

Each one is precalculated such that they can be fed directly into shaders without a recalculation each frame.

func (*MVPCache) Update

func (m *MVPCache) Update(o *gfx.Object, c gfx.Camera)

Update updates the cache (if needed) to account for changes to the object's transform, or the camera's transform/projection changing. It should be called before drawing the object each frame.

Jump to

Keyboard shortcuts

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