summaryrefslogtreecommitdiff
path: root/gfx/models/mesh.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-17 22:43:51 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-17 22:43:51 +0100
commit9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be (patch)
treefad012153b02c786c3471e2e70119feaf5b8fe43 /gfx/models/mesh.cpp
parentRevamp how VertexArrayObject configures attributes and data (diff)
downloadilt-9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be.tar.bz2
ilt-9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be.tar.xz
ilt-9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be.zip
Separate storing of mesh vertex/index data from configuring VAO
Diffstat (limited to 'gfx/models/mesh.cpp')
-rw-r--r--gfx/models/mesh.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp
index 4200703..2c849e7 100644
--- a/gfx/models/mesh.cpp
+++ b/gfx/models/mesh.cpp
@@ -7,10 +7,18 @@
Mesh::Mesh(const std::span<const Vertex> vertices, const std::span<const unsigned int> indices, GLenum m) :
m_numIndices {static_cast<GLsizei>(indices.size())}, mode {m}
{
- VertexArrayObject {m_vertexArrayObject}
+ VertexArrayObject::data(vertices, m_vertexArrayBuffers[0], GL_ARRAY_BUFFER);
+ VertexArrayObject::data(indices, m_vertexArrayBuffers[1], GL_ARRAY_BUFFER);
+ configureVAO(m_vertexArrayObject);
+}
+
+VertexArrayObject &
+Mesh::configureVAO(VertexArrayObject && vao) const
+{
+ return vao
.addAttribs<Vertex, &Vertex::pos, &Vertex::texCoord, &Vertex::normal, &Vertex::colour, &Vertex::material>(
- m_vertexArrayBuffers[0], vertices)
- .addIndices(m_vertexArrayBuffers[1], indices);
+ m_vertexArrayBuffers[0])
+ .addIndices(m_vertexArrayBuffers[1]);
}
void