changing fog color - during runtime
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));
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement