PDA

View Full Version : retrieve frame buffer color and intensity value



chien
02-12-2007, 01:02 AM
Hi,
I had an application with RGB and gray display modes. I need to get the R,G,B color attribute of all pixels in color dipaly mode , and get the intensity attribute of all pixels in gray scale display mode.
COuld you inform me how to do this in wINDOW xp.

plasmonster
02-12-2007, 02:33 AM
Luminance (Y) = 0.2126 Red + 0.7152 Green + 0.0722 Blue

On older hardware you could call glCopyTexSubImage /glReadPixels to grab the frame buffer, then maybe use texture environment combiners to sum the scaled components.

Better still, if you have modern hardware you could use a fragment shader to perform the calculation directly, perhaps from a texture render target (FBO/Pbuffer) to avoid the glCopyTexSubImage/glReadPixels.

In any case, the calculation is OS neuTRAL :-)