Transparency in Direct X 8.0

Started by
0 comments, last by Dark Star 20 years, 10 months ago
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
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Advertisement
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);

This topic is closed to new replies.

Advertisement