summaryrefslogtreecommitdiff
path: root/mesh.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-17 18:54:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-01-17 18:54:26 +0000
commit43a87590f45aa6e55724d30d0c2d0d34b407a57e (patch)
tree21ce8e8886f8aa58b159419b7d885f57d9a37580 /mesh.h
parentInitial commit (diff)
downloadilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.tar.bz2
ilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.tar.xz
ilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.zip
First cut modernizing and sanitizing
Diffstat (limited to 'mesh.h')
-rw-r--r--mesh.h60
1 files changed, 13 insertions, 47 deletions
diff --git a/mesh.h b/mesh.h
index aceaafe..69f41b9 100644
--- a/mesh.h
+++ b/mesh.h
@@ -1,68 +1,34 @@
#ifndef MESH_INCLUDED_H
#define MESH_INCLUDED_H
-#include "obj_loader.h"
#include <GL/glew.h>
-#include <glm/glm.hpp>
+#include <array>
+#include <cstddef>
#include <string>
-#include <vector>
-struct Vertex {
-public:
- Vertex(const glm::vec3 & pos, const glm::vec2 & texCoord, const glm::vec3 & normal)
- {
- this->pos = pos;
- this->texCoord = texCoord;
- this->normal = normal;
- }
-
- glm::vec3 *
- GetPos()
- {
- return &pos;
- }
- glm::vec2 *
- GetTexCoord()
- {
- return &texCoord;
- }
- glm::vec3 *
- GetNormal()
- {
- return &normal;
- }
-
-private:
- glm::vec3 pos;
- glm::vec2 texCoord;
- glm::vec3 normal;
-};
+class IndexedModel;
+class Vertex;
enum MeshBufferPositions { POSITION_VB, TEXCOORD_VB, NORMAL_VB, INDEX_VB };
class Mesh {
public:
- Mesh(const std::string & fileName);
+ explicit Mesh(const std::string & fileName);
+ explicit Mesh(const IndexedModel & model);
Mesh(Vertex * vertices, unsigned int numVertices, unsigned int * indices, unsigned int numIndices);
-
- void Draw();
+ Mesh(const Mesh &) = delete;
+ void operator=(const Mesh &) = delete;
virtual ~Mesh();
-protected:
-private:
- static const unsigned int NUM_BUFFERS = 4;
- void
- operator=(const Mesh & mesh)
- {
- }
- Mesh(const Mesh & mesh) { }
+ void Draw();
- void InitMesh(const IndexedModel & model);
+private:
+ static constexpr unsigned int NUM_BUFFERS {4};
GLuint m_vertexArrayObject;
- GLuint m_vertexArrayBuffers[NUM_BUFFERS];
- unsigned int m_numIndices;
+ std::array<GLuint, NUM_BUFFERS> m_vertexArrayBuffers;
+ size_t m_numIndices;
};
#endif