Archived

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

beginner directx alpha channels

This topic is 5238 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, 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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

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.

Share this post


Link to post
Share on other sites