From 20646758939562c0fbad4d52774efcfacf7e22fc Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 22 Dec 2021 14:10:34 +0000 Subject: RAII for glVertex and glBuffer --- gfx/models/mesh.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'gfx/models/mesh.h') diff --git a/gfx/models/mesh.h b/gfx/models/mesh.h index c9f1204..4e6cec8 100644 --- a/gfx/models/mesh.h +++ b/gfx/models/mesh.h @@ -2,30 +2,22 @@ #define MESH_INCLUDED_H #include -#include +#include +#include #include #include -#include class Vertex; -enum MeshBufferPositions { POSITION_VB, TEXCOORD_VB, NORMAL_VB, INDEX_VB }; - class Mesh { public: Mesh(const std::span vertices, const std::span indices, GLenum = GL_TRIANGLES); - virtual ~Mesh(); - - NO_COPY(Mesh); - NO_MOVE(Mesh); void Draw() const; private: - static constexpr unsigned int NUM_BUFFERS {4}; - - GLuint m_vertexArrayObject; - std::array m_vertexArrayBuffers; + glVertexArray m_vertexArrayObject; + glBuffers<2> m_vertexArrayBuffers; GLsizei m_numIndices; GLenum mode; }; -- cgit v1.2.3