PDA

View Full Version : texture mip unload



stevenjb
10-29-2004, 02:52 PM
I am writing a texture manager for a large number of textures. I want to be able to unload a large mip level from a texture. Can I do this reliably without creating a new target? It is not clear from anything I have read how to do this. It seems that the following might work, depending on the driver implementation:

// Disable the highest mip from a texture.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1);
// Presumably GL will keep the data around since TEXTURE_BASE_LEVEL could change later, so...
// Replace mip 0 with a 1x1 image
const U32 nulldata = 0;
glTexImage2D(GL_TEXTURE_2D, 0, iformat, 1, 1, 0, dataformat, GL_UNSIGNED_BYTE, (GLvoid*)nulldata);

Will this work? i.e. will OpenGL reliably free the previous mip when the new texture is specified? If not, is there another way? Is there a better way? I realize that I could create a new target, copy the mip data I want to keep, and delete the origional; I am looking for an easier/faster way that will definately work on ATI, nVidia, PC and Mac.

Many thanks,
-Steven