Mesh.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef MESH_H
  2. #define MESH_H
  3. #include <GL/glew.h>
  4. #include <GLFW/glfw3.h>
  5. class Mesh
  6. {
  7. public:
  8. Mesh();
  9. Mesh(int mode);
  10. Mesh(const Mesh& orig);
  11. virtual ~Mesh();
  12. void addPosition(float x, float y, float z);
  13. void addColor(float r, float g, float b, float a);
  14. void addTexture(float tx, float ty);
  15. void addNormal(float nx, float ny, float nz);
  16. void build();
  17. void draw();
  18. static const int COLOR = 1;
  19. static const int TEXTURE = 2;
  20. static const int NORMAL = 4;
  21. private:
  22. void ensureCapacity(unsigned int index);
  23. GLuint vba = 0;
  24. GLuint vbo = 0;
  25. unsigned int positionStartIndex = 0;
  26. unsigned int colorStartIndex = 0;
  27. unsigned int textureStartIndex = 0;
  28. unsigned int normalStartIndex = 0;
  29. unsigned int positionIndex = 0;
  30. unsigned int colorIndex = 0;
  31. unsigned int textureIndex = 0;
  32. unsigned int normalIndex = 0;
  33. unsigned int vertexSize = 0;
  34. unsigned int vertices = 0;
  35. unsigned int dataSize = 3;
  36. float* data = nullptr;
  37. };
  38. #endif