summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'gfx')
-rw-r--r--gfx/models/mesh.cpp8
-rw-r--r--gfx/models/mesh.h3
2 files changed, 6 insertions, 5 deletions
diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp
index 90de8db..4a3d9d4 100644
--- a/gfx/models/mesh.cpp
+++ b/gfx/models/mesh.cpp
@@ -7,7 +7,7 @@
Mesh::Mesh(const std::string & fileName) : Mesh(OBJModel(fileName).ToIndexedModel()) { }
Mesh::Mesh(const IndexedModel & model) :
- m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {model.indices.size()}
+ m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {model.indices.size()}, mode {GL_TRIANGLES}
{
glGenVertexArrays(1, &m_vertexArrayObject);
glBindVertexArray(m_vertexArrayObject);
@@ -38,8 +38,8 @@ Mesh::Mesh(const IndexedModel & model) :
glBindVertexArray(0);
}
-Mesh::Mesh(std::span<Vertex> vertices, std::span<unsigned int> indices) :
- m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {indices.size()}
+Mesh::Mesh(std::span<Vertex> vertices, std::span<unsigned int> indices, GLenum m) :
+ m_vertexArrayObject {}, m_vertexArrayBuffers {}, m_numIndices {indices.size()}, mode {m}
{
glGenVertexArrays(1, &m_vertexArrayObject);
glBindVertexArray(m_vertexArrayObject);
@@ -75,7 +75,7 @@ Mesh::Draw() const
{
glBindVertexArray(m_vertexArrayObject);
- glDrawElementsBaseVertex(GL_TRIANGLES, m_numIndices, GL_UNSIGNED_INT, nullptr, 0);
+ glDrawElementsBaseVertex(mode, m_numIndices, GL_UNSIGNED_INT, nullptr, 0);
glBindVertexArray(0);
}
diff --git a/gfx/models/mesh.h b/gfx/models/mesh.h
index e955644..ebd300b 100644
--- a/gfx/models/mesh.h
+++ b/gfx/models/mesh.h
@@ -17,7 +17,7 @@ class Mesh {
public:
explicit Mesh(const std::string & fileName);
explicit Mesh(const IndexedModel & model);
- Mesh(std::span<Vertex> vertices, std::span<unsigned int> indices);
+ Mesh(std::span<Vertex> vertices, std::span<unsigned int> indices, GLenum = GL_TRIANGLES);
virtual ~Mesh();
NO_COPY(Mesh);
@@ -31,6 +31,7 @@ private:
GLuint m_vertexArrayObject;
std::array<GLuint, NUM_BUFFERS> m_vertexArrayBuffers;
size_t m_numIndices;
+ GLenum mode;
};
#endif