summaryrefslogtreecommitdiff
path: root/gfx/models/mesh.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-29 18:50:02 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-29 18:50:02 +0100
commit4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17 (patch)
tree6f4bd0c999e3b4a11410aed234622e80842261ad /gfx/models/mesh.cpp
parentLookup material details once in the vertex shader (diff)
downloadilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.tar.bz2
ilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.tar.xz
ilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.zip
Dunno how, but some DOS new lines got in here!
Diffstat (limited to 'gfx/models/mesh.cpp')
-rw-r--r--gfx/models/mesh.cpp84
1 files changed, 42 insertions, 42 deletions
diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp
index 52c9275..7c5ddd4 100644
--- a/gfx/models/mesh.cpp
+++ b/gfx/models/mesh.cpp
@@ -1,42 +1,42 @@
-#include "mesh.h"
-#include "gfx/gl/vertexArrayObject.hpp"
-#include "glArrays.h"
-#include "vertex.hpp"
-#include <cstddef>
-
-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::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]);
-}
-
-void
-Mesh::Draw() const
-{
- glBindVertexArray(m_vertexArrayObject);
-
- glDrawElements(mode, m_numIndices, GL_UNSIGNED_INT, nullptr);
-
- glBindVertexArray(0);
-}
-
-void
-Mesh::DrawInstanced(GLuint vao, GLsizei count) const
-{
- glBindVertexArray(vao);
-
- glDrawElementsInstanced(mode, m_numIndices, GL_UNSIGNED_INT, nullptr, count);
-
- glBindVertexArray(0);
-}
+#include "mesh.h"
+#include "gfx/gl/vertexArrayObject.hpp"
+#include "glArrays.h"
+#include "vertex.hpp"
+#include <cstddef>
+
+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::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]);
+}
+
+void
+Mesh::Draw() const
+{
+ glBindVertexArray(m_vertexArrayObject);
+
+ glDrawElements(mode, m_numIndices, GL_UNSIGNED_INT, nullptr);
+
+ glBindVertexArray(0);
+}
+
+void
+Mesh::DrawInstanced(GLuint vao, GLsizei count) const
+{
+ glBindVertexArray(vao);
+
+ glDrawElementsInstanced(mode, m_numIndices, GL_UNSIGNED_INT, nullptr, count);
+
+ glBindVertexArray(0);
+}