PDA

View Full Version : can't pick out alpha value in frame buffer



koradji
10-20-2005, 05:49 AM
hi,everyone
i have codes like this:

// set back color
glClearColor(0.0,0.0,0.0,0.0);

glColor4f(0.6,0.6,0.6,0.5);
// draw something
....
....
glFinish();
// now we want to get the pixels in frame buffer
glReadPixels(0,0,win_sizex,win_sizey,GL_RGBA,
GL_UNSIGNED_BYTE,pixel_buf);
....
....

code is finished,but whatever we set the params in glColor4f, the alpha value stored in
the pixel_buf is always 1.0, so how can i properly get the alpha value in the frame buffer?

thanks!!!

def
10-20-2005, 06:39 AM
You need to make certain that your window is supplying an alpha channel. This is done in the Windows pixelformat definition or in GLUT you need to specify GLUT_RGBA and GLUT_ALPHA when you create your window.

jra101
10-20-2005, 07:11 AM
Try doing this:


GLint alpha_bits;
glGetIntegerv(GL_ALPHA_BITS, &alpha_bits);after you create your rendering context to verify that you are getting a pixel format that has alpha.

koradji
10-20-2005, 03:18 PM
yes! just check the pixelformat,
I use glut, so I set GLUT_ALPHA when
glutInitDisplayMode,it runs good.
thanks!