SimpleEngine/include/simpleengine/gfx/vbo.h

34 lines
703 B
C
Raw Normal View History

#pragma once
#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);
}
void bind() const {
glBindBuffer(type, handle);
}
2021-11-26 03:28:47 +00:00
void buffer(void *data, size_t offset, size_t size) {
bind();
2021-11-26 03:28:47 +00:00
glBufferData(type, size - offset, data, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW);
}
};
}