Call glDeleteBuffers glDeleteBuffers API
However, I would not recommend changing the buffer size frequently. Instead, if you need to change the data in the buffer, just select the large buffer, pack it with the necessary data, and note that you can dereference the buffer safely and use only those parts of the buffer.
Constant allocation and deletion of the OpenGL buffer is slow. I would suggest that this is much slower than just adjusting your data, since you must have a circular trip from the GPU to the CPU to give you a new buffer pointer on the GPU, and then you should send the data back to the GPU and THEN , you must send another round-trip call to delete the buffer. So 3 rides!
I mean, every time you allocate arrays in C ++, are you constantly new and delete array every time you fill it or recycle it?
zero298
source share