Archived

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

chris1234

transparent textures...?

Recommended Posts

hi, How would I make part of an texture in Directx8 partly transparent, use 1 colorkey to become invissible when rendered to the screen so that I will see the textures that lie behind it. now I use the colorkey parameter of the D3DXCreateTextureFromFileExA(); funtion to make purple transparent but it doesn''t seem to work since it just turns the purple into black and I still don''t see the texture that''s behind it...so how would I do such thing? Chris

Share this post


Link to post
Share on other sites
Use alpha testing and alpha blending.
To enable alpha testing, use:
pD3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
To enable alpha blending, use:
pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

You may need to also alter the Source blend and destination blending variables, look up D3DRS_SRCBLEND and D3DRS_DESTBLEND.

Jim Adams

Share this post


Link to post
Share on other sites
you must enable alpha testing, and when you specify the transparent color, make sure the alpha value is maximum, so for example black you would use (in hexidecimal format) FF000000 rather than just 00000000 (unless your bitmap file specifies the alpha values as something else, which isnt usually the case)

Share this post


Link to post
Share on other sites