I'm using OpenGL4.5, and using Direct State Access where possible. I wrote basic wrappers around VAO and buffer objects. I'm using glVertexArrayVertexBuffer
to bind a buffer to a VAO. I'm wondering if it is good idea to store the ID/name of the bound buffer in the VAO class. If I call glDeleteBuffers
on the buffer will that buffer and its ID stay alive as long as it is attached to at least one VAO? Will its content be deleted but the name/ID still reserved and stay attached to the VAO?
Upon deletion, the buffer will be unbound from any binding point and detached from any container (VAO is a container object) if it is bound to the current context.
Chapter 5.1 Object Deletion Behavior of the OpenGL specification:
- 5.1.2 Automatic Unbinding of Deleted Objects
When a buffer, texture, or renderbuffer object is deleted, it is unbound from any bind points it is bound to in the current context, and detached from any attachments of container objects that are bound to the current context ... Attachments to unbound container objects, such as deletion of a buffer attached to a vertex array object which is not bound to the context, are not affected and continue to act as references on the deleted object, ...
- 5.1.3 Deleted Object and Object Name Lifetimes
When a buffer, texture, sampler, renderbuffer, query, or sync object is deleted, its name immediately becomes invalid (e.g. is marked unused), but the underlying object will not be deleted until it is no longer in use
Furthermore, i recommend to also read the Chapter 6 Buffer Objects, especially the sections of
DeleteBuffers
After a buffer object is deleted it has no contents, and its name is again unused ... Unused names in buffers that have been marked as used for the purposes of GenBuffers are marked as unused again
and
BindBuffer
If a buffer object is deleted while it is bound, all bindings to that object in the current context (i.e. in the thread that called DeleteBuffers) are reset to zero. Bindings to that buffer in other contexts are not affected, and the deleted buffer may continue to be used at any places it remains bound or attached, as described in section 5.1.