diff --git a/include/object.hpp b/include/object.hpp index 817878a..8b83697 100644 --- a/include/object.hpp +++ b/include/object.hpp @@ -35,7 +35,7 @@ namespace oglu inline void RegisterVertexAttribPointer(GLuint index, const VertexAttribute& topology); - GLuint VAO; + GLuint VAO, VBO, EBO; GLsizei count; }; diff --git a/src/object.cpp b/src/object.cpp index 90f68bf..eaf9d89 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -3,14 +3,17 @@ namespace oglu { AbstractObject::AbstractObject(const AbstractObject& other) : - VAO(other.VAO), count(other.count) + VAO(other.VAO), VBO(other.VBO), EBO(other.EBO), count(other.count) { } AbstractObject::~AbstractObject() { + glBindVertexArray(0); glDeleteVertexArrays(1, &VAO); + glDeleteBuffers(1, &VBO); + glDeleteBuffers(1, &EBO); } Object MakeObject(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize) @@ -22,14 +25,11 @@ namespace oglu AbstractObject::AbstractObject(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize) : - VAO(0), count(0) + VAO(0), VBO(0), EBO(0), count(0) { topologySize /= sizeof(VertexAttribute); - GLuint VBO; glGenBuffers(1, &VBO); - - GLuint EBO; glGenBuffers(1, &EBO); glGenVertexArrays(1, &VAO);