1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
void init_light(void)
{
D3DLIGHT9 light; // this is the struct that holds the light settings
D3DLIGHT9 light2; // the second struct for light
D3DMATERIAL9 material; // create the material struct
ZeroMemory(&light, sizeof(light)); // clear out the struct so we can set what settings we want
light.Type = D3DLIGHT_DIRECTIONAL; // sets the light type to 'directional light'
light.Diffuse = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); // set up the colour of the light
light.Direction = D3DXVECTOR3(-1.0f, -0.3f, -1.0f); // Set up the direciton of the light
ZeroMemory(&light2, sizeof(light2));
light2.Type = D3DLIGHT_DIRECTIONAL; // set up another directional light
light.Diffuse = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f); // set color to white
light.Direction = D3DXVECTOR3(1.0f, 0.0f, -1.0f); // setup the direction of the light
//d3ddev->SetLight(0, &light); // send light properties to light #0
//d3ddev->LightEnable(0, TRUE); // turn on light #0
d3ddev->SetLight(1, &light2); // setup up the second lights options
d3ddev->LightEnable(1, TRUE); // turn on light #1
ZeroMemory(&material, sizeof(material)); // clear out the material struct
material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); // set diffuse color to White
material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); // set ambient color to white
d3ddev->SetMaterial(&material); // set the globally-used material to material
}
|