Is there any way to read the rectangle from the texture?

I have large (2048x2048) compressed RGBA texture. i need to read small (24x24) uncompressed rectangle from it. glGetTexImage() function reads the whole texture, uncompresses it and returns me lots of values i don’t really need. does anyone know the way to read only the part of the texture?

i don’t think so. even if you use only a simple compression (like run-length-encoding), you’ll loose the information about which compressed byte belongs to which x-y-coordinate. you cannot tell which byte belongs to the 24x24 rectangle unless you uncompress the whole image.

but i think if we are talking about DXT compression it is possible. so as i understood there is no function which can read me the part of the texture

You could render a section of texture with the proper scaling and filter settings and read it back with glReadPixels.

but i think if we are talking about DXT compression it is possible.
What makes you say that?

so as i understood there is no function which can read me the part of the texture
Are you sure about that?

Originally posted by Leghorn:
Are you sure about that?
if you know the function could you please name it?

Honestly, if you need to have access to the texture data, you shouldn’t have deleted your copy of it from memory. That way, there’s 0 performance cost associated with it.

There is no function to download a section of a texture. If you need to decompress your DXT texture, there is code hanging around. Look at DevIL
http://openil.sourceforge.net/

thanks everyone for your tips :slight_smile: i created the static buffer in memory which changes its data only when i read other texture. so i don’t call glGetTexImage() every time i need to access my compressed texture. i’ve got speedup up to 30 times :slight_smile: