2021-11-27 19:16:41 +00:00
|
|
|
#pragma once
|
2021-11-25 21:15:24 +00:00
|
|
|
|
2021-12-02 21:58:15 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
#include <GL/glew.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#elif
|
2021-11-25 21:15:24 +00:00
|
|
|
#include <gl/glew.h>
|
2021-12-02 21:58:15 +00:00
|
|
|
#include <gl/gl.h>
|
|
|
|
#endif
|
2021-11-25 21:15:24 +00:00
|
|
|
|
|
|
|
namespace simpleengine::gfx {
|
|
|
|
class VBO {
|
|
|
|
public:
|
|
|
|
GLuint handle;
|
|
|
|
GLint type;
|
|
|
|
bool dynamic;
|
|
|
|
|
2021-12-07 19:51:12 +00:00
|
|
|
VBO() = default;
|
|
|
|
|
2021-11-25 21:15:24 +00:00
|
|
|
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
|
|
|
}
|