Archived

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

Transparency in Direct X 8.0

This topic is 5303 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi Guys and Girls, could anyone tell me how I can blit a surface to another surface so that it automatically ignores the transparent colour such as 0. I am using Direct3D 8.0. I have read Ernest Pazera''s book and He says that CopyRects does not support transparency but does not go on to say how to do so. Would I have to write my own Blitter function to remove the unwanted colour or is there a blit function similar to that of DirectDraw''s. Thanks for the help DarkStar UK

Share this post


Link to post
Share on other sites
D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

D3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
D3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
D3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
D3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP,D3DTOP_MODULATE);
D3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
D3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_DIFFUSE);

IDirect3DTexture8 *Texture;
D3DXCreateTextureFromFileEx( D3DDevice, "IMAGEFILE.BMP", D3DX_DEFAULT,D3DX_DEFAULT,0,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,ColorKey,NULL,NULL,&Texture);

To make black transparent change ColorKey to D3DCOLOR_XRGB(0,0,0);

Share this post


Link to post
Share on other sites