Does it cause a memory leak?

I create my VBO as follows:

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:

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

(of course, the data in tempvct changes)

I'm just wondering if the aforementioned memory leak problem could be. Do I need to remove vbo and recreate it, or will it automatically delete the old one and update it?

thank

+3
source share
3 answers

This does not cause a memory leak because the buffer is not reallocated.

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

+4
source

I entered "glBufferDataARB" on Google and found this as the first hit:

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

. , glGenBuffersARB , glDeleteBuffersARB , .

0

Source: https://habr.com/ru/post/1752378/


All Articles