PDA

View Full Version : Is there any way to read the rectangle from the texture?



Dark Cheetah
09-26-2006, 12:58 AM
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?

RigidBody
09-26-2006, 01:03 AM
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.

Dark Cheetah
09-26-2006, 06:41 AM
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

macarter
09-26-2006, 07:38 AM
You could render a section of texture with the proper scaling and filter settings and read it back with glReadPixels.

Brolingstanz
09-26-2006, 08:05 AM
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 textureAre you sure about that?

Dark Cheetah
09-26-2006, 08:15 AM
Originally posted by Leghorn:
Are you sure about that? if you know the function could you please name it?

Korval
09-26-2006, 09:52 AM
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.

V-man
09-26-2006, 07:35 PM
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/

Dark Cheetah
09-27-2006, 02:10 AM
thanks everyone for your tips :) 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 :)