Documentation ¶
Overview ¶
Package asset provides tools to manage loading, use, and unloading of assets, such as images and audio.
Index ¶
- func LoadDAE(path string) (mesh.Mesh, error)
- func LoadFile(path string) ([]byte, error)
- func LoadFont(path string) (*truetype.Font, error)
- func LoadOBJ(path string, opts OBJOpts) (mesh.Mesh, error)
- func LoadTexture(path string) (gl.Texture, error)
- func LoadTextureData2D(data [][]uint8) (gl.Texture, error)
- func LoadTextureDataImage(img image.Image) (gl.Texture, error)
- func SetBaseDir(baseDirectory string)
- type OBJOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadTexture ¶
LoadTexture from local assets. Handles jpg, png, and static gifs.
func LoadTextureData2D ¶
LoadTextureData takes raw RGBA image data and puts it into a texture unit on the GPU. 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.
func LoadTextureDataImage ¶
LoadTextureDataImage loads the provided image onto the GPU and returns a reference to the gl Texture.
func SetBaseDir ¶
func SetBaseDir(baseDirectory string)
SetBaseDir sets the base directory from which all path based asset loading occurs on. Note that this method has no effect if used in a +js environment as URL are used in place of file paths on the web.
Types ¶
type OBJOpts ¶
type OBJOpts struct { // The mesh is scaled to be as large as possible while still fitting in a unit sphere. // Use this if you are loading multiple meshes designed at different scales and want to be able to work with them // in a consistent manner. This makes scaling meshes relative to each other very easy to think about. Normalize bool // Center calculates the center of the mesh by finding the min and max values for x,y,z and then shifts // the mesh by a percent of the range you specify. // If nil this is ignored. // Use this if the center of your mesh isn't where you want it to be. // // For example, if your OBJ file contains a unit cube with one corner at the origin and you // specify Center: mgl32.Vec3{0.5, 0.5, 0.5} then the loaded mesh will be a unit cube centered at the origin. Center *mgl32.Vec3 }
OBJOpts describes how to modify a mesh as it is loaded.