-
class
SGFXAPI::
Mesh
¶ Bundles together one or more VertexBuffer objects, an optional IndexBuffer, a ShaderProgram, and one or more Texture objects, and bounds them together into a “VAO” for rendering.
Public Functions
-
void
GenerateVAO
(int startVertexOffset)¶ Call this once, after the mesh’s properties are set, before calling LinkShaders().
- Parameters
startVertexOffset
-tells the mesh which vertex is the 0th vertex of the mesh. The IndexBuffer will count off this starting vertex if the mesh is indexed. Otherwise, the mesh will start at the vertex indicated, in groups of 3 vertices, with one group of 3 vertices per triangle. Default is 0th vertex.
-
void
LinkShaders
()¶ Call this once, after the mesh has generated a VAO, and before ever calling Bind().
-
void
Bind
()¶ Bind the VAO.
Call this to bind the Mesh; before calling Draw(), the mesh must be bound.
-
void
UnBind
()¶ Unbind the VAO.
-
bool
IsBound
() const¶ Check if the Mesh is bound.
- Return
- true if the Mesh is bound, else returns false.
- See
- Mesh::Bind()
-
void
Draw
(int numIndices, int startIndexOffset)¶ Draw the Mesh.
Mesh must be bound before calling this. The ShaderProgram of this mesh (Mesh::sp) should be “in use” (call ShaderProgram::Use()) before drawing to render properly.
- See
- Mesh::Bind(), Mesh::sp, ShaderProgram::Use()
- Parameters
numIndices
-the number of indices to use for this mesh; default is -1 which means all of the indices in the IndexBuffer if using indexed geometry, or all of the implicit indices/triangles in the VertexBuffer objects if not using indexed geometry.
startIndexOffset
-the start index to use for this mesh; default is 0 which means the first index in the IndexBuffer if using indexed geometry, or all of the implicit indices/triangles in the VertexBuffer.
-
void
CheckIndexBounds
(int numIndices, int startIndexOffset) const¶ This loops through all the indices and checks that they are valid.
-
const VertexDeclaration &
Declaration
() const¶ Return the effective vertex-declaration across all VBOs in the mesh. Only valid after a call to GenerateVAO().
-
PrimitiveType
PrimType
() const¶ Returns the type of primitives used by this mesh (PrimPoint, PrimLineList, PrimLineStrip, PrimTriangleList or PrimTriangleStrip).
Public Members
-
std::vector<std::shared_ptr<VertexBuffer>>
vbs
¶ Add VertexBuffer objects to the Mesh via this public member.
-
std::shared_ptr<IndexBuffer>
ib
¶ Set the IndexBuffer to the mesh - if using indexed geometry - via this public member.
-
std::shared_ptr<ShaderProgram>
sp
¶ Set the ShaderProgram to the mesh via this public member.
-
std::vector<std::shared_ptr<MeshTexture>>
textures
¶ Add MeshTexture objects to the mesh via this public member.
Public Static Functions
-
void
UnBindAll
()¶ Static method to unbind all VAOs.
-
void