View Full Version : glCopyTexImage2D

07-29-2002, 07:01 PM
I want to be able to copy from the framebuffer the alpha buffer.
I do this:
glBindTexture(GL_TEXTURE_2D, tex);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);
but does not work.
I verify this using blending with GL_DST_ALPHA function.
The alpha is allways 1.
Please tell me what is happening and what to do about it.

07-30-2002, 01:40 AM
You probably don't have an alpha channel in the frame buffer. Call glGetInteger with GL_ALPHA_BITS to see how many alpha bits you have in the frame buffer.

07-30-2002, 06:13 PM
I've done what you said and the result was 0. Is strange because if I render my viewport with an alpha texture and then if I use alpha blending with GL_DST_ALPHA, and GL_ONE_MINUS_DST_ALPHA I get the expected result - mean transparency.
Pls tell me how should I get alpha bits.

07-30-2002, 09:02 PM
I found the problem, was my pixel format structure. I didn't ask for alpha channel (was 0 before).
Hope someone find this useful.
sizeof(PIXELFORMATDESCRIPTOR), // Size of this structure
1, // Version of this structure
PFD_DRAW_TO_WINDOW | // Draw to a window (not bitmap)
PFD_SUPPORT_OPENGL | // Support OpenGL in window
PFD_DOUBLEBUFFER, // Double-buffered mode
PFD_TYPE_RGBA, // RGBA color mode
24, // RGB = 24 bits
0,0, // # of bits and shift for Red channel.
0,0, // # of bits and shift for Green channel.
0,0, // # of bits and shift for Blue channel.
8,0, // # of bits and shift for Alpha channel.
0, // No use of accumulation buffer
0,0,0,0, // # of Red, Green, Blue and Alpha bits in the accumulation buffer.
32, // Size of depth buffer
0, // No stancil buffer
0, // No auxiliary buffer
PFD_MAIN_PLANE, // Draw in main plane // seems that this is ignored
0, // Reserved
0, // Ignored only in earlier implementations of OpenGL
0, // Used only in index mode
0 }; // Ignored only in earlier implementations of OpenGL