Tal Pressman
Tal Pressman

Reputation: 7317

Is 0 a valid OpenGL texture ID?

glGenTextures(1, &textureid);

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

Upvotes: 42

Views: 11512

Answers (4)

Chris Boyle
Chris Boyle

Reputation: 11551

The manual page for glGenTextures() says see also glIsTexture(); the latter will (according to that) always return GL_FALSE for a texture name of 0. So, 0 can't be a valid texture name.

Upvotes: 39

Eric
Eric

Reputation: 6436

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.

Upvotes: 2

Christoph
Christoph

Reputation: 794

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

Upvotes: 12

Nikolai Ruhe
Nikolai Ruhe

Reputation: 81878

Absolutely not.

Upvotes: 1

Related Questions