45 lines
786 B
C++
Raw Normal View History

//
// Created by FlaXxy on 21.05.2018.
//
#include "./buffer.hpp"
namespace MM::OpenGL {
2022-04-13 01:23:39 +02:00
Buffer::Buffer(const void* data, std::size_t size, GLenum usage, GLenum target) : _size(size), _target(target) {
glGenBuffers(1, &_handle);
2022-04-13 01:23:39 +02:00
glBindBuffer(_target, _handle);
glBufferData(_target, size, data, usage);
}
Buffer::~Buffer(void) {
2022-04-13 01:23:39 +02:00
glDeleteBuffers(1, &_handle);
}
void Buffer::bind(void) const {
glBindBuffer(_target, _handle);
}
void Buffer::bind(GLenum target) const {
glBindBuffer(target, _handle);
}
2022-04-13 01:23:39 +02:00
void Buffer::unbind(void) const {
glBindBuffer(_target, 0);
}
void Buffer::unbind(GLenum target) const {
glBindBuffer(target, 0);
}
std::size_t Buffer::getSize(void) const {
return _size;
}
2022-04-13 01:23:39 +02:00
GLuint Buffer::getHandle(void) const {
return _handle;
}
} // MM::OpenGL