mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2024-12-04 19:23:28 +01:00
refactor ogl buffer
This commit is contained in:
parent
ab169927fe
commit
69a04cbd7e
@ -6,20 +6,28 @@
|
||||
|
||||
namespace MM::OpenGL {
|
||||
|
||||
Buffer::Buffer(const void* data, std::size_t size, GLenum usage) : _size(size) {
|
||||
Buffer::Buffer(const void* data, std::size_t size, GLenum usage, GLenum target) : _size(size), _target(target) {
|
||||
glGenBuffers(1, &_handle);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _handle);
|
||||
glBufferData(GL_ARRAY_BUFFER, size, data, usage);
|
||||
glBindBuffer(_target, _handle);
|
||||
glBufferData(_target, size, data, usage);
|
||||
}
|
||||
|
||||
Buffer::~Buffer(void) {
|
||||
glDeleteBuffers(1,&_handle);
|
||||
glDeleteBuffers(1, &_handle);
|
||||
}
|
||||
|
||||
void Buffer::bind(void) const {
|
||||
glBindBuffer(_target, _handle);
|
||||
}
|
||||
|
||||
void Buffer::bind(GLenum target) const {
|
||||
glBindBuffer(target, _handle);
|
||||
}
|
||||
|
||||
void Buffer::unbind(void) const {
|
||||
glBindBuffer(_target, 0);
|
||||
}
|
||||
|
||||
void Buffer::unbind(GLenum target) const {
|
||||
glBindBuffer(target, 0);
|
||||
}
|
||||
@ -28,5 +36,9 @@ std::size_t Buffer::getSize(void) const {
|
||||
return _size;
|
||||
}
|
||||
|
||||
GLuint Buffer::getHandle(void) const {
|
||||
return _handle;
|
||||
}
|
||||
|
||||
} // MM::OpenGL
|
||||
|
||||
|
@ -21,15 +21,20 @@ namespace MM::OpenGL {
|
||||
private:
|
||||
GLuint _handle = 0;
|
||||
std::size_t _size = 0;
|
||||
GLenum _target;
|
||||
|
||||
public:
|
||||
Buffer(const void* data, std::size_t size, GLenum usage);
|
||||
Buffer(const void* data, std::size_t size, GLenum usage, GLenum target = GL_ARRAY_BUFFER);
|
||||
~Buffer(void);
|
||||
|
||||
void bind(void) const;
|
||||
void bind(GLenum target) const;
|
||||
void unbind(void) const;
|
||||
void unbind(GLenum target) const;
|
||||
|
||||
std::size_t getSize(void) const;
|
||||
|
||||
GLuint getHandle(void) const;
|
||||
};
|
||||
} // MM::OpenGL
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user