Nigel Barink
16b61986a1
* Added Texures to the two sample cubes * Modified mesh structure - mesh now contains indices and vertices - Vertices contain vertices and uv's (later on they will also contain normals) Solution definitely not perfect and needs improvement.
47 lines
857 B
C++
47 lines
857 B
C++
#include "Graphics/Buffer.h"
|
|
|
|
|
|
int Buffer::getBufferID() {
|
|
return id;
|
|
}
|
|
|
|
void Buffer::createBuffer() {
|
|
glGenBuffers(1, (GLuint*) &id);
|
|
}
|
|
|
|
void Buffer::setBufferData(void* data, size_t dataSize, bool elementBuffer = false ) {
|
|
|
|
if (elementBuffer) {
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW);
|
|
|
|
}
|
|
else {
|
|
glBufferData(GL_ARRAY_BUFFER, dataSize, data, GL_STATIC_DRAW);
|
|
}
|
|
|
|
}
|
|
|
|
void Buffer::Bind(bool elementBuffer = false ) {
|
|
if (elementBuffer) {
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
|
|
|
|
}
|
|
else {
|
|
glBindBuffer(GL_ARRAY_BUFFER, id);
|
|
|
|
}
|
|
}
|
|
|
|
void Buffer::Unbind(bool elementBuffer = false) {
|
|
if (elementBuffer) {
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
|
}
|
|
else {
|
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
|
|
}
|
|
}
|
|
|
|
void Buffer::Delete() {
|
|
glDeleteBuffers(1, (GLuint*) &id);
|
|
} |