BuffersGL 1.5
glDeleteBuffers
Destroys buffer objects and frees their GPU memory.
Part of the family glDelete*
Signature
void glDeleteBuffers(GLsizei n, const GLuint *buffers);
How it works
Releases the IDs and the storage of n buffers. If a deleted buffer is currently bound, it is unbound (the slot goes back to 0).
In C++ this belongs in a destructor: an RAII wrapper around the buffer ID makes leaks impossible.
Parameters
nGLsizei
Number of buffers to delete.
buffersconst GLuint *
Array of IDs. Zeros and unknown IDs are silently ignored.
Tips & pitfalls
Deleting requires a valid OpenGL context — do it before destroying the window.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GL_INVALID_VALUE
- n is negative.
Example
example.cpp
1glDeleteBuffers(1, &vbo);
2glDeleteBuffers(1, &ebo);