PDA

View Full Version : Freeing bufferobject memory the right way?



Osbios
07-23-2013, 04:34 PM
I have a C++ wraper class and now have a simple question building it.

If I wont need the contend of a bufferobject anymore e.g. like a VertexBufferObject, rendertbuffers or texture. Shall I just use glDeleteBuffers to throw away the ID and later make a new one. Or shall I use glBufferData with a size of 0?

mhagain
07-23-2013, 05:23 PM
glDeleteBuffers is the official way.

Either way may or may not actually release the memory used by the old buffer, and if it does, it may or may not release it immediately. OpenGL doesn't specify when (or even if) memory is released, just that the object name is available for reuse. It's OK for the driver to not release memory but instead keep it available and use it to satisfy a future request (rather than having to make a new allocation).