glutil

package
v0.0.0-...-1050381 Latest Latest
Warning

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

Go to latest
Published: May 7, 2017 License: MIT Imports: 6 Imported by: 5

Documentation

Overview

glutil contains common functions to deal with OpenGl and WebGL, such as loading data into Buffers and Textures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadBuffer

func LoadBuffer(data []byte) gl.Buffer

LoadBuffer takes a float32 slice and stores the underlying data in a buffer on the GPU.

func LoadBufferFloat32

func LoadBufferFloat32(data []float32) gl.Buffer

LoadBufferFloat32 takes a float32 slice and stores the underlying data in a buffer on the GPU.

func LoadBufferUint16

func LoadBufferUint16(data []uint16) gl.Buffer

LoadBufferUint16 takes a uint16 slice and stores the underlying data in a buffer on the GPU.

func LoadBufferVec2

func LoadBufferVec2(data []mgl32.Vec2) gl.Buffer

func LoadBufferVec3

func LoadBufferVec3(data []mgl32.Vec3) gl.Buffer

func LoadIndexBuffer

func LoadIndexBuffer(data []uint16) gl.Buffer

LoadIndexBuffer takes a uint16 slice and stores the underlying data in an ELEMENT_ARRAY buffer on the GPU.

func LoadTextureData

func LoadTextureData(width, height int, data []uint8) (gl.Texture, error)

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.

Jump to

Keyboard shortcuts

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