Reputation: 325
let's say that I have the vbo id stored in an int, and I want to resize that buffer; what would I do?
1st choice: use glbufferdata
function after binding the buffer.
2nd choice:.use gldeletebuffers
then regenerate the buffer and use glbufferdata
function after binding the buffer.
So my question is does glbufferdata
deallocate the buffer by it self or it didn't?
Upvotes: 1
Views: 1151
Reputation: 473397
Is it legal OpenGL to re-allocate the storage of a buffer object with a different size? Yes. Is it a good idea? Well, consider this.
OpenGL has a new(ish) way to allocate storage for a buffer: glBufferStorage
. It allocates "immutable" storage. So called because, once allocated, you cannot re-allocate it.
The people behind OpenGL would not have added this immutable buffer allocation method if they thought that reallocating the storage of a buffer object was a good idea.
Upvotes: 1
Reputation: 213328
Just call glBufferData
. The glDeleteBuffers
/ glGenBuffers
calls are unnecessary.
Think about it this way: glBufferData
creates a new buffer. The glGenBuffers
function creates a new name (integer) for a bufffer.
You don't need to deallocate the buffer yourself… not that OpenGL gives you a way to do that. Your OpenGL implementation will do that for you after it is done using the data in the buffer, as long as you don't hold a reference to it.
Upvotes: 1