mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 10:34:16 +00:00
feat(VBO): add vbo config
This commit is contained in:
20
inc/VBO.hpp
Executable file
20
inc/VBO.hpp
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef VBO_HPP
|
||||||
|
#define VBO_HPP
|
||||||
|
|
||||||
|
#include <gl/glew.h>
|
||||||
|
|
||||||
|
class VBO
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
unsigned int id;
|
||||||
|
|
||||||
|
public:
|
||||||
|
VBO(GLfloat* vertices, size_t size);
|
||||||
|
~VBO();
|
||||||
|
|
||||||
|
void bind();
|
||||||
|
void unbind();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
23
src/VBO.cpp
Executable file
23
src/VBO.cpp
Executable file
@@ -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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user