mirror of
https://github.com/guezoloic/LearnOpenGL.git
synced 2026-01-25 12:34:15 +00:00
feat(EBO): add EBO config
This commit is contained in:
18
inc/EBO.hpp
Executable file
18
inc/EBO.hpp
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef EBO_HPP
|
||||||
|
#define EBO_HPP
|
||||||
|
|
||||||
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
class EBO
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
GLuint id;
|
||||||
|
|
||||||
|
public:
|
||||||
|
EBO(const unsigned int* indices, size_t size);
|
||||||
|
~EBO();
|
||||||
|
|
||||||
|
void bind();
|
||||||
|
void unbind();
|
||||||
|
};
|
||||||
|
#endif
|
||||||
23
src/EBO.cpp
Executable file
23
src/EBO.cpp
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "EBO.hpp"
|
||||||
|
|
||||||
|
EBO::EBO(const unsigned int* indices, size_t size)
|
||||||
|
{
|
||||||
|
glGenBuffers(1, &id);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
|
||||||
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW);
|
||||||
|
}
|
||||||
|
|
||||||
|
EBO::~EBO()
|
||||||
|
{
|
||||||
|
glDeleteBuffers(1, &id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EBO::bind()
|
||||||
|
{
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EBO::unbind()
|
||||||
|
{
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user