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 w开发者_运维百科ill it automatically delete the old and update?
Thanks
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.
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.
See this thread: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=267373
精彩评论