tags:

views:

150

answers:

3

I create my VBO like this:

glGenBuffersARB(1,&polyvbo);

    glBindBufferARB(GL_ARRAY_BUFFER_ARB,polyvbo);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * tempvct.size(),&tempvct[0],GL_DYNAMIC_COPY);

Then to update it I just do the same thing:

    glBindBufferARB(GL_ARRAY_BUFFER_ARB,polyvbo);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB,sizeof(GLfloat) * tempvct.size(),&tempvct[0],GL_DYNAMIC_COPY);

(needless to say, the data in tempvct changes)

I'm just wondering if the above produces a memory leak. do I need to delete the vbo and recreate it, or will it automatically delete the old and update?

Thanks

A: 

I've entered "glBufferDataARB" into Google and found this as the first hit:

http://www.songho.ca/opengl/gl_vbo.html

I suggest you read it. As I understand it, glGenBuffersARB creates the buffer objects and glDeleteBuffersARB destroys them, so the other two functions simply reuse the existing buffer without modifying its allocation.

Secure
+4  A: 

It doesn't cause a memory leak because the buffer is not reallocated.

But why not use glBufferSubData()? it will probably be much faster and does basically the same thing.

shoosh