Archived

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

davidcoell

newbie directx8 transparency

Recommended Posts

I am new to directx and was wondering how do you make the background of a Primitive transparent. I have saved a bmp file with the black parts that I want transparent but when running the code the black bits are showing and is not transparent. I thought the following code would work? g_pd3ddev->SetRenderState ( D3DRS_ALPHATESTENABLE, TRUE); g_pd3ddev->SetRenderState ( D3DRS_ALPHAFUNC , D3DCMP_GREATEREQUAL ) ; g_pd3ddev->SetRenderState ( D3DRS_ALPHAREF , 1 ) ; any help would be appreciated, thanks

Share this post


Link to post
Share on other sites
I have had the same problem as you with the transparency. One solution you may want to try is to create a texture using the texture tool included in the SDK tools and add an alpha channel to the bitmap. Then save it as a .dds file (direct draw surface). Then, if you render in the proper order the object will be transparent according to the alpha channel. You may want to check your graphics card though because some don''t have much support for alpha channels. The voodoo3 for instance supports a1r5g5b5 mode. So this won''t work on the voodoo3 (it will look kinda weird). But if your card supports a8r8g8b8 mode, it will work just fine. I hope that helps you out a little bit.

P.S. Another way to do this is to use a material with the alpha channel set to the desired level. It can be tricky to get it to work properly though

Share this post


Link to post
Share on other sites
many popular paint programs (paint shop pro, photo shop) allow you to include an alpha channel in your picture. save your pic to a format that supports alpha channel (i suggest .png) and load it with the extended directX functions.

[edited by - OneBitWonder on October 7, 2003 5:38:53 PM]

Share this post


Link to post
Share on other sites
well the code is setup to check for certain modes and an actual code like D3DFMT_A8R8G8B8 isnt specifically specified. I can quite easily change the code to specify the mode above so will do that first and will check out the other things mentioned above, as i''m new to this i''ve got abit of reading up to do also but thanks for all your replys

Share this post


Link to post
Share on other sites