resources

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package resources handles the managing of assets such as images and shaders.

Index

Constants

View Source
const (
	// ComponentTypeShader represents a shaders components type.
	ComponentTypeShader = "shader"
	// CameraUniform is the expected name of view matrix uniform in the shader.
	CameraUniform = "camera"
	// ProjectionUniform is the expected name of the projection matrix uniform in the shader.
	ProjectionUniform = "projection"
	// ModelUniform is the expected name of the model matrix uniform in the shader.
	ModelUniform = "model"
	// TextureUniform is the expected name of the texture uniform in the shader.
	TextureUniform = "tex"
	// VertexAttribute is the expected name of the vertex data attribute in the shader.
	VertexAttribute = "vert"
	// VertexTexCordAttribute is the expected name of the vertex texture coordinates attribute in the shader.
	VertexTexCordAttribute = "vertTexCoord"
	// ShaderOutputColor is the expected name of the output color variable leaving the fragment shader.
	ShaderOutputColor = "outputColor"
)
View Source
const (
	// ShaderSrcDir lists the expected location of shaders
	ShaderSrcDir = "assets/shaders/"
)
View Source
const (
	// TextureSrcDir is the expected location of textures
	TextureSrcDir = "assets/textures/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages engine resources.

func NewManager

func NewManager() *Manager

NewManager creates a new Manager to handle shader and texture assets.

func (*Manager) Shaders

func (am *Manager) Shaders() ShaderManager

Shaders retrieves the ShaderManager.

func (*Manager) Textures

func (am *Manager) Textures() TextureManager

Textures retrieves the TextureManager.

type Shader

type Shader interface {
	// GetUniformLoc retrieves the shader location of the specified uniform.
	GetUniformLoc(name string) int32
	// GetAttribLoc retrieves the shader location of a the specified attribute.
	GetAttribLoc(name string) uint32
	// GetName retrieves the name of the shader program.
	GetName() string
	// ProgramID retrieves the program id of the shader program.
	ProgramID() uint32
	// CreateVAO loads the mesh data onto the gpu.
	CreateVAO(components.Mesh) uint32
}

Shader represents the behaviors needed to access a shader and its variables.

type ShaderManager

type ShaderManager interface {
	// LoadProgramFromFile creates a shader program from a vertex and fragment shader source files.
	LoadProgramFromFile(vertSrcFile string, fragSrcFile string, shouldBeDefault bool) (Shader, error)
	// LoadProgramFromSrc creates a shader program from a vertex and fragment shader source strings.
	LoadProgramFromSrc(vertSrc string, fragSrc string, name string, shouldBeDefault bool) (Shader, error)
	// GetShader returns a program id if the shader program was loaded.
	GetShader(key string) (Shader, bool)
	// GetShaderProgram returns the Shader interface with information about the opengl shader.
	GetShaderProgram(id uint32) (Shader, bool)
	// GetDefaultShader returns the name of the default shader.
	GetDefaultShader() uint32
}

ShaderManager interface is used to interact with the shaderManager.

type TextureManager

type TextureManager interface {
	// LoadTexture loads a png file into an opengl texture and returns the texture id.
	LoadTexture(filePath string, key string) (uint32, error)
	// GetTexture returns a texture id if the texture was loaded.
	GetTexture(key string) (texture uint32, isFound bool)
}

TextureManager interface is used to interact with a textureManager

Jump to

Keyboard shortcuts

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