Microsoft DirectX 8.0 (C++)

Retrieving Light Properties

You can retrieve all the properties for an existing light source from C++ by calling the IDirect3DDevice8::GetLight method for the device. When calling the GetLight method, pass in the first parameter the zero-based index of the light source for which the properties will be retrieved, and supply the address of a D3DLIGHT8 structure in the second parameter. The device fills the D3DLIGHT8 structure to describe the lighting properties it uses for the light source at that index.

The following code example illustrates this process.

/*
 * For the purposes of this example, the pd3dDevice variable
 * is a valid pointer to an IDirect3DDevice8 interface.
 */
HRESULT hr;
D3DLIGHT8 light;

// Get the property information for the first light.
hr = pd3dDevice->GetLight(0, &light);
if (FAILED(hr))
{
    // Code to handle the error goes here.
}

If you supply an index outside the range of the light sources assigned in the device, the GetLight method fails, returning D3DERR_INVALIDCALL.