changing fog color - during runtime

Started by
1 comment, last by bigbrother2000 19 years, 4 months ago
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));
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.
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.

This topic is closed to new replies.

Advertisement