#pragma once #include #ifdef __linux__ #include #include #else #include #include #endif namespace simpleengine::gfx { class VBO { public: GLuint handle; GLint type; bool dynamic; VBO(GLuint handle, GLint type, bool dynamic) : type(type), dynamic(dynamic), handle(handle) { } ~VBO() { // TODO: Anything to do here? } static VBO init(GLint type, bool dynamic) { GLuint handle; glGenBuffers(1, &handle); return VBO(handle, type, dynamic); } void destroy() { glDeleteBuffers(1, &handle); } void bind() const { glBindBuffer(type, handle); } void unbind() const { glBindBuffer(type, 0); } void buffer(void *data, size_t offset, size_t size) { bind(); glBufferData(type, size - offset, data, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); } }; }