Jump to content
  • Advertisement
Sign in to follow this  

Lights not working ? :S

This topic is 4229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

goday! my second post on one day.... well just tell me whats wrong whit this code becus it dont work! and i have just ript it from my bok and thats not Either working! and its driving me insane =)
void Light::SpotLight()
	D3DLIGHT9 light;

	light.Type = D3DLIGHT_SPOT;
	D3DXVECTOR3 vDir (0.0f, 0.0f,0.0f);
	D3DXVec3Normalize((D3DXVECTOR3*)&light.Direction, &vDir);
	light.Position = D3DXVECTOR3 ( 5.0f,5.0f,-5.0f);
	light.Diffuse.b = 255.0f;
	light.Diffuse.g = 255.0f;
	light.Diffuse.r = 255.0f;
	light.Ambient.b =255.0f;
	light.Ambient.g = 255.0f;
	light.Ambient.r =255.0f;
	light.Range = 7.0f;
	light.Theta =2.0f;

	pd3dDevice->SetLight(0, &light);
	pd3dDevice->LightEnable(0, TRUE);

Share this post

Link to post
Share on other sites
What does "not working" actually mean? Does it crash? Is something not drawing the way you expect? if so, what is it you expect, and what is the output?

Did you actually read the section of the book you took the code from? Know what they were trying to do there?

Share this post

Link to post
Share on other sites
Direction is 0,0,0, which won't work. You need attenuation values. Light colors are usually expressed as 0 to 1, not 255. Ambient in your light, while supported, is just odd.

Also be aware you need a material (D3DMATERIAL9, SetMaterial), and your vertices need normals.

Share this post

Link to post
Share on other sites
well i first created a Point light and that whats im want to work right now! and why i posted a code on a Spotlight is becus i ript it from the book and it dident work!

so in a pointLight, do i need normals and olor values at 0.0f-1.0f, and not a direction to 0.0f,0.0f,0.0f?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!