View Full Version : Reading FBO Texture

Hylke Donker
12-26-2006, 12:53 AM
I would like to know what the color of a perticular pixel from a texture is. Obviously this isn't a 'regular' static texure, but a texture from a Frame Buffer Object.
But is there a way to do this, except for using shaders(because they can directly read from textures if i'm correct)? I would like to keep the shaders-way as a last resort.

12-26-2006, 11:04 AM
FBO Textures are the same as regular textures from the OpenGL point of view. You could read the texture image back to the main memory, or just texture a polygon with the texel you want it and read the pixel color back...

Hylke Donker
12-27-2006, 08:57 PM
Ah ok..
So if I want to access 2 or 3 pixels, I need to copy the whole texture back to my main RAM?
In that case, i'm gonna first try to do it with shaders.
Anyway, thanks for your help :-)

12-28-2006, 12:44 AM
If the textures are bound to FBO's, you can always bind the FBO's one at a time and use glReadPixels to read the pixel (=texel) values from there. That way you won't need to copy the whole texture image back to the client memory.


Hylke Donker
12-28-2006, 08:48 AM
Wow, thanks for your reply. :-)
That's just what I needed.

12-28-2006, 10:24 AM
Is glReadPixels still slow when using it with FBOs? Wouldn't using glGetTexImage be faster than a glReadPixels call?

12-28-2006, 12:08 PM
I always thought that GetTexImage was slower then ReadPixels... Still, if you read just one pixel it should be fast enough...