• Advertisement
Sign in to follow this  

changing fog color - during runtime

This topic is 4839 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 all, i'm trying to change the fog during runtime by using a variable fogcolor. If changefogcolor is set to one then the fog should change to black although instead of a gradual gradient in change like the backdrop the fog will remain white and then turn suddenly to black once the value is 255. It is passed the same fogcolor variable that is given to the backdrop so shouldn't the effect be the same? //placed in render function if ((changefogcolor == 1) && (fogcolor < 255)) { fogcolor++; } m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(fogcolor, fogcolor, fogcolor), 1.0f, 0); //Begin the scene m_pD3DDevice->BeginScene(); m_pD3DDevice->SetRenderState(D3DRS_FOGCOLOR, D3DXCOLOR(fogcolor,fogcolor,fogcolor,0));

Share this post


Link to post
Share on other sites
Advertisement
Use this instead:
m_pD3DDevice->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_XRGB(fogcolor,fogcolor,fogcolor));

D3DXCOLOR likes floats, D3DCOLOR likes ints/dwords/whole numbers.

Also, why exactly are you clearing to your fog color? You seem to have used D3DCOLOR in your clear call, so you had it right in one place.

Share this post


Link to post
Share on other sites
thank you ms291052 that worked a treat, i'm only just starting with directX and its quite hard to get through but i'm learning thanks to you and the users on this forum.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement