From da1c1336596d361678b3f641a1d23ab89e078789 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 17 Apr 2023 17:09:40 +0100 Subject: Revamp how VertexArrayObject configures attributes and data --- gfx/models/mesh.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gfx/models/mesh.cpp') diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index 2719211..4200703 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -7,9 +7,10 @@ Mesh::Mesh(const std::span vertices, const std::span indices, GLenum m) : m_numIndices {static_cast(indices.size())}, mode {m} { - VertexArrayObject::configure<&Vertex::pos, &Vertex::texCoord, &Vertex::normal, &Vertex::colour, - &Vertex::material>( - m_vertexArrayObject, m_vertexArrayBuffers[0], m_vertexArrayBuffers[1], vertices, indices); + VertexArrayObject {m_vertexArrayObject} + .addAttribs( + m_vertexArrayBuffers[0], vertices) + .addIndices(m_vertexArrayBuffers[1], indices); } void -- cgit v1.2.3 From 9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 17 Apr 2023 22:43:51 +0100 Subject: Separate storing of mesh vertex/index data from configuring VAO --- gfx/models/mesh.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'gfx/models/mesh.cpp') 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 vertices, const std::span indices, GLenum m) : m_numIndices {static_cast(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( - m_vertexArrayBuffers[0], vertices) - .addIndices(m_vertexArrayBuffers[1], indices); + m_vertexArrayBuffers[0]) + .addIndices(m_vertexArrayBuffers[1]); } void -- cgit v1.2.3 From f3343e1cc8a56f039888d4d375a6d5a088a68494 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 19 Apr 2023 01:52:46 +0100 Subject: Export mesh size and primitive type --- gfx/models/mesh.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gfx/models/mesh.cpp') diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index 2c849e7..55759cb 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -21,6 +21,18 @@ Mesh::configureVAO(VertexArrayObject && vao) const .addIndices(m_vertexArrayBuffers[1]); } +GLsizei +Mesh::count() const +{ + return m_numIndices; +} + +GLenum +Mesh::type() const +{ + return mode; +} + void Mesh::Draw() const { -- cgit v1.2.3