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

Some Transparency for my HUD?

This topic is 5624 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

Heya All! I''m looking to do some transparency stuff for my HUD items. How can I "control" the transparency level, for example: //This contains an opacity value between 0.0f and 1.0f FLOAT fOpacity; 0.0f -> 0% Opacity 0.1f -> 100% Opacity //I want to be able to set the Opacity level to any value between 0.0f and 1.0f. How do I get any plane/3D object or whatever to obide by my laws of invisibility (how do I choose how transparent I want them)?... Thanks (in advance) idx to code or not to code, that is the algorithm

Share this post

Link to post
Share on other sites
If you set the renderstates and texture-stage-states appropriately, you can vary the transparency with a value from 0 to 255 (in my code below, m_Alpha contains this value).


// Set alpha-blending flags.

g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
g_pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
g_pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB(m_Alpha, 255,255,255) );

// Render your primitives here.


Share this post

Link to post
Share on other sites