After you've created a light and set its properties, you can add it to a viewport by calling the viewport's IDirect3DViewport3::AddLight method. The AddLight method causes the viewport to add the light to a list of light objects it considers when rendering a scene. When you call AddLight, you specify the IDirect3DLight interface pointer that was returned when you initially created the light object by calling IDirect3D3::CreateLight, as shown in the following code fragment:
/*
* For this example, the g_lpD3DLight variable is a pointer to
* the IDirect3DLight interface of a light object whose
* illumination properties have been set, and the lpViewport3
* variable is a valid IDirect3DViewport3 interface.
*/
HRESULT hr;
hr = lpViewport3->AddLight (g_lpD3DLight);
if (FAILED (hr))
return hr;