Platform SDK: DirectX

Ambient Lighting State

Ambient light is the surrounding light that comes from all directions. For specific information on how Direct3D used ambient light, see Direct Light vs. Ambient Light, and Mathematics of Direct3D Lighting.

[C++]

Your C++ application sets the color of the ambient lighting by invoking the IDirect3DDevice7::SetRenderState method and passing the enumerated value D3DRENDERSTATE_AMBIENT as the first parameter. The second parameter is a color in RGBA format. The default is zero.

// This code fragment assumes that lpD3DDevice is a valid pointer to
// an IDirect3DDevice7 interface.
 
// Set the ambient light.
D3DCOLOR d3dclrAmbientLightColor = D3DRGBA(1.0f,1.0f,1.0f,1.0f);
lpD3DDevice->SetRenderState(D3DRENDERSTATE_AMBIENT, 
                            d3dclrAmbientLightColor);
[Visual Basic]

A Visual Basic application sets the color of the ambient lighting by invoking the Direct3DDevice7.SetRenderState method and passing the enumerated value D3DRENDERSTATE_AMBIENT as the first parameter. The second parameter is a color in RGBA format. The default is zero.

' This code fragment assumes that D3DDevice contains a valid
' reference to a Direct3DDevice7 object, and dx contains a 
' valid reference to a DirectX7 object.
Dim AmbientLightColor As Long

' Set the ambient light.
AmbientLightColor = dx.CreateColorRGBA(1#, 1#, 1#, 1#)
Call D3DDevice.SetRenderState(D3DRENDERSTATE_AMBIENT, _
                              AmbientLightColor)