colorkey in Dx8

Started by
10 comments, last by sagmam 21 years, 2 months ago
here is how I draw 2d transparent sprites.

I make a quad with four vertices rendered as a triangle strip with a texture.

the vertex format is D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1

the z-buffer and lighting are disabled.
and this is how i setup the blending.
m_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
m_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

before rendering the textured quad(s).
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
and after
m_pD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
Advertisement
and to setup the texture I either use a .tga with an alpha channel or if its a .jpg or .bmp I set the color key when loading the texture with D3DXCreateTextureFromFileEx()

This topic is closed to new replies.

Advertisement