Delete a texture, keep the name

I would like to be able to delete a texture, but keep the name it was bound to (in essense, put it into the same state it had when the name was first created).

Reading through the MSVC6 documentation, it says specifying an image with a size of 0 on at least one dimension results in a null texture, and indeed when I run the following code:

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_BYTE, 0 );

It comes back with an error code of 0. However I can’t find this behavior mentioned in either the red book or blue book. Is this the correct way to do it?

One option is to just call another glTexImage level 0 with your new image and the same texture handle bound and it will reuse the handle deleting the old and creating the new in one call.

You should know that you can use any names you choose for bound textures, you don’t have to use glGenTextures unless you need compatability with some other 3rd party texture creation software.

The problem arises when you glDeleteTextures and use glGenTextures to get names, you might get a name collision if you reuse the handle in a bind call.

So, if you like just use your own unique integers for each texture and don’t use glGenTextures at all you won’t have a problem.