diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-22 19:06:42 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-22 19:06:42 +0100 |
commit | d1f79b4c438ebf0822741e103b2cb06bdee4514e (patch) | |
tree | a4d574d12cd81d5e33886ce7ca961f7dbe872fcf /gfx/models/mesh.cpp | |
parent | Rename lots of shader files (diff) | |
parent | Keep the instance unused vector sorted and binary search it (diff) | |
download | ilt-d1f79b4c438ebf0822741e103b2cb06bdee4514e.tar.bz2 ilt-d1f79b4c438ebf0822741e103b2cb06bdee4514e.tar.xz ilt-d1f79b4c438ebf0822741e103b2cb06bdee4514e.zip |
Merge branch 'instancing'
Diffstat (limited to 'gfx/models/mesh.cpp')
-rw-r--r-- | gfx/models/mesh.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index 2719211..55759cb 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -7,9 +7,30 @@ 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<Vertex>::configure<&Vertex::pos, &Vertex::texCoord, &Vertex::normal, &Vertex::colour,
- &Vertex::material>(
- m_vertexArrayObject, m_vertexArrayBuffers[0], m_vertexArrayBuffers[1], vertices, indices);
+ 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])
+ .addIndices(m_vertexArrayBuffers[1]);
+}
+
+GLsizei
+Mesh::count() const
+{
+ return m_numIndices;
+}
+
+GLenum
+Mesh::type() const
+{
+ return mode;
}
void
|