tanspatrent background

Hi there!
I am trying to implement a desktop 3d model viwer, which means I don’t want to show the anything about window, just a 3d model itself.(windows plateform).
I have tried SetLayeredWindowAttributes(), but that function not only make the window transparency but also make everyting draw in the framebuff transparency.
And that method really decreases the FPS.
By the way, there is anther problem confused me.
glClearColor(0,0,0,0);
unsigned char _Tbuf[40000];
unsigned char _Tbuf2[40000];
memset(_Tbuf2,0,40000*sizeof(unsigned char));
glDrawBuffer(GL_BACK);
glDrawPixels(100,100,GL_RGBA,GL_UNSIGNED_BYTE,_Tbuf2);
glReadBuffer(GL_BACK);
glReadPixels(0,0,100,100,GL_RGBA,GL_UNSIGNED_BYTE,_Tbuf);
the _Tbuf alpha channle always be 255, no matter what alpha value I set. Is that means the framebuff alpha channle is always 255?
Thanks.

1, you should set the alpha bits to get alpha value.


PIXELFORMATDESCRIPTOR pfd;
pfd.cAlphaBits = 8;

2, Create a layered window, set the blend function.


BLENDFUNCTION m_blendFunc;
m_blendFunc.BlendOp = AC_SRC_OVER;
m_blendFunc.BlendFlags = 0;
m_blendFunc.AlphaFormat = AC_SRC_ALPHA ;
m_blendFunc.SourceConstantAlpha = 0xFF;

3, Render on main windows, then read pixels and update to the layered windows.


UpdateLayeredWindow(m_hWnd, m_hDC, in_pptDst, in_psize, m_hDCMem, in_pptSrc, 0, &m_blendFunc, ULW_ALPHA);

Really thanks to help!

I do forget to set alpha bits. And now I get the correct result.
But what do you mean creat a layer window? I am really newbie for windows programming. I created a window(does it mean main wondow?)then draw 3d primitives on it and create a child window(layer window?)then read pixels from the main window and draw pixels on the layer window?