asset

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: 21 Imported by: 8

Documentation

Overview

Package asset provides tools to manage loading, use, and unloading of assets, such as images and audio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDAE

func LoadDAE(path string) (mesh.Mesh, error)

func LoadFile

func LoadFile(path string) ([]byte, error)

func LoadFont

func LoadFont(path string) (*truetype.Font, error)

func LoadOBJ

func LoadOBJ(path string, opts OBJOpts) (mesh.Mesh, error)

LoadOBJ creates a mesh from an obj file.

func LoadTexture

func LoadTexture(path string) (gl.Texture, error)

LoadTexture from local assets. Handles jpg, png, and static gifs.

func LoadTextureData2D

func LoadTextureData2D(data [][]uint8) (gl.Texture, error)

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

func LoadTextureDataImage(img image.Image) (gl.Texture, error)

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.

Jump to

Keyboard shortcuts

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