# Question on alpha blending

## Recommended Posts

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?

##### Share on other sites
I'm guessing your backbuffer is X8R8G8B8 not A8R8G8B8.

##### Share on other sites
Quote:
 Original post by NamethatnobodyelsetookI'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!

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628378
• Total Posts
2982334

• 10
• 9
• 15
• 24
• 11