|Microsoft DirectX 9.0|
The Lighting sample show how to use Microsoft?Direct3D?lights when rendering. It shows the difference between the various types of lightsambient, point, directional, and spothow to configure these lights, and how to enable and disable them.
Source: (SDK root)\Samples\C++\Direct3D\Lighting
Executable: (SDK root)\Samples\C++\Direct3D\Bin
The following table lists the keys that are implemented. You can use menu commands for the same controls.
|ENTER||Starts and stops the scene.|
|SPACEBAR||Advances the scene by a small increment.|
|F2||Prompts the user to select a new rendering device or display mode.|
|ALT+ENTER||Toggles between full-screen and windowed modes.|
|UP ARROW, DOWN ARROW||Increase or decrease vertices in walls.|
|ESC||Exits the application.|
Direct3D lights can be used to shade and color objects that are rendered. They modify the color at each vertex of the primitives rendered while the lights are active. Note that the walls and floor of this sample contain many vertices, so the lighting is fairly detailed. If the vertices were only at the corners of the walls and floor, the lighting effects would be much rougher because of the reduced number of vertices. You can modify the m_m and m_n member variables in this program to see how the vertex count affects the lighting of the surfaces.
There are ways to generate lighting effects other than by using Direct3D lights. Techniques like light mapping can create lighting effects that are not limited to being computed only at each vertex. Vertex shaders can generate more unusual, realistic, or customized lighting at each vertex. Pixel shaders can perform lighting computation at each pixel of the polygons being rendered.
This sample uses common Microsoft DirectX?code that consists of programming elements such as helper functions. This code is shared with other samples in the DirectX software development kit (SDK). You can find the sample framework headers and source code in (SDK root)\DXSDK\Samples\C++\Common\Include and (SDK root)\DXSDK\Samples\C++\Common\Src.