YoggieEngine/BarinkEngine/graphics/Buffer.cpp

47 lines
875 B
C++

#include "Graphics/Buffer.h"
int GpuBuffer::getBufferID() {
return id;
}
void GpuBuffer::createBuffer() {
glGenBuffers(1, (GLuint*) &id);
}
void GpuBuffer::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 GpuBuffer::Bind(bool elementBuffer = false ) {
if (elementBuffer) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
}
else {
glBindBuffer(GL_ARRAY_BUFFER, id);
}
}
void GpuBuffer::Unbind(bool elementBuffer = false) {
if (elementBuffer) {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
else {
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
}
void GpuBuffer::Delete() {
glDeleteBuffers(1, (GLuint*) &id);
}