Is 0 a valid OpenGL texture ID?

Viewed 10204
glGenTextures(1, &textureid);

Assuming that the texture was created succesfully, could textureid be 0?

4 Answers

From the OpenGL Spec 3.1: on page 157:

If a texture object is deleted, it as if all texture units which are bound to that texture object are rebound to texture object zero.

It seems to me that the zero named texture is a special one

The correct way to do error checking in OpenGL is generally to call glGetError. You can then check for both of the error conditions listed in the description of glGenTextures. As also mentioned, you can call glIsTexture to check if a given texture is valid.

Related