PDA

View Full Version : reading back alpha values...



pixelate
01-31-2005, 11:02 PM
hi...

For some reason i need to use the alpha channel to record the alpha values of fragments that passed the depth test, and subsequently read them back into a buffer. Im trying to use the alpha channel to encode some values, so what i do is the following...

glColor4f(0, 0, 0, x);
glVertex3f(....);

and after all the rendering is finished, i need to readback the alpha values. However, i am not getting the correct alpha values when i read back the frame buffer.

Anybody has any idea on how i should do this?
Thanks=)

Relic
02-01-2005, 12:48 AM
Check if your pixelformat has destination alpha bits.
glGetIntegerv(GL_ALPHA_BITS, &nAlphaBits);
If there are none all alpha readbacks return 1.0.

Correct your pixelformat selection:
With GLUT you must add GLUT_ALPHA, because GL_RGBA is defined as GL_RGB.
With Win32 API check the requested pixleformat structure and check the returned one with DescribePixelFormat. Best is to avoid ChoosePixelFormat alltogether and do your own pixelformat enumeration.
Or use wglChoosePixelFormatARB which is stricter.

Check your
- glClearColor (0,0,0,0)
- glColorMask (1,1,1,1)
- lighting enables (off)
- glBlendFunc settings and enables (off)
- apha test enable (off)

The color buffer is probably only 8 bits per channel, you won't be able to distinguish more than 256 float values.

If that wasn't it, describe what you read back.

pixelate
02-01-2005, 04:21 PM
OH MY GOD. great.... i was tearing my hair out...
JUST BECUZ of that GLUT_RGBA!!! =|

anyway... thanks soooo much! you are really my savior! =D