Changed D3D9 to D3D11 api connection

Changed mesh to D3D11
Changed material to D3D11 (WIP)
This commit is contained in:
2026-11-23 12:31:31 +01:00
parent abb8da9cff
commit 204c55e915
14 changed files with 288 additions and 182 deletions
+22 -32
View File
@@ -32,25 +32,15 @@ int WINAPI WinMain(
error = d3d.init(window.getWindowHandle(), width, height, isFullscreen);
CheckError(error);
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 = {};
error = mesh.init(d3d.getDevice());
CheckError(error);
// 4. create a camera
Camera camera = {};
error = camera.init(d3d.getDevice(), width, height);
CheckError(error);
//// 4. create a camera
//Camera camera = {};
//error = camera.init(d3d.getDevice(), width, height);
//CheckError(error);
// 5. create time
Time time = {};
@@ -62,42 +52,42 @@ int WINAPI WinMain(
error = material.init(d3d.getDevice(), TEXT("wall.jpg"));
CheckError(error);
// 7. create light source
Light light = {};
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 };
//// 7. create light source
//Light light = {};
//
//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);
//error = light.init(lightData);
//CheckError(error);
// 8. run application
while (window.run())
{
// 8.1. update objects
time.update();
//time.update();
mesh.update(time.getDeltaTime());
camera.update(time.getDeltaTime());
light.update(time.getDeltaTime());
//camera.update(time.getDeltaTime());
//light.update(time.getDeltaTime());
// 8.2. render objects
d3d.beginScene();
light.render(d3d.getDevice());
//light.render(d3d.getDevice());
material.render(d3d.getDevice());
mesh.render(d3d.getDevice());
mesh.render(d3d.getDeviceContext());
d3d.endScene();
}
// 9. tidy up
light.deInit();
time.deInit();
camera.deInit();
//light.deInit();
material.deInit();
time.deInit();
//camera.deInit();
mesh.deInit();
d3d.deInit();
window.deInit();