Question on alpha blending

Started by
1 comment, last by Sante05 17 years, 1 month ago
Hi. I'm trying to draw my polygons blended with the alpha value stored in the frame buffer, the render states I'm using are:
g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_DESTALPHA);
g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO);
g_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
The polygons I'm drawing have alpha=0, and I'm clearing the frame buffer with D3DCOLOR_ARGB(0,0,0,0). My problem is the polygon still shows up in screen. Correct me if I'm wrong, but if the alpha formula was: Final Color = (ObjectColor * SourceBlendFactor) plus (PixelColor * DestinationBlendFactor) My dest blend factor is zero. So the final color only depends on the object color blended with the source blend, which is in fact the dest alpha (the framebuffer), which I cleared to be zero as well. So the object shouldn't be appearing in screen, right? It seems to me as if the framebuffer was not correctly cleared and still had 1.0 as alpha value. If I use D3DBLEND_INVDESTALPHA the object disappears. Any ideas of what I could be doing wrong?
-----DevZing Blog (in Spanish)
Advertisement
I'm guessing your backbuffer is X8R8G8B8 not A8R8G8B8.
Quote:Original post by Namethatnobodyelsetook
I'm guessing your backbuffer is X8R8G8B8 not A8R8G8B8.


Yep, that was it. Really stupid for me using an old initialization code and assuming it was correct. Thanks!
-----DevZing Blog (in Spanish)

This topic is closed to new replies.

Advertisement