Sign in to follow this  
kooooo

DirectX Transparency not working

Recommended Posts

I wrote a program to display a 'map' made of tiles, and everything works except the tile transparency. Here is an example of one tile that I am loading - a completely transparent tile. The tile is filled with the color r254, g255, b255, which is the color that I specified in the Color Key argument of the function. <code> result = D3DXLoadSurfaceFromFile( tileEmpty, NULL, NULL, TILE_EMPTY, NULL, D3DX_DEFAULT, D3DCOLOR_XRGB(254,255,255), NULL); </code> Now this somewhat works, but instead of becoming transparent, the tile becomes black, and I cannot see the grass tiles that I have underneath it. Do I need to use a different color format or something? Please help!

Share this post


Link to post
Share on other sites
make sure you alpha blending is on and set-up correctly. most common parameters are as follows:

device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);

device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
device->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);

Share this post


Link to post
Share on other sites
It still won't work... I enabled alpha blending, and worked with the
parameters a little bit also. Still all that I get is black... I will
check an example program about sprites and stuff in one of my books.
Pls reply if you think you can help

Share this post


Link to post
Share on other sites
ok... I'm a dumb person. I've been trying to use the wrong thing for
transparency... oh well, that's why im still in the beginners forum. I
think I got it now though.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this