DirectX Help (lighting)

Hi all,

First does anyone know of any good directx forums (or am I not allowed to mention that here)?

But now onto the main problem I'm having.
Using a basic tutorial guide I'm getting to grips with Directx's basic features. But I'm having trouble setting up a seond light. Here's my code at the moment (I'm just showing you what I believe is the relevant function:

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
}


So my question is, even though I've commented out the first light why, oh why(?!?!?!), is the second one NOT showing up? All there is the basic ambient light I've set up as a fallback...

Any ideas? Thanks again.

Mike
@Nexius Those are the ones I'm going through.

One of the little tasks at the end of one of the pages said to add a second lighting source... which is what I'm trying to do.

Am I missing the idea completely? Or is it just a little change I need to get this lighting source working?

Like I say I cannot get the second one to work DESPITE commenting out the first light...

Thanks again, Mike
Nevermind all!

Worked it out. Line 14 and 15 mistakenly called light, when should've been light2.

My Bad Mike
Topic archived. No new replies allowed.