2022-06-04 23:44:54 +00:00
|
|
|
#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);
|
2022-05-04 13:27:42 +00:00
|
|
|
}
|