transparent textures...?

Started by
1 comment, last by chris1234 22 years, 2 months ago
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
Advertisement
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
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)

This topic is closed to new replies.

Advertisement