Browse Source

Fix a memory leak in the vertex array buffer handling.

legacy
Sam Hocevar sam 13 years ago
parent
commit
c5240f20e1
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      src/scene.cpp

+ 11
- 4
src/scene.cpp View File

@@ -61,6 +61,9 @@ private:
int ntiles; int ntiles;
float angle; float angle;


#if LOL_EXPERIMENTAL
GLuint vao;
#endif
GLuint *bufs; GLuint *bufs;
int nbufs; int nbufs;


@@ -82,6 +85,10 @@ Scene::Scene(float angle)


data->bufs = 0; data->bufs = 0;
data->nbufs = 0; data->nbufs = 0;

#if LOL_EXPERIMENTAL
glGenVertexArrays(1, &data->vao);
#endif
} }


Scene::~Scene() Scene::~Scene()
@@ -89,6 +96,9 @@ Scene::~Scene()
/* FIXME: this must be done while the GL context is still active. /* FIXME: this must be done while the GL context is still active.
* Change the architecture to make sure of that. */ * Change the architecture to make sure of that. */
glDeleteBuffers(data->nbufs, data->bufs); glDeleteBuffers(data->nbufs, data->bufs);
#if LOL_EXPERIMENTAL
glDeleteVertexArrays(1, &data->vao);
#endif
free(data->bufs); free(data->bufs);
delete data; delete data;
} }
@@ -200,10 +210,7 @@ void Scene::Render() // XXX: rename to Blit()
} }


#if LOL_EXPERIMENTAL #if LOL_EXPERIMENTAL
GLuint vao;

glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindVertexArray(data->vao);
#else #else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);


Loading…
Cancel
Save