Archived

This topic is now archived and is closed to further replies.

laotzu

transparency (alpha blending?) in dx8

Recommended Posts

I''ve been trying to figure out how to get alpha blending to work, but haven''t been able to get it yet. What I''m trying to do is just make it so that a color is transparent, lets say plain old black. Right now what I''m using (at least I think this is the part that does the transparency)... ... lpdevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); lpdevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); lpdevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); if(d3dcaps.AlphaCmpCaps & D3DPCMPCAPS_GREATER) { lpdevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER); lpdevice->SetRenderState(D3DRS_ALPHAREF, 0x00000000); lpdevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); } ... Thank you to anyone that can help. -laotzu

Share this post


Link to post
Share on other sites
G'day!

You have to get the alpha component in the texture. You didn't say how you're loading the texture, but you should use D3DXCreateTextureFromFileEx because it allows you to set a color key. For the format paramter of that call use D3DFMT_A8R8G8B8 or D3DFMT_A1R5G5B5.


After that this is all you need:
lpdevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
lpdevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
lpdevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

Stay Casual,

Ken
Drunken Hyena

Edited by - DrunkenHyena on March 17, 2001 12:28:32 AM

Share this post


Link to post
Share on other sites