View Full Version : What happens to bindings of a destroyed object?

10-26-2012, 03:32 AM
Let's say I created a texture and its ID is 1. Now I bind this texture to a framebuffer with glFramebufferTexture2D.
Now let's say that at some point in runtime I destroyed this texture and created another one, which also has ID equal to 1.
Question: what happens to the binding I made when called glFramebufferTexture2D? I doubt that now this second texture (which has ID = 1 just like the first texture had) is bound to the framebuffer? Or is the binding in a "wrong state" since the first texture has been destroyed?

Dan Bartlett
10-26-2012, 07:07 AM
Read the chapter "Shared Objects and Multiple Contexts" in the OpenGL spec. In particular, section 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, as described for Delete-
Buffers, DeleteTextures, and DeleteRenderbuffers. If the object binding was
established with other related state (such as a buffer range in BindBufferRange
or selected level and layer information in FramebufferTexture or BindImage-
Texture), that state is not affected by the automatic unbind. Bind points in other
contexts are not affected. 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, as described
in the following section.
and section 5.1.3 Deleted Object and Object Name Lifetimes