PDA

View Full Version : Texture Compreesion with glTexSubImage2D



tomjscott
07-09-2004, 09:12 AM
I know that I can perform texture compression on the fly when loading an image into the texture by using the following code:

glTexImage2D(GL_TEXTURE_2D, 0, compressedFormat,
mWidth, mHeight, 0,
colorFormat, GL_UNSIGNED_BYTE,
imageData);

However, what if I already have a compressed texture and I want to update it using glTexSubImage2D. Does the sub image get compressed into the already compressed texture object?

I know that your thinking it is a bad idea to compress dynamic textures at runtime. However, here is the reason for all this madness:

1. We must retain backward compatibility with a system that uses images that are not a power of two.
2. These images must be compressed to conserve memory.

Therefore, what I am trying to do is create an empty texture that is the nearest power of two to the source image. Then I want to copy the image into the texture object using glTexSubImage2D. And of course I want it to be compressed.

Thoughts and suggestions?