DirectX SDK

Fog Color

[C++]

Fog color for both pixel and vertex fog is set through the D3DRENDERSTATE_FOGCOLOR render state. The render state values can be any RGB color, specified as an RGBA color (the alpha component is ignored).

The following C++ example sets the fog color to white:

/* For this example, the g_lpD3DDevice variable is
 * a valid pointer to an IDirect3DDevice7 interface.
 */
HRESULT hr;
 
hr = g_lpd3dDevice->SetRenderState(
                    D3DRENDERSTATE_FOGCOLOR,
                    0x00FFFFFF); // Highest 8 bits aren't used.
 
if(FAILED(hr))
    return hr;
[Visual Basic]

Fog color for both pixel and vertex fog is set through the D3DRENDERSTATE_FOGCOLOR render state. The render state values can be any RGB color, as returned by the DirectX7.CreateColorRGB method.

The following Visual Basic example sets the fog color to white:

'
' For this example, the g_d3dDevice variable is
' a valid reference to a Direct3DDevice7 object,
' and g_dx is a valid reference to a DirectX7 object.
'
On Local Error Resume Next

Call g_d3dDevice.SetRenderState( _
                    D3DRENDERSTATE_FOGCOLOR, _
                    g_dx.CreateColorRGB(1#, 1#, 1#))
 
If Err.Number <> DD_OK Then
    ' Code to handle error goes here.
End If