2021-11-27 19:16:41 +00:00
|
|
|
#pragma once
|
2021-11-25 21:15:24 +00:00
|
|
|
|
|
|
|
#include <gl/glew.h>
|
|
|
|
#include <gl/GL.h>
|
|
|
|
|
|
|
|
namespace simpleengine::gfx {
|
|
|
|
class VBO {
|
|
|
|
public:
|
|
|
|
GLuint handle;
|
|
|
|
GLint type;
|
|
|
|
bool dynamic;
|
|
|
|
|
|
|
|
VBO(GLint type, bool dynamic) : type(type), dynamic(dynamic) {
|
|
|
|
glGenBuffers(1, &handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
~VBO() {
|
|
|
|
destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void destroy() {
|
|
|
|
glDeleteBuffers(1, &handle);
|
|
|
|
}
|
|
|
|
|
2021-11-27 18:52:48 +00:00
|
|
|
void bind() const {
|
2021-11-25 21:15:24 +00:00
|
|
|
glBindBuffer(type, handle);
|
|
|
|
}
|
|
|
|
|
2021-11-26 03:28:47 +00:00
|
|
|
void buffer(void *data, size_t offset, size_t size) {
|
2021-11-25 21:15:24 +00:00
|
|
|
bind();
|
2021-11-26 03:28:47 +00:00
|
|
|
glBufferData(type, size - offset, data, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
|
2021-11-25 21:15:24 +00:00
|
|
|
}
|
|
|
|
};
|
2021-11-27 19:16:41 +00:00
|
|
|
}
|