About Alpha blending sprites in Direct3D9

Posted by ambrozija on Game Development See other posts from Game Development or by ambrozija
Published on 2011-06-24T11:33:25Z Indexed on 2011/06/25 16:31 UTC
Read the original article Hit count: 272

Filed under:

I have a Direct3D9 application that is rendering ID3DXSprites. The problem I am experiencing is best described in this situation:

I have a texture that is totally opaque. On top of it I draw a rectangle filled with solid color and alpha of 128. On top of the rectangle I have a text that is totally opaque. I draw all of this and get the resulting image through GetRenderTarget call. The problem is that on the resulting image, on the area where the transparent rectangle is, I have semi transparent pixels. It is not a problem that the rectangle is transparent, the problem is that the resulting image is.

The question is how to setup the blending so in this situation I don't get the transparent pixels in the resulting image?

I use the sprite with D3DXSPRITE_ALPHABLEND which sets the device state to D3DBLEND_SRCALPHA and D3DBLEND_INVSRCALPHA. I tried couple of combinations of SetRenderState, like D3DBLEND_SRCALPHA, D3DBLEND_DESTALPHA etc., but couldn't make it work.


© Game Development or respective owner

Related posts about c++

Related posts about directx9