Documentation ¶
Overview ¶
Package gfxutil implements basic gfx utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InsertionSort ¶
InsertionSort performs a simple insertion sort on the sort interface. In the case of ByDist it performs generally as fast as sort.Sort except that it can exploit temporal coherence improving performance dramatically when the objects have not moved much.
func OpenShader ¶
OpenShader opens the GLSL shader files specified by the given base path. For example:
s := OpenShader("glsl/basic")
Would return a shader composed of the two GLSL shader sources:
glsl/basic.vert glsl/basic.frag
The filename (e.g. "basic") will be the name of the shader (which is used for debug output only).
If a error is returned it is an IO error and a nil shader is returned.
func OpenTexture ¶
OpenTexture opens the named image file, decodes it, and returns a texture with that image as it's source. As usual, you will also need to import a image decoder, e.g. for png:
import _ "image/png"
The returned texture will have a MinFilter == LinearMipmapLinear (trilinear filtering) a MagFilter == Linear, and Format == DXT1.
If a error is returned it is an IO or image decoding error and a nil texture is returned.
Types ¶
type ByDist ¶
type ByDist struct { // The list of objects to sort. Objects []*gfx.Object // The target position to compare against. The list is sorted based off // each object's distance away from this position (typically this is the // camera's position). Target lmath.Vec3 }
ByDist sorts a list of graphics objects based on their distance away from a target position (typically the camera). As such if the sorted objects are drawn in order then they are drawn back-to-front (which is useful for rendering alpha-blended objects such that transparency appears correct).
Using sort.Reverse this doubles as front-to-back sorting (which is useful for drawing opaque objects efficiently due to depth testing).