From 400410fcd436d5e4310bfa779f0309c5fae5b2c2 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 16 Jan 2021 18:09:15 +0000 Subject: Initial commit Stripped back and formatted from https://github.com/BennyQBD/ModernOpenGLTutorial/ --- mesh.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 mesh.h (limited to 'mesh.h') diff --git a/mesh.h b/mesh.h new file mode 100644 index 0000000..aceaafe --- /dev/null +++ b/mesh.h @@ -0,0 +1,68 @@ +#ifndef MESH_INCLUDED_H +#define MESH_INCLUDED_H + +#include "obj_loader.h" +#include +#include +#include +#include + +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; +}; + +enum MeshBufferPositions { POSITION_VB, TEXCOORD_VB, NORMAL_VB, INDEX_VB }; + +class Mesh { +public: + Mesh(const std::string & fileName); + Mesh(Vertex * vertices, unsigned int numVertices, unsigned int * indices, unsigned int numIndices); + + void Draw(); + + virtual ~Mesh(); + +protected: +private: + static const unsigned int NUM_BUFFERS = 4; + void + operator=(const Mesh & mesh) + { + } + Mesh(const Mesh & mesh) { } + + void InitMesh(const IndexedModel & model); + + GLuint m_vertexArrayObject; + GLuint m_vertexArrayBuffers[NUM_BUFFERS]; + unsigned int m_numIndices; +}; + +#endif -- cgit v1.2.3