Archived

This topic is now archived and is closed to further replies.

andy_fish

Reading alpha with glReadPixels

Recommended Posts

Is there any way to read the alpha component of the framebuffer with glReadPixels? When I try, everything I read has an alpha of 1. What I want to do is be able to clear a certain area to have an alpha of 0, then draw to that area, then use glReadPixels to copy that area to a buffer, in such a way so that the pixels that I didn''t draw to still have an alpha of 0. Is this possible? Thanks.

Share this post


Link to post
Share on other sites
Do you have defined an alhpa channel in your pixel format??

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081

Share this post


Link to post
Share on other sites
Yes, but did you set up an alpha channel (and the color channels) in your PIXELFORMATDESCRIPTOR like this:

PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL |
PFD_DOUBLEBUFFER ,
PFD_TYPE_RGBA,
32, //Color Bits
8, // Bits for Red Channel
0, // ignored
8, // Bits for Green Channel
0, // ignored
8, // Bits for Blue Channel
0, // ignored
8, // Bits for Alpha Channel
0, // ignored
0,0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,
};

But be careful! If you use this with Descriptor with 32 Bits and run you application in windowed mode on a 16 Bit Desktop you recieve a software OpenGL context!! If Desktop has 16 Bits you have to design the Descriptor for 16 Bits too (16 Bit Color Bits, 4 Bits for each channel)

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081

Share this post


Link to post
Share on other sites