add light

This commit is contained in:
2025-11-19 13:50:33 +01:00
parent 4910894bef
commit 770c3f790b
6 changed files with 49 additions and 13 deletions
+12 -2
View File
@@ -34,7 +34,10 @@ int WINAPI WinMain(
// set render states
d3d.getDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
d3d.getDevice()->SetRenderState(D3DRS_LIGHTING, FALSE);
d3d.getDevice()->SetRenderState(D3DRS_LIGHTING, TRUE);
d3d.getDevice()->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
d3d.getDevice()->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
d3d.getDevice()->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
// 3. create a mesh
Mesh mesh = {};
@@ -58,7 +61,14 @@ int WINAPI WinMain(
// 7. create light source
Light light = {};
error = light.init();
D3DLIGHT9 lightData = {};
lightData.Type = D3DLIGHT_DIRECTIONAL;
lightData.Direction = { 0.0f, 0.0f, 1.0f };
lightData.Diffuse = { 0.5f, 0.5f, 0.5f, 1.0f };
lightData.Specular = { 1.0f, 1.0f, 1.0f, 1.0f };
lightData.Ambient = { 0.2f, 0.2f, 0.2f, 1.0f };
error = light.init(lightData);
CheckError(error);
// 8. run application