VoltAir
|
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 MeshPtr & | getMesh () const |
Returns the current Mesh. More... | |
void | setMesh (const MeshPtr &mesh) |
Sets the current Mesh, rebinding vertex Attribute locations. More... | |
const ShaderPtr & | getShader () 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... | |
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.
MeshInstance::MeshInstance | ( | ) |
Construct an empty MeshInstance.
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.
|
static |
Creates a Mesh that contains all of the vertex Attributes in a given Shader, also creating a MeshInstance that binds the two.
vertexCount | Number of vertices the Mesh will contain |
mode | GL primitive type to draw |
shader | Shader to read vertex Attributes from |
|
inline |
Returns the GL primitive type to draw (i.e. GL_TRIANGLES).
|
inline |
void MeshInstance::setMesh | ( | const MeshPtr & | mesh | ) |
void MeshInstance::setMode | ( | GLenum | value | ) |
Sets the kind of GL primitive to draw.
value | GL primitive type to draw |
void MeshInstance::setShader | ( | const ShaderPtr & | shader | ) |