beginner directx alpha channels

Started by
1 comment, last by bobster 20 years, 8 months ago
Hi, I''m making a simple platformer using Direct3D and textured trianglestrips to display the bitmaps. Unfortunately I just cannot work out how to get the renderer to make the alpha channel define the strip''s opacity. I''m pretty sure its to do with SetTextureStageState method, but every combination of parameters I use doesnt seem to work. This is the texture bit I have currently put into my Render() function: g_pd3dDevice->SetTexture( 0, g_pTexture ); //these four have been messed with they need to be set up correctly g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); I''m pretty sure its soming to do with the last two parameters in the last set of brackets P.S. I can''t seem to be able to put in windows in a post so I can show my code on the forum properly. How do I do this?
Advertisement

I am not sure about this because I haven''t looked at it in a while, but I believe you will need to set some render states to get alpha blending to work correctly.

I think you need:

SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

These names may not be quite right, and some of them may be default settings, but you should be able to look them up in the docs to verify.
k thanks I''ll try that out!

This topic is closed to new replies.

Advertisement