Microsoft DirectX 8.0 (Visual Basic)

Enabling and Disabling Lights

Once you assign a set of light properties for a light source in a scene, the light source can be activated by calling the Direct3DDevice8.LightEnable method for the device. New light sources are disabled by default. The LightEnable method accepts two parameters. Set the first parameter to the zero-based index of the light source to be affected by the method, and set the second parameter to True to enable the light or False to disable it.

The following code example illustrates the use of this method by enabling the first light source in the device's list of light source properties.

'
' For the purposes of this example, the d3dDevice variable contains
' a valid reference to Direct3DDevice8 object.
'
On Local Error Resume Next

Call d3dDevice.LightEnable(0, True)
If Err.Number <> D3D_OK Then
    'Code to handle the error goes here.
End If

If you enable or disable a light that has no properties that are set with Direct3Ddevice8.SetLight, the LightEnable method creates a light source with the properties listed in following table and enables or disables it.

Member Default
Type D3DLIGHT_DIRECTIONAL
Diffuse (R:1, G:1, B:1, A:0)
Specular (R:0, G:0, B:0, A:0)
Ambient (R:0, G:0, B:0, A:0)
Position (0, 0, 0)
Direction (0, 0, 1)
Range 0
Falloff 0
Attenuation0 0
Attenuation1 0
Attenuation2 0
Theta 0
Phi 0