diff options
Diffstat (limited to 'gfx/models')
-rw-r--r-- | gfx/models/mesh.cpp | 20 | ||||
-rw-r--r-- | gfx/models/mesh.h | 3 |
2 files changed, 10 insertions, 13 deletions
diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index 55759cb..52c9275 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -21,24 +21,22 @@ Mesh::configureVAO(VertexArrayObject && vao) const .addIndices(m_vertexArrayBuffers[1]);
}
-GLsizei
-Mesh::count() const
+void
+Mesh::Draw() const
{
- return m_numIndices;
-}
+ glBindVertexArray(m_vertexArrayObject);
-GLenum
-Mesh::type() const
-{
- return mode;
+ glDrawElements(mode, m_numIndices, GL_UNSIGNED_INT, nullptr);
+
+ glBindVertexArray(0);
}
void
-Mesh::Draw() const
+Mesh::DrawInstanced(GLuint vao, GLsizei count) const
{
- glBindVertexArray(m_vertexArrayObject);
+ glBindVertexArray(vao);
- glDrawElements(mode, m_numIndices, GL_UNSIGNED_INT, nullptr);
+ glDrawElementsInstanced(mode, m_numIndices, GL_UNSIGNED_INT, nullptr, count);
glBindVertexArray(0);
}
diff --git a/gfx/models/mesh.h b/gfx/models/mesh.h index 472b7ed..538c57a 100644 --- a/gfx/models/mesh.h +++ b/gfx/models/mesh.h @@ -14,9 +14,8 @@ public: Mesh(const std::span<const Vertex> vertices, const std::span<const unsigned int> indices, GLenum = GL_TRIANGLES);
void Draw() const;
+ void DrawInstanced(GLuint vao, GLsizei count) const;
VertexArrayObject & configureVAO(VertexArrayObject &&) const;
- GLsizei count() const;
- GLenum type() const;
private:
glVertexArray m_vertexArrayObject;
|