Hey all I'm having trouble getting the directx lighting to work in my program. Its the spotlight, and I dont see it I cant see any light. If I switch it to point light I see the light immediately so I cant tell whats wrong.
Here is the code for the light:
pos.x = 0.0f;
pos.y = 0.0f;
pos.z = 1.0f;
// Set default rendering states.
g_D3DDevice->SetRenderState(D3DRS_LIGHTI... TRUE);
g_D3DDevice->SetRenderState(D3DRS_AMBIEN...
D3DCOLOR_COLORVALUE(0.3f, 0.3f, 0.3f, 1.0f));
// Setup the light source.
g_light.Type = D3DLIGHT_SPOT;
g_light.Direction = D3DXVECTOR3(-0.0f, -0.0f, 0.0f);
g_light.Diffuse.r = 1.0f;
g_light.Diffuse.g = 1.0f;
g_light.Diffuse.b = 1.0f;
g_light.Diffuse.a = 1.0f;
// g_light.Specular.r = g_light.Specular.g = 1;
//g_light.Specular.b = g_light.Specular.a = 1;
g_light.Position = pos;
g_light.Range = 1.0f;
g_light.Theta = 0.0f;
g_light.Phi = 0.0f;
g_light.Falloff = 1.0f;
g_light.Attenuation0 = 1.0f;
g_light.Attenuation1 = 1.0f;
g_light.Attenuation2 = 1.0f;
// Register the light.
g_D3DDevice->SetLight(0, &g_light);
g_D3DDevice->LightEnable(0, TRUE);
// Setup the material properties for the teapot.
ZeroMemory(&g_material, sizeof(D3DMATERIAL9));
g_material.Diffuse.r = g_material.Ambient.r = 0.6f;
g_material.Diffuse.g = g_material.Ambient.g = 0.6f;
g_material.Diffuse.b = g_material.Ambient.b = 0.7f;
g_material.Specular.r = 0.4f;
g_material.Specular.g = 0.4f;
g_material.Specular.b = 0.4f;
g_material.Power = 8.0f;
Tags: