-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVertexArrayObject.h
More file actions
47 lines (33 loc) · 1.06 KB
/
VertexArrayObject.h
File metadata and controls
47 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef VERTEX_ARRAY_OBJECT_H
#define VERTEX_ARRAY_OBJECT_H
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <vector>
class VertexArrayObject {
public:
explicit VertexArrayObject();
virtual ~VertexArrayObject() = default;
void begin(unsigned int drawMode);
void addVertex2f(float x, float y);
void addVertex3f(float x, float y, float z);
void addColor3f(float r, float g, float b);
void addNormal3f(float x, float y, float z);
void addTexCoord2f(float s, float t);
void addIndex1ui(unsigned int i);
void end();
void draw();
protected:
GLuint mDrawMode; // stores the vao drawmode, can be GL_TRIANGLES, GL_POINTS, ...
GLuint mVAO; // VAO ID
GLuint mPositionBufferHandle; // all IDs for the VBOs
GLuint mColorBufferHandle;
GLuint mNormalBufferHandle;
GLuint mTexCoordBufferHandle;
GLuint mIndexBufferHandle;
std::vector<float> mPositions; // the VBO data is stored in dynamic arrays
std::vector<float> mColors;
std::vector<float> mNormals;
std::vector<float> mTexCoords;
std::vector<unsigned int> mIndices;
};
#endif