Add lighting

This commit is contained in:
2026-11-20 12:12:50 +01:00
parent 491367dfa8
commit 7aad3c6292
6 changed files with 60 additions and 15 deletions
+17 -2
View File
@@ -32,7 +32,15 @@ int WINAPI WinMain(
error = d3d.init(window.getWindowHandle(), width, height, isFullscreen);
CheckError(error);
d3d.getDevice()->SetRenderState(D3DRS_LIGHTING, FALSE);
d3d.getDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
d3d.getDevice()->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
d3d.getDevice()->SetRenderState(D3DRS_LIGHTING, TRUE);
d3d.getDevice()->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
d3d.getDevice()->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
d3d.getDevice()->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
d3d.getDevice()->SetRenderState(D3DRS_EMISSIVEMATERIALSOURCE, D3DMCS_MATERIAL);
d3d.getDevice()->SetRenderState(D3DRS_SPECULARENABLE, TRUE);
// 3. create a mesh
Mesh mesh = {};
@@ -56,7 +64,14 @@ int WINAPI WinMain(
// 7. create light source
Light light = {};
error = light.init();
D3DLIGHT9 lightData = {};
lightData.Type = D3DLIGHT_DIRECTIONAL;
lightData.Direction = { -1.0f, -1.0f, 1.0f };
lightData.Diffuse = { 1.0f, 1.0f, 1.0f };
lightData.Specular = { 1.0f, 1.0f, 1.0f };
error = light.init(lightData);
CheckError(error);
// 8. run application