PDA

View Full Version : redefining texture, glDeleteTextures required?



arekkusu
01-26-2005, 11:38 AM
Here's (what should be) an easy question:

If I generate one texture ID:
glGenTextures(1, &theid);

and create a texture with it:
glBindTexture(GL_TEXTURE_2D, theid);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA8,
256,
256,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
thetexels);

and then, later, define a differently-sized texture with the same id (and assume the client-side buffer is static):
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA8,
256,
128,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
thetexels);

Is this OK? Is the GL required to free its internal copies of the texel data when redefining the bound id?

Or it it required for the client to use glDeleteTextures to destroy the id, to force the GL to free all of its memory?

I'm asking because I've found a case where GL appears to leak, if glDeleteTextures is not used.

Inquisitor
01-26-2005, 12:44 PM
Should be okay.
glGenTextures and glDeleteTextures are not necessary. They are just helpers to manage your texture identifiers.
Anyway, OpenGL should free the old texture and replace it by your second one without leaking.