glBindBuffer, glBindTexture w/ name 0 deprecated?

Hi,

I have noticed that glBindBuffer(target, 0) and glBindTexture(target, 0) are nowadays considered deprecated.

This is a bit suprising, and several questions arise.

  1. Assume I render to a texture in a first pass, then bind the texture and draw something with it in the second pass. In the next iteration, the texture will still be bound in the first pass. Is this safe? (Note: in the first pass, no textures are sampled in the shader.)

  2. Same as (1), but with transform feedback and buffer objects.

  3. Textures/buffer objects are automatically unbound when deleting them? Is this defined in the spec now? I can’t find it.

  4. Why is glUseProgram(0) NOT deprecated?

      1. I never heard about this. Where did you find your information ? I might be wrong here but I’m pretty sure you misunderstood something since binding a buffer to 0 is the only way to switch off the use of VBO and such.
  1. Just because there is absolutely no other alternatives to switch back to the fixed pipeline.

NOTE: I am talking about OpenGL 3 forward-compatible profile (as in, nothing deprecated allowed).

gDEBugger complains about using non-generated GL names, referring to the name 0. It claims this is deprecated. It is true that non-generated GL names are not to be used anymore, but name 0 does not seem to have an special meaning anymore?

Also, since this is GL3, switching back to the fixed pipeline makes no sense.

EDIT: the GL 3.3 specification does mention the name 0, and E section E.2.2 states that types which have default objects (including textures and buffer objects) can bind to said default object, which is designated with the name 0. So perhaps gDEBugger has a bug? :slight_smile:

Here are the relevant sections of the 3.0 deprecation model (appendix E in the GL 3.0-4.1 specs):

Application-generated object names - the names of all object types, such as buffer, query, and texture objects, must be generated using the corresponding Gen* commands. Trying to bind an object name not returned by a Gencommand will result in an INVALID_OPERATION error. This behavior is already the case for framebuffer, renderbuffer, and vertex array objects. Object types which have default objects (objects named zero), such as vertex array, framebuffer, and texture objects, may also bind the default object, even though it is not returned by Gen.

Client vertex and index arrays - all vertex array attribute and element array index pointers must refer to buffer objects (section 2.9.6). The default vertex array object (the name zero) is also deprecated. Calling VertexAttribPointer when no buffer object or no vertex array object is bound will generate an INVALID_OPERATION error, as will calling any array drawing command when no vertex array object is bound.

You can unbind framebuffers, renderbuffers, and textures using name 0 from the GL state, and you can unbind vertex buffer objects from a VAO. You just can’t send vertex data without a buffer object, nor bind a buffer object without a VAO.