VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Public Member Functions | Static Public Member Functions | List of all members

Mesh bound to a specific Shader. More...

Public Member Functions

 MeshInstance ()
 Construct an empty MeshInstance. More...
 
 MeshInstance (GLenum mode, const MeshPtr &mesh, const ShaderPtr &shader)
 Construct a MeshInstance which binds the given Mesh to the given Shader. More...
 
GLenum getMode () const
 Returns the GL primitive type to draw (i.e. GL_TRIANGLES). More...
 
void setMode (GLenum value)
 Sets the kind of GL primitive to draw. More...
 
const MeshPtrgetMesh () const
 Returns the current Mesh. More...
 
void setMesh (const MeshPtr &mesh)
 Sets the current Mesh, rebinding vertex Attribute locations. More...
 
const ShaderPtrgetShader () const
 Returns the current Shader to which the current Mesh is bound to. More...
 
void setShader (const ShaderPtr &shader)
 Sets the current shader, rebinding vertex Attribute locations. More...
 
void bind ()
 Binds the Mesh, and its vertex attribute arrays to the attribute locations in this instance's Shader. More...
 
void unbind ()
 Reverses a call to bind(), unbinding the Mesh and disabling vertex attribute arrays. More...
 

Static Public Member Functions

static MeshInstancePtr createCompatibleMesh (int vertexCount, GLenum mode, const ShaderPtr &shader)
 Creates a Mesh that contains all of the vertex Attributes in a given Shader, also creating a MeshInstance that binds the two. More...
 

Detailed Description

Mesh bound to a specific Shader.

This class stores the mapping of vertex Attributes in a Mesh to vertex Attributes in a Shader for efficient binding and rendering.

MeshInstances can either be used on their own as wrappers around GL buffers or in conjunction with Renderer. If used with Renderer, bind() and unbind() will be called as needed when selected.

Constructor & Destructor Documentation

MeshInstance::MeshInstance ( )

Construct an empty MeshInstance.

MeshInstance::MeshInstance ( GLenum  mode,
const MeshPtr mesh,
const ShaderPtr shader 
)

Construct a MeshInstance which binds the given Mesh to the given Shader.

Parameters
modeGL primitive type to draw (i.e. GL_TRIANGLES)
meshMesh to store and read attributes from
shaderShader to bind the Mesh to

Member Function Documentation

void MeshInstance::bind ( )

Binds the Mesh, and its vertex attribute arrays to the attribute locations in this instance's Shader.

Attribute locations are computed and cached. The Mesh is bound and uploaded if necessary. Vertex attribute arrays in the Mesh are then enabled and bound in preparation for rendering.

Note
This method does not bind the associated Shader.
static MeshInstancePtr MeshInstance::createCompatibleMesh ( int  vertexCount,
GLenum  mode,
const ShaderPtr shader 
)
static

Creates a Mesh that contains all of the vertex Attributes in a given Shader, also creating a MeshInstance that binds the two.

Parameters
vertexCountNumber of vertices the Mesh will contain
modeGL primitive type to draw
shaderShader to read vertex Attributes from
Returns
MeshInstance binding the new Mesh and the given Shader
const MeshPtr& MeshInstance::getMesh ( ) const
inline

Returns the current Mesh.

GLenum MeshInstance::getMode ( ) const
inline

Returns the GL primitive type to draw (i.e. GL_TRIANGLES).

const ShaderPtr& MeshInstance::getShader ( ) const
inline

Returns the current Shader to which the current Mesh is bound to.

void MeshInstance::setMesh ( const MeshPtr mesh)

Sets the current Mesh, rebinding vertex Attribute locations.

Parameters
meshMesh to set
void MeshInstance::setMode ( GLenum  value)

Sets the kind of GL primitive to draw.

Parameters
valueGL primitive type to draw
void MeshInstance::setShader ( const ShaderPtr shader)

Sets the current shader, rebinding vertex Attribute locations.

Parameters
shaderShader to set
void MeshInstance::unbind ( )

Reverses a call to bind(), unbinding the Mesh and disabling vertex attribute arrays.

Note
This method does not unbind the associated Shader.