12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef MESH_H
- #define MESH_H
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- class Mesh
- {
- public:
- Mesh();
- Mesh(int mode);
- Mesh(const Mesh& orig);
- virtual ~Mesh();
-
- void addPosition(float x, float y, float z);
- void addColor(float r, float g, float b, float a);
- void addTexture(float tx, float ty);
- void addNormal(float nx, float ny, float nz);
-
- void build();
- void draw();
-
- static const int COLOR = 1;
- static const int TEXTURE = 2;
- static const int NORMAL = 4;
- private:
- void ensureCapacity(unsigned int index);
-
- GLuint vba = 0;
- GLuint vbo = 0;
-
- unsigned int positionStartIndex = 0;
- unsigned int colorStartIndex = 0;
- unsigned int textureStartIndex = 0;
- unsigned int normalStartIndex = 0;
-
- unsigned int positionIndex = 0;
- unsigned int colorIndex = 0;
- unsigned int textureIndex = 0;
- unsigned int normalIndex = 0;
-
- unsigned int vertexSize = 0;
- unsigned int vertices = 0;
- unsigned int dataSize = 3;
- float* data = nullptr;
- };
- #endif
|