Jump to content
  • Advertisement

Archived

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

idx14

Some Transparency for my HUD?

This topic is 5929 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
Advertisement
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->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
g_pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

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.



--Hoozit.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!