Microsoft DirectX 8.1 (Visual Basic) |
A material defines the color that is reflected off the surface of a geometric object when a light hits it. The following code fragment uses the D3DMATERIAL8 structure to create a material that is yellow.
Dim mtrl As D3DMATERIAL8 With col: .r = 1: .g = 1: .b = 0: .a = 1: End With mtrl.diffuse = col mtrl.Ambient = col g_D3DDevice.SetMaterial mtrl
The diffuse color and ambient color for the material are set to yellow. The call to the Direct3DDevice8.SetMaterial method applies the material to the Microsoft® Direct3D® device used to render the scene. The only parameter that SetMaterial accepts is the address of the material to set. After this call is made, every primitive will be rendered with this material until another call is made to SetMaterial that specifies a different material.
Now that material has been applied to the scene, the next step is to create a light. This is described in Step 2.2: Creating a Light.