View Full Version : extract RBG color value from texture
03-30-2001, 06:01 AM
knowing the texture coord (U,V) is it possible to get the RGB value at that point in a texture?
03-30-2001, 06:07 AM
can't you just convert the scalars into pixel locations on the image and read that?
I guess if you no longer have the image in system memory you could use glTexSubImage2D() to sample a 1x1 area of the origional.
03-30-2001, 07:31 AM
>>I guess if you no longer have the image in system memory you could use glTexSubImage2D() to sample a 1x1 area of the origional.
Huh? glTexSubImage2D downloads a texture.
You mean, draw a textured quad with GL_NEAREST filtering and texture coordinates (u,v) to (u,v) (maybe plus 1/2 texel) and check the color onscreen.
glGetTexImage is the correct call to readout a downloaded texture, but I haven't ever seen an app using that. Supposedly slooow.
03-30-2001, 12:14 PM
Converting a UV coordinate into a 2D point is pretty easy (put the UV into the range [0,1] and just multiply by the resolution of the texture).
I would suggest that, if you frequently need access to the texture (either to read or write), don't delete the texture you pass to glTexture2D. Keep it around and, if you change the data, make another call to glTexture2D.
Rather similar to shadowing OpenGL functions.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.