56 lines
1.0 KiB
C++

#ifndef MESH_H
#define MESH_H
#include <glew/glew.h>
#include <vector>
#include <glm/vec3.hpp>
#include <glm/vec2.hpp>
class Mesh
{
protected:
enum {
// required buffers
INDICES_BUFFER, POSITION_BUFFER,
// optionnal buffers :
NORMAL_BUFFER, TEXCOORD_BUFFER, TANGENT_BUFFER,
NB_BUFFERS
};
typedef struct
{
glm::vec3 tangent;
glm::vec3 binormal;
} Tangents;
std::vector<glm::vec3> positions;
std::vector<glm::vec3> normals;
std::vector<glm::vec2> texCoords;
std::vector<Tangents> tangents;
std::vector<unsigned int> indices;
GLuint vao;
GLuint vbo[NB_BUFFERS];
bool locked;
public:
~Mesh();
bool hasNormals();
bool hasTexCoords();
bool hasTangents();
/*
* When the mesh is locked, addFace and addVertex do nothing, but the mesh can be drawn
* initGL locks the mesh
* destroyGL unlocks the mesh
*/
void initGL(bool isDynamic = false);
void destroyGL();
void draw();
bool isLocked(){return locked;}
};
#endif // MESH_H