#include "mesh.h" #include "gfx/gl/vertexArrayObject.hpp" #include "glArrays.h" #include "vertex.hpp" #include Mesh::Mesh(const std::span vertices, const std::span indices, GLenum m) : m_numIndices {static_cast(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( m_vertexArrayBuffers[0]) .addIndices(m_vertexArrayBuffers[1]); } GLsizei Mesh::count() const { return m_numIndices; } GLenum Mesh::type() const { return mode; } void Mesh::Draw() const { glBindVertexArray(m_vertexArrayObject); glDrawElements(mode, m_numIndices, GL_UNSIGNED_INT, nullptr); glBindVertexArray(0); }