-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathVertexArrayObject.cpp
More file actions
40 lines (34 loc) · 1.01 KB
/
VertexArrayObject.cpp
File metadata and controls
40 lines (34 loc) · 1.01 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
#include "VertexArrayObject.h"
VertexArrayObject::~VertexArrayObject() {
for(int i = 0; i < bufferCount; i++) {
delete buffers[i];
}
delete[] buffers;
}
void VertexArrayObject::bufferData(int attribute, float* data, int count, int stepPerVertex) {
if(buffers[attribute] == nullptr) {
buffers[attribute] = new DataList(count);
for(float* i = data; i < data + count; i += stepPerVertex) {
buffers[attribute]->bind(i, stepPerVertex);
}
}
else {
delete buffers[attribute];
buffers[attribute] = nullptr;
bufferData(attribute, data, count, stepPerVertex);
}
}
void VertexArrayObject::bufferIndices(int* indices, int count) {
if(indexBuffer == nullptr) {
indexBuffer = new int[count];
indexCount = count;
for(int i = 0; i < count; i++) {
indexBuffer[i] = indices[i];
}
}
else {
delete[] indexBuffer;
indexBuffer = nullptr;
bufferIndices(indices, count);
}
}