YoggieEngine/MyGraphicsEngine/Buffer.cpp

47 lines
873 B
C++

#include "include/MyGraphicsEngine/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);
}