Changeset 671


Ignore:
Timestamp:
Feb 20, 2011, 1:02:48 PM (10 years ago)
Author:
sam
Message:

Fix numerous resource leaks in scene.cpp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scene.cpp

    r666 r671  
    9090     * Change the architecture to make sure of that. */
    9191    glDeleteBuffers(data->nbufs, data->bufs);
     92    free(data->bufs);
    9293    delete data;
    9394}
     
    200201
    201202#if LOL_EXPERIMENTAL
    202         GLuint vao, vbo[2], attr;
     203        GLuint vao;
    203204
    204205        glGenVertexArrays(1, &vao);
    205206        glBindVertexArray(vao);
    206         glGenBuffers(2, &vbo[0]);
    207 
    208         glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
    209         glBufferData(GL_ARRAY_BUFFER, 18 * (n - i) * sizeof(GLfloat), vertex, GL_STATIC_DRAW);
     207#else
     208        glEnableClientState(GL_VERTEX_ARRAY);
     209        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     210#endif
     211
     212        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf]);
     213        glBufferData(GL_ARRAY_BUFFER, 18 * (n - i) * sizeof(GLfloat),
     214                     vertex, GL_STATIC_DRAW);
     215#if LOL_EXPERIMENTAL
    210216        glVertexAttribPointer(attr_pos, 3, GL_FLOAT, GL_FALSE, 0, 0);
    211217        glEnableVertexAttribArray(attr_pos);
    212 
    213         glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
    214         glBufferData(GL_ARRAY_BUFFER, 12 * (n - i) * sizeof(GLfloat), texture, GL_STATIC_DRAW);
     218#else
     219        glVertexPointer(3, GL_FLOAT, 0, NULL);
     220#endif
     221
     222        glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf + 1]);
     223        glBufferData(GL_ARRAY_BUFFER, 12 * (n - i) * sizeof(GLfloat),
     224                     texture, GL_STATIC_DRAW);
     225#if LOL_EXPERIMENTAL
    215226        glVertexAttribPointer(attr_tex, 2, GL_FLOAT, GL_FALSE, 0, 0);
    216227        glEnableVertexAttribArray(attr_tex);
    217 
     228#else
     229        glTexCoordPointer(2, GL_FLOAT, 0, NULL);
     230#endif
     231
     232#if LOL_EXPERIMENTAL
    218233        stdshader->Bind();
    219 #else
    220         glEnableClientState(GL_VERTEX_ARRAY);
    221         glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    222 
    223         glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf]);
    224         glBufferData(GL_ARRAY_BUFFER, 6 * 3 * (n - i) * sizeof(float),
    225                      vertex, GL_DYNAMIC_DRAW);
    226         glVertexPointer(3, GL_FLOAT, 0, NULL);
    227 
    228         glBindBuffer(GL_ARRAY_BUFFER, data->bufs[buf + 1]);
    229         glBufferData(GL_ARRAY_BUFFER, 6 * 2 * (n - i) * sizeof(float),
    230                      texture, GL_DYNAMIC_DRAW);
    231         glTexCoordPointer(2, GL_FLOAT, 0, NULL);
    232234#endif
    233235
Note: See TracChangeset for help on using the changeset viewer.