In Short:
How to 'render to a per pixel transparent/alpha Bitmap' using OpenGL
In Detail:
I'm writing a program in VC++, using OpenGL (Platform: Windows XP).
The idea is to use OpenGL to render a scene (say, a few triangles) that has semi transparent Vertex Colors (for eg: r,g,b,a= 0,1,1,0.5) to a 32Bit Bitmap, With Alpha Channel.
Then, display that perpixel-alpha-blended bitmap on screen using a Layered window.
Displaying an Alpha-channel bitmap as a layered window works fine.
But the problem is, the bitmap that is rendered doesn't has an alpha channel(meaning, all the alpha values are Zero).
I tried searching a lot around the internet, only to find 'colorkeyed' rendering of OpenGL-based transparent windows; what I would like to do is to display a 'per-pixel-alpha' based window, rendered using OpenGL.
EDIT:
void EnableOpenGL(HWND hWnd, HDC * hDC, HGLRC * hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int format;
ZeroMemory( &pfd, sizeof( pfd ) );
pfd.nSize = sizeof( pfd );
pfd.nVersion = 1;
pfd.dwFlags =PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 32;
pfd.cDepthBits = 32;
pfd.iLayerType = PFD_MAIN_PLANE;
format = ChoosePixelFormat( *hDC, &pfd );
SetPixelFormat( *hDC, format, &pfd );
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );
}