Documentation ¶
Overview ¶
glutil contains common functions to deal with OpenGl and WebGL, such as loading data into Buffers and Textures.
Index ¶
- func LoadBuffer(data []byte) gl.Buffer
- func LoadBufferFloat32(data []float32) gl.Buffer
- func LoadBufferUint16(data []uint16) gl.Buffer
- func LoadBufferVec2(data []mgl32.Vec2) gl.Buffer
- func LoadBufferVec3(data []mgl32.Vec3) gl.Buffer
- func LoadIndexBuffer(data []uint16) gl.Buffer
- func LoadTextureData(width, height int, data []uint8) (gl.Texture, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadBuffer ¶
LoadBuffer takes a float32 slice and stores the underlying data in a buffer on the GPU.
func LoadBufferFloat32 ¶
LoadBufferFloat32 takes a float32 slice and stores the underlying data in a buffer on the GPU.
func LoadBufferUint16 ¶
LoadBufferUint16 takes a uint16 slice and stores the underlying data in a buffer on the GPU.
func LoadIndexBuffer ¶
LoadIndexBuffer takes a uint16 slice and stores the underlying data in an ELEMENT_ARRAY buffer on the GPU.
func LoadTextureData ¶
LoadTextureData takes raw RGBA image data and puts it into a texture unit on the GPU. Width and height are refer to the actual image, not the number of RGBA bytes. For example, an 8 by 8 pixel image should be provided as (8, 8, data) even though the size of the data should be 8 * 8 * 4, since there are 4 bytes per pixel.
Errors are returned if: - data is the incorrect size for the provided width and height - either width or height is not a power of 2. This is a requirement for making mipmaps in webgl.
TODO: Example usage. Make sure to give an example that uses image.Pix as data.
It's up to the caller to delete the texture buffer using gl.DeleteTexture(texture) when it's no longer needed. Note that the input data must not be ragged - each row must be the same length.
Types ¶
This section is empty.