diff --git a/inc/VBO.hpp b/inc/VBO.hpp new file mode 100755 index 0000000..bfbccb2 --- /dev/null +++ b/inc/VBO.hpp @@ -0,0 +1,20 @@ +#ifndef VBO_HPP +#define VBO_HPP + +#include + +class VBO +{ +private: + unsigned int id; + +public: + VBO(GLfloat* vertices, size_t size); + ~VBO(); + + void bind(); + void unbind(); + +}; + +#endif \ No newline at end of file diff --git a/src/VBO.cpp b/src/VBO.cpp new file mode 100755 index 0000000..f87cfeb --- /dev/null +++ b/src/VBO.cpp @@ -0,0 +1,23 @@ +#include "VBO.hpp" + +VBO::VBO(GLfloat* vertices, size_t size) +{ + glGenBuffers(1, &id); + glBindBuffer(GL_ARRAY_BUFFER, id); + glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW); +} + +VBO::~VBO() +{ + glDeleteBuffers(1, &id); +} + +void VBO::bind() +{ + glBindBuffer(GL_ARRAY_BUFFER, id); +} + +void VBO::unbind() +{ + glBindBuffer(GL_ARRAY_BUFFER, 0); +} \ No newline at end of file