diff --git a/.gitignore b/.gitignore index ba80a613..95c75253 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,11 @@ x64/ .git/ .vs/ .vscode/ +bin/ build/ backup/ lib/ +vsxmake2022/ *.cso *.mbo *.inc @@ -19,3 +21,4 @@ lib/ *.lastcodeanalysissucceeded !dxtex.exe *.exe +compile_commands.json \ No newline at end of file diff --git a/ImGui/xmake.lua b/ImGui/xmake.lua new file mode 100644 index 00000000..d01c5578 --- /dev/null +++ b/ImGui/xmake.lua @@ -0,0 +1,12 @@ +target("ImGui") + set_group("ImGui") + set_kind("static") + if is_mode("debug") then + set_targetdir(path.join(os.projectdir(),"bin/Debug/ImGui")) + else + set_targetdir(path.join(os.projectdir(),"bin/Release/ImGui")) + end + add_headerfiles("**.h") + add_files("**.cpp") + add_includedirs("./",{public = true}) +target_end() \ No newline at end of file diff --git a/MarkdownFiles/005.png b/MarkdownFiles/005.png new file mode 100644 index 00000000..efe3e86d Binary files /dev/null and b/MarkdownFiles/005.png differ diff --git a/Project 01-09/01 DirectX11 Initialization/xmake.lua b/Project 01-09/01 DirectX11 Initialization/xmake.lua new file mode 100644 index 00000000..e4aa50cc --- /dev/null +++ b/Project 01-09/01 DirectX11 Initialization/xmake.lua @@ -0,0 +1,9 @@ +targetName = "01_DirectX11_Initialization" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") +target_end() \ No newline at end of file diff --git a/Project 01-09/02 Rendering a Triangle/xmake.lua b/Project 01-09/02 Rendering a Triangle/xmake.lua new file mode 100644 index 00000000..b75a2c26 --- /dev/null +++ b/Project 01-09/02 Rendering a Triangle/xmake.lua @@ -0,0 +1,13 @@ +targetName = "02_Rendering_a_Triangle" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + --shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") +target_end() \ No newline at end of file diff --git a/Project 01-09/03 Rendering a Cube/xmake.lua b/Project 01-09/03 Rendering a Cube/xmake.lua new file mode 100644 index 00000000..68e02190 --- /dev/null +++ b/Project 01-09/03 Rendering a Cube/xmake.lua @@ -0,0 +1,13 @@ +targetName = "03_Rendering_a_Cube" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + --shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") +target_end() \ No newline at end of file diff --git a/Project 01-09/06 Use ImGui/xmake.lua b/Project 01-09/06 Use ImGui/xmake.lua new file mode 100644 index 00000000..fdcd216e --- /dev/null +++ b/Project 01-09/06 Use ImGui/xmake.lua @@ -0,0 +1,14 @@ +targetName = "06_Use_ImGui" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_dx_sdk_options() + add_deps("ImGui") + add_headerfiles("**.h") + add_files("**.cpp") + --shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") +target_end() \ No newline at end of file diff --git a/Project 01-09/07 Lighting/xmake.lua b/Project 01-09/07 Lighting/xmake.lua new file mode 100644 index 00000000..7984ce9a --- /dev/null +++ b/Project 01-09/07 Lighting/xmake.lua @@ -0,0 +1,14 @@ +targetName = "07_Lighting" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_dx_sdk_options() + add_deps("ImGui") + add_headerfiles("**.h") + add_files("**.cpp") + --shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") +target_end() \ No newline at end of file diff --git a/Project 01-09/08 Direct2D and Direct3D Interoperability/xmake.lua b/Project 01-09/08 Direct2D and Direct3D Interoperability/xmake.lua new file mode 100644 index 00000000..90fe333d --- /dev/null +++ b/Project 01-09/08 Direct2D and Direct3D Interoperability/xmake.lua @@ -0,0 +1,13 @@ +targetName = "08_Direct2D_and_Direct3D_Interoperability" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + --shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") +target_end() \ No newline at end of file diff --git a/Project 01-09/09 Texture Mapping/xmake.lua b/Project 01-09/09 Texture Mapping/xmake.lua new file mode 100644 index 00000000..0a636da7 --- /dev/null +++ b/Project 01-09/09 Texture Mapping/xmake.lua @@ -0,0 +1,16 @@ +targetName = "09_Texture_Mapping" +target(targetName) + set_group("Project 01-09") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 01-09/xmake.lua b/Project 01-09/xmake.lua new file mode 100644 index 00000000..e3545e9d --- /dev/null +++ b/Project 01-09/xmake.lua @@ -0,0 +1,12 @@ +if is_mode("debug") then + binDir = path.join(os.projectdir(),"bin/Debug/Project 01-09") +else + binDir = path.join(os.projectdir(),"bin/Release/Project 01-09") +end +includes("01 DirectX11 Initialization") +includes("02 Rendering a Triangle") +includes("03 Rendering a Cube") +includes("06 Use ImGui") +includes("07 Lighting") +includes("08 Direct2D and Direct3D Interoperability") +includes("09 Texture Mapping") \ No newline at end of file diff --git a/Project 10-17/10 Camera/xmake.lua b/Project 10-17/10 Camera/xmake.lua new file mode 100644 index 00000000..4ab7049a --- /dev/null +++ b/Project 10-17/10 Camera/xmake.lua @@ -0,0 +1,20 @@ +targetName = "10_camera" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/11 Blending/xmake.lua b/Project 10-17/11 Blending/xmake.lua new file mode 100644 index 00000000..34c11819 --- /dev/null +++ b/Project 10-17/11 Blending/xmake.lua @@ -0,0 +1,20 @@ +targetName = "11_Blending" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/12 Depth and Stenciling/xmake.lua b/Project 10-17/12 Depth and Stenciling/xmake.lua new file mode 100644 index 00000000..ca39f875 --- /dev/null +++ b/Project 10-17/12 Depth and Stenciling/xmake.lua @@ -0,0 +1,20 @@ +targetName = "12_Depth_and_Stenciling" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/13 Living Without FX11/imgui.ini b/Project 10-17/13 Living Without FX11/imgui.ini index ee31560e..9f625681 100644 --- a/Project 10-17/13 Living Without FX11/imgui.ini +++ b/Project 10-17/13 Living Without FX11/imgui.ini @@ -8,3 +8,8 @@ Pos=18,14 Size=332,165 Collapsed=0 +[Window][Living without FX11] +Pos=60,60 +Size=332,105 +Collapsed=0 + diff --git a/Project 10-17/13 Living Without FX11/xmake.lua b/Project 10-17/13 Living Without FX11/xmake.lua new file mode 100644 index 00000000..efa38b30 --- /dev/null +++ b/Project 10-17/13 Living Without FX11/xmake.lua @@ -0,0 +1,20 @@ +targetName = "13_Living_Without_FX11" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/14 Depth Test/xmake.lua b/Project 10-17/14 Depth Test/xmake.lua new file mode 100644 index 00000000..4abdf677 --- /dev/null +++ b/Project 10-17/14 Depth Test/xmake.lua @@ -0,0 +1,20 @@ +targetName = "14_Depth_Test" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/15 Geometry Shader Beginning/xmake.lua b/Project 10-17/15 Geometry Shader Beginning/xmake.lua new file mode 100644 index 00000000..4105f9eb --- /dev/null +++ b/Project 10-17/15 Geometry Shader Beginning/xmake.lua @@ -0,0 +1,20 @@ +targetName = "15_Geometry_Shader_Beginning" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/16 Stream Output/xmake.lua b/Project 10-17/16 Stream Output/xmake.lua new file mode 100644 index 00000000..2e022c84 --- /dev/null +++ b/Project 10-17/16 Stream Output/xmake.lua @@ -0,0 +1,20 @@ +targetName = "16_Stream_Output" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/17 Tree Billboard/xmake.lua b/Project 10-17/17 Tree Billboard/xmake.lua new file mode 100644 index 00000000..35334018 --- /dev/null +++ b/Project 10-17/17 Tree Billboard/xmake.lua @@ -0,0 +1,20 @@ +targetName = "17_Tree_Billboard" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_deps("ImGui") + add_rules("imguiini") + add_dx_sdk_options() + add_headerfiles("**.h") + add_files("**.cpp") + add_headerfiles("../Common/**.h") + add_files("../Common/**.cpp") + add_includedirs("../Common") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 10-17/xmake.lua b/Project 10-17/xmake.lua new file mode 100644 index 00000000..62c85745 --- /dev/null +++ b/Project 10-17/xmake.lua @@ -0,0 +1,13 @@ +if is_mode("debug") then + binDir = path.join(os.projectdir(),"bin/Debug/Project 10-17") +else + binDir = path.join(os.projectdir(),"bin/Release/Project 10-17") +end +includes("10 Camera") +includes("11 Blending") +includes("12 Depth and Stenciling") +includes("13 Living Without FX11") +includes("14 Depth Test") +includes("15 Geometry Shader Beginning") +includes("16 Stream Output") +includes("17 Tree Billboard") \ No newline at end of file diff --git a/Project 19-/19 Meshes/xmake.lua b/Project 19-/19 Meshes/xmake.lua new file mode 100644 index 00000000..7769cb0b --- /dev/null +++ b/Project 19-/19 Meshes/xmake.lua @@ -0,0 +1,17 @@ +targetName = "19_Meshes" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/20 Instancing and Frustum Culling/xmake.lua b/Project 19-/20 Instancing and Frustum Culling/xmake.lua new file mode 100644 index 00000000..dfd85849 --- /dev/null +++ b/Project 19-/20 Instancing and Frustum Culling/xmake.lua @@ -0,0 +1,17 @@ +targetName = "20_Instancing_and_Frustum_Culling" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/21 Picking/xmake.lua b/Project 19-/21 Picking/xmake.lua new file mode 100644 index 00000000..2dc8a853 --- /dev/null +++ b/Project 19-/21 Picking/xmake.lua @@ -0,0 +1,17 @@ +targetName = "21_Picking" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/22 Static Cube Mapping/xmake.lua b/Project 19-/22 Static Cube Mapping/xmake.lua new file mode 100644 index 00000000..681587e3 --- /dev/null +++ b/Project 19-/22 Static Cube Mapping/xmake.lua @@ -0,0 +1,17 @@ +targetName = "22_Static_Cube_Mapping" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/23 Dynamic Cube Mapping/xmake.lua b/Project 19-/23 Dynamic Cube Mapping/xmake.lua new file mode 100644 index 00000000..ec6a11fd --- /dev/null +++ b/Project 19-/23 Dynamic Cube Mapping/xmake.lua @@ -0,0 +1,17 @@ +targetName = "23_Dynamic_Cube_Mapping" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/24 Render To Texture/xmake.lua b/Project 19-/24 Render To Texture/xmake.lua new file mode 100644 index 00000000..1d9a9874 --- /dev/null +++ b/Project 19-/24 Render To Texture/xmake.lua @@ -0,0 +1,17 @@ +targetName = "24_Render_To_Texture" +target(targetName) + set_group("Project 10-17") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/25 Normal Mapping/xmake.lua b/Project 19-/25 Normal Mapping/xmake.lua new file mode 100644 index 00000000..84246bb9 --- /dev/null +++ b/Project 19-/25 Normal Mapping/xmake.lua @@ -0,0 +1,17 @@ +targetName = "25_Normal_Mapping" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/26 Compute Shader Beginning/xmake.lua b/Project 19-/26 Compute Shader Beginning/xmake.lua new file mode 100644 index 00000000..ce33a19f --- /dev/null +++ b/Project 19-/26 Compute Shader Beginning/xmake.lua @@ -0,0 +1,17 @@ +targetName = "26_Compute_Shader_Beginning" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/27 Bitonic Sort/xmake.lua b/Project 19-/27 Bitonic Sort/xmake.lua new file mode 100644 index 00000000..2e8a2e61 --- /dev/null +++ b/Project 19-/27 Bitonic Sort/xmake.lua @@ -0,0 +1,17 @@ +targetName = "27_Bitonic_Sort" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/28 Waves/xmake.lua b/Project 19-/28 Waves/xmake.lua new file mode 100644 index 00000000..7a7205d2 --- /dev/null +++ b/Project 19-/28 Waves/xmake.lua @@ -0,0 +1,17 @@ +targetName = "28_Waves" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/29 OIT/xmake.lua b/Project 19-/29 OIT/xmake.lua new file mode 100644 index 00000000..e165120b --- /dev/null +++ b/Project 19-/29 OIT/xmake.lua @@ -0,0 +1,17 @@ +targetName = "29_OIT" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/30 Blur and Sobel/xmake.lua b/Project 19-/30 Blur and Sobel/xmake.lua new file mode 100644 index 00000000..dce3f155 --- /dev/null +++ b/Project 19-/30 Blur and Sobel/xmake.lua @@ -0,0 +1,17 @@ +targetName = "30_Blur_and_Sobel" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/31 Shadow Mapping/xmake.lua b/Project 19-/31 Shadow Mapping/xmake.lua new file mode 100644 index 00000000..d1c71c9f --- /dev/null +++ b/Project 19-/31 Shadow Mapping/xmake.lua @@ -0,0 +1,17 @@ +targetName = "31_Shadow_Mapping" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/32 SSAO/xmake.lua b/Project 19-/32 SSAO/xmake.lua new file mode 100644 index 00000000..6a8752af --- /dev/null +++ b/Project 19-/32 SSAO/xmake.lua @@ -0,0 +1,17 @@ +targetName = "32_SSAO" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/33 Tessellation/xmake.lua b/Project 19-/33 Tessellation/xmake.lua new file mode 100644 index 00000000..2265df62 --- /dev/null +++ b/Project 19-/33 Tessellation/xmake.lua @@ -0,0 +1,18 @@ +targetName = "33_Tessellation" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl") + add_files("Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/34 Displacement Mapping/xmake.lua b/Project 19-/34 Displacement Mapping/xmake.lua new file mode 100644 index 00000000..774a6ddd --- /dev/null +++ b/Project 19-/34 Displacement Mapping/xmake.lua @@ -0,0 +1,17 @@ +targetName = "34_Displacement_Mapping" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/35 Particle System/xmake.lua b/Project 19-/35 Particle System/xmake.lua new file mode 100644 index 00000000..441c9e91 --- /dev/null +++ b/Project 19-/35 Particle System/xmake.lua @@ -0,0 +1,17 @@ +targetName = "35_Particle_System" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/36 Deferred Rendering/xmake.lua b/Project 19-/36 Deferred Rendering/xmake.lua new file mode 100644 index 00000000..2862d89e --- /dev/null +++ b/Project 19-/36 Deferred Rendering/xmake.lua @@ -0,0 +1,17 @@ +targetName = "36_Deferred_Rendering" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/37 Tile-Based Deferred Rendering/xmake.lua b/Project 19-/37 Tile-Based Deferred Rendering/xmake.lua new file mode 100644 index 00000000..9beb0dc2 --- /dev/null +++ b/Project 19-/37 Tile-Based Deferred Rendering/xmake.lua @@ -0,0 +1,17 @@ +targetName = "37_Tile-Based_Deferred_Rendering" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli|Shaders/**.h") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/38 Cascaded Shadow Mapping/xmake.lua b/Project 19-/38 Cascaded Shadow Mapping/xmake.lua new file mode 100644 index 00000000..3439ef0a --- /dev/null +++ b/Project 19-/38 Cascaded Shadow Mapping/xmake.lua @@ -0,0 +1,17 @@ +targetName = "38_Cascaded_Shadow_Mapping" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/39 VSM and ESM/xmake.lua b/Project 19-/39 VSM and ESM/xmake.lua new file mode 100644 index 00000000..3c103c7b --- /dev/null +++ b/Project 19-/39 VSM and ESM/xmake.lua @@ -0,0 +1,17 @@ +targetName = "39_VSM_and_ESM" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/40 FXAA/xmake.lua b/Project 19-/40 FXAA/xmake.lua new file mode 100644 index 00000000..6a8343b0 --- /dev/null +++ b/Project 19-/40 FXAA/xmake.lua @@ -0,0 +1,17 @@ +targetName = "40_FXAA" +target(targetName) + set_group("Project 19-") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_copy") + add_headerfiles("Shaders/**.hlsl|Shaders/**.hlsli") + add_files("Shaders/**.hlsl|Shaders/**.hlsli") + -- assert + add_rules("asset_file") +target_end() \ No newline at end of file diff --git a/Project 19-/Common/ModelManager.cpp b/Project 19-/Common/ModelManager.cpp index e7ec49aa..3a8ed5a9 100644 --- a/Project 19-/Common/ModelManager.cpp +++ b/Project 19-/Common/ModelManager.cpp @@ -5,7 +5,6 @@ #include - #include #include #include diff --git a/Project 19-/Common/d3dApp.cpp b/Project 19-/Common/d3dApp.cpp index e236eb74..81c1dcb4 100644 --- a/Project 19-/Common/d3dApp.cpp +++ b/Project 19-/Common/d3dApp.cpp @@ -1,26 +1,25 @@ #include "d3dApp.h" -#include "XUtil.h" #include "DXTrace.h" +#include "XUtil.h" #include -#pragma warning(disable: 6031) -extern "C" -{ - // 在具有多显卡的硬件设备中,优先使用NVIDIA或AMD的显卡运行 - // 需要在.exe中使用 - __declspec(dllexport) uint32_t NvOptimusEnablement = 0x00000001; - __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 0x00000001; +#pragma warning(disable : 6031) + +extern "C" { +// 在具有多显卡的硬件设备中,优先使用NVIDIA或AMD的显卡运行 +// 需要在.exe中使用 +__declspec(dllexport) uint32_t NvOptimusEnablement = 0x00000001; +__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 0x00000001; } extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -namespace -{ - // This is just used to forward Windows messages from a global window - // procedure to our member function window procedure because we cannot - // assign a member function to WNDCLASS::lpfnWndProc. - D3DApp* g_pd3dApp = nullptr; +namespace { +// This is just used to forward Windows messages from a global window +// procedure to our member function window procedure because we cannot +// assign a member function to WNDCLASS::lpfnWndProc. +D3DApp* g_pd3dApp = nullptr; } LRESULT CALLBACK @@ -32,15 +31,15 @@ MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } D3DApp::D3DApp(HINSTANCE hInstance, const std::wstring& windowName, int initWidth, int initHeight) - : m_hAppInst(hInstance), - m_MainWndCaption(windowName), - m_ClientWidth(initWidth), - m_ClientHeight(initHeight), - m_hMainWnd(nullptr), - m_AppPaused(false), - m_Minimized(false), - m_Maximized(false), - m_Resizing(false) + : m_hAppInst(hInstance) + , m_MainWndCaption(windowName) + , m_ClientWidth(initWidth) + , m_ClientHeight(initHeight) + , m_hMainWnd(nullptr) + , m_AppPaused(false) + , m_Minimized(false) + , m_Maximized(false) + , m_Resizing(false) { // 让一个全局指针获取这个类,这样我们就可以在Windows消息处理的回调函数 // 让这个类调用内部的回调函数了 @@ -58,17 +57,17 @@ D3DApp::~D3DApp() ImGui::DestroyContext(); } -HINSTANCE D3DApp::AppInst()const +HINSTANCE D3DApp::AppInst() const { return m_hAppInst; } -HWND D3DApp::MainWnd()const +HWND D3DApp::MainWnd() const { return m_hMainWnd; } -float D3DApp::AspectRatio()const +float D3DApp::AspectRatio() const { return static_cast(m_ClientWidth) / m_ClientHeight; } @@ -79,19 +78,14 @@ int D3DApp::Run() m_Timer.Reset(); - while (msg.message != WM_QUIT) - { - if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - { + while (msg.message != WM_QUIT) { + if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); - } - else - { + } else { m_Timer.Tick(); - if (!m_AppPaused) - { + if (!m_AppPaused) { CalculateFrameStats(); ImGui_ImplDX11_NewFrame(); ImGui_ImplWin32_NewFrame(); @@ -99,9 +93,7 @@ int D3DApp::Run() UpdateScene(m_Timer.DeltaTime()); DrawScene(); m_FrameCount++; - } - else - { + } else { Sleep(100); } } @@ -130,9 +122,8 @@ void D3DApp::OnResize() assert(m_pd3dImmediateContext); assert(m_pd3dDevice); assert(m_pSwapChain); - - if (m_pd3dDevice1 != nullptr) - { + + if (m_pd3dDevice1 != nullptr) { assert(m_pd3dImmediateContext1); assert(m_pd3dDevice1); assert(m_pSwapChain1); @@ -141,7 +132,7 @@ void D3DApp::OnResize() // 重设交换链并且重新创建渲染目标视图 for (UINT i = 0; i < m_BackBufferCount; ++i) m_pRenderTargetViews[i].Reset(); - HR(m_pSwapChain->ResizeBuffers(m_BackBufferCount, m_ClientWidth, m_ClientHeight, DXGI_FORMAT_R8G8B8A8_UNORM, + HR(m_pSwapChain->ResizeBuffers(m_BackBufferCount, m_ClientWidth, m_ClientHeight, DXGI_FORMAT_R8G8B8A8_UNORM, m_IsDxgiFlipModel ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0)); m_FrameCount = 0; } @@ -151,74 +142,59 @@ LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (ImGui_ImplWin32_WndProcHandler(m_hMainWnd, msg, wParam, lParam)) return true; - switch (msg) - { - // WM_ACTIVATE is sent when the window is activated or deactivated. - // We pause the game when the window is deactivated and unpause it - // when it becomes active. + switch (msg) { + // WM_ACTIVATE is sent when the window is activated or deactivated. + // We pause the game when the window is deactivated and unpause it + // when it becomes active. case WM_ACTIVATE: - if (LOWORD(wParam) == WA_INACTIVE) - { + if (LOWORD(wParam) == WA_INACTIVE) { m_AppPaused = true; m_Timer.Stop(); - } - else - { + } else { m_AppPaused = false; m_Timer.Start(); } return 0; - // WM_SIZE is sent when the user resizes the window. + // WM_SIZE is sent when the user resizes the window. case WM_SIZE: // Save the new client area dimensions. m_ClientWidth = LOWORD(lParam); m_ClientHeight = HIWORD(lParam); - if (m_pd3dDevice) - { - if (wParam == SIZE_MINIMIZED) - { + if (m_pd3dDevice) { + if (wParam == SIZE_MINIMIZED) { m_AppPaused = true; m_Minimized = true; m_Maximized = false; - } - else if (wParam == SIZE_MAXIMIZED) - { + } else if (wParam == SIZE_MAXIMIZED) { m_AppPaused = false; m_Minimized = false; m_Maximized = true; OnResize(); - } - else if (wParam == SIZE_RESTORED) - { + } else if (wParam == SIZE_RESTORED) { // Restoring from minimized state? - if (m_Minimized) - { + if (m_Minimized) { m_AppPaused = false; m_Minimized = false; OnResize(); } // Restoring from maximized state? - else if (m_Maximized) - { + else if (m_Maximized) { m_AppPaused = false; m_Maximized = false; OnResize(); - } - else if (m_Resizing) - { - // If user is dragging the resize bars, we do not resize - // the buffers here because as the user continuously + } else if (m_Resizing) { + // If user is dragging the resize bars, we do not resize + // the buffers here because as the user continuously // drags the resize bars, a stream of WM_SIZE messages are // sent to the window, and it would be pointless (and slow) // to resize for each WM_SIZE message received from dragging - // the resize bars. So instead, we reset after the user is - // done resizing the window and releases the resize bars, which + // the resize bars. So instead, we reset after the user is + // done resizing the window and releases the resize bars, which // sends a WM_EXITSIZEMOVE message. - } - else // API call such as SetWindowPos or m_pSwapChain->SetFullscreenState. + } else // API call such as SetWindowPos or m_pSwapChain->SetFullscreenState. { OnResize(); } @@ -247,8 +223,8 @@ LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) PostQuitMessage(0); return 0; - // The WM_MENUCHAR message is sent when a menu is active and the user presses - // a key that does not correspond to any mnemonic or accelerator key. + // The WM_MENUCHAR message is sent when a menu is active and the user presses + // a key that does not correspond to any mnemonic or accelerator key. case WM_MENUCHAR: // Don't beep when we alt-enter. return MAKELRESULT(0, MNC_CLOSE); @@ -263,7 +239,6 @@ LRESULT D3DApp::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return DefWindowProc(hwnd, msg, wParam, lParam); } - bool D3DApp::InitMainWindow() { WNDCLASS wc; @@ -278,8 +253,7 @@ bool D3DApp::InitMainWindow() wc.lpszMenuName = 0; wc.lpszClassName = L"D3DWndClassName"; - if (!RegisterClass(&wc)) - { + if (!RegisterClass(&wc)) { MessageBox(0, L"RegisterClass Failed.", 0, 0); return false; } @@ -297,15 +271,14 @@ bool D3DApp::InitMainWindow() m_hMainWnd = CreateWindow(L"D3DWndClassName", m_MainWndCaption.c_str(), WS_OVERLAPPEDWINDOW, (screenWidth - width) / 2, (screenHeight - height) / 2, width, height, 0, 0, m_hAppInst, 0); - if (!m_hMainWnd) - { + if (!m_hMainWnd) { MessageBox(0, L"CreateWindow Failed.", 0, 0); return false; } ShowWindow(m_hMainWnd, SW_SHOW); UpdateWindow(m_hMainWnd); - + return true; } @@ -315,12 +288,11 @@ bool D3DApp::InitDirect3D() // 创建D3D设备 和 D3D设备上下文 UINT createDeviceFlags = 0; -#if defined(DEBUG) || defined(_DEBUG) +#if defined(DEBUG) || defined(_DEBUG) createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; #endif // 驱动类型数组 - D3D_DRIVER_TYPE driverTypes[] = - { + D3D_DRIVER_TYPE driverTypes[] = { D3D_DRIVER_TYPE_HARDWARE, D3D_DRIVER_TYPE_WARP, D3D_DRIVER_TYPE_REFERENCE, @@ -328,8 +300,7 @@ bool D3DApp::InitDirect3D() UINT numDriverTypes = ARRAYSIZE(driverTypes); // 特性等级数组 - D3D_FEATURE_LEVEL featureLevels[] = - { + D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, }; @@ -337,14 +308,12 @@ bool D3DApp::InitDirect3D() D3D_FEATURE_LEVEL featureLevel; D3D_DRIVER_TYPE d3dDriverType; - for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) - { + for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) { d3dDriverType = driverTypes[driverTypeIndex]; hr = D3D11CreateDevice(nullptr, d3dDriverType, nullptr, createDeviceFlags, featureLevels, numFeatureLevels, D3D11_SDK_VERSION, m_pd3dDevice.GetAddressOf(), &featureLevel, m_pd3dImmediateContext.GetAddressOf()); - - if (hr == E_INVALIDARG) - { + + if (hr == E_INVALIDARG) { // Direct3D 11.0 的API不承认D3D_FEATURE_LEVEL_11_1,所以我们需要尝试特性等级11.0以及以下的版本 hr = D3D11CreateDevice(nullptr, d3dDriverType, nullptr, createDeviceFlags, &featureLevels[1], numFeatureLevels - 1, D3D11_SDK_VERSION, m_pd3dDevice.GetAddressOf(), &featureLevel, m_pd3dImmediateContext.GetAddressOf()); @@ -354,15 +323,13 @@ bool D3DApp::InitDirect3D() break; } - if (FAILED(hr)) - { + if (FAILED(hr)) { MessageBox(0, L"D3D11CreateDevice Failed.", 0, 0); return false; } // 检测是否支持特性等级11.0或11.1 - if (featureLevel != D3D_FEATURE_LEVEL_11_0 && featureLevel != D3D_FEATURE_LEVEL_11_1) - { + if (featureLevel != D3D_FEATURE_LEVEL_11_0 && featureLevel != D3D_FEATURE_LEVEL_11_1) { MessageBox(0, L"Direct3D Feature Level 11_0 or 11_1 unsupported.", 0, 0); return false; } @@ -375,20 +342,19 @@ bool D3DApp::InitDirect3D() ComPtr dxgiDevice = nullptr; ComPtr dxgiAdapter = nullptr; - ComPtr dxgiFactory1 = nullptr; // D3D11.0(包含DXGI1.1)的接口类 - ComPtr dxgiFactory2 = nullptr; // D3D11.1(包含DXGI1.2)特有的接口类 - + ComPtr dxgiFactory1 = nullptr; // D3D11.0(包含DXGI1.1)的接口类 + ComPtr dxgiFactory2 = nullptr; // D3D11.1(包含DXGI1.2)特有的接口类 + // 为了正确创建 DXGI交换链,首先我们需要获取创建 D3D设备 的 DXGI工厂,否则会引发报错: // "IDXGIFactory::CreateSwapChain: This function is being called with a device from a different IDXGIFactory." HR(m_pd3dDevice.As(&dxgiDevice)); HR(dxgiDevice->GetAdapter(dxgiAdapter.GetAddressOf())); HR(dxgiAdapter->GetParent(IID_PPV_ARGS(dxgiFactory1.GetAddressOf()))); - + // 查看该对象是否包含IDXGIFactory2接口 hr = dxgiFactory1.As(&dxgiFactory2); // 如果包含,则说明支持D3D11.1 - if (dxgiFactory2 != nullptr) - { + if (dxgiFactory2 != nullptr) { HR(m_pd3dDevice.As(&m_pd3dDevice1)); HR(m_pd3dImmediateContext.As(&m_pd3dImmediateContext1)); // 填充各种结构体用以描述交换链 @@ -401,7 +367,7 @@ bool D3DApp::InitDirect3D() sd.SampleDesc.Quality = 0; sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; #if _WIN32_WINNT >= _WIN32_WINNT_WIN10 - m_BackBufferCount = 2; + m_BackBufferCount = 2; sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; m_IsDxgiFlipModel = true; @@ -411,7 +377,6 @@ bool D3DApp::InitDirect3D() sd.Flags = 0; #endif sd.BufferCount = m_BackBufferCount; - DXGI_SWAP_CHAIN_FULLSCREEN_DESC fd; fd.RefreshRate.Numerator = 60; @@ -422,9 +387,7 @@ bool D3DApp::InitDirect3D() // 为当前窗口创建交换链 HR(dxgiFactory2->CreateSwapChainForHwnd(m_pd3dDevice.Get(), m_hMainWnd, &sd, &fd, nullptr, m_pSwapChain1.GetAddressOf())); HR(m_pSwapChain1.As(&m_pSwapChain)); - } - else - { + } else { // 填充DXGI_SWAP_CHAIN_DESC用以描述交换链 DXGI_SWAP_CHAIN_DESC sd; ZeroMemory(&sd, sizeof(sd)); @@ -446,7 +409,7 @@ bool D3DApp::InitDirect3D() m_BackBufferCount = 1; HR(dxgiFactory1->CreateSwapChain(m_pd3dDevice.Get(), &sd, m_pSwapChain.GetAddressOf())); } - + // 可以禁止alt+enter全屏 dxgiFactory1->MakeWindowAssociation(m_hMainWnd, DXGI_MWA_NO_ALT_ENTER | DXGI_MWA_NO_WINDOW_CHANGES); @@ -468,9 +431,9 @@ bool D3DApp::InitImGui() IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // 允许键盘控制 - io.ConfigFlags |= ImGuiConfigFlags_IsSRGB; // 标记当前使用的是SRGB,目前对ImGui源码有修改 - io.ConfigWindowsMoveFromTitleBarOnly = true; // 仅允许标题拖动 + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // 允许键盘控制 + io.ConfigFlags |= ImGuiConfigFlags_IsSRGB; // 标记当前使用的是SRGB,目前对ImGui源码有修改 + io.ConfigWindowsMoveFromTitleBarOnly = true; // 仅允许标题拖动 // 设置Dear ImGui风格 ImGui::StyleColorsDark(); @@ -480,7 +443,6 @@ bool D3DApp::InitImGui() ImGui_ImplDX11_Init(m_pd3dDevice.Get(), m_pd3dImmediateContext.Get()); return true; - } void D3DApp::CalculateFrameStats() @@ -491,16 +453,15 @@ void D3DApp::CalculateFrameStats() frameCnt++; - if ((m_Timer.TotalTime() - timeElapsed) >= 1.0f) - { + if ((m_Timer.TotalTime() - timeElapsed) >= 1.0f) { float fps = (float)frameCnt; // fps = frameCnt / 1 float mspf = 1000.0f / fps; std::wostringstream outs; outs.precision(6); outs << m_MainWndCaption << L" " - << L"FPS: " << fps << L" " - << L"Frame Time: " << mspf << L" (ms)"; + << L"FPS: " << fps << L" " + << L"Frame Time: " << mspf << L" (ms)"; SetWindowText(m_hMainWnd, outs.str().c_str()); // Reset for next average. @@ -508,5 +469,3 @@ void D3DApp::CalculateFrameStats() timeElapsed += 1.0f; } } - - diff --git a/Project 19-/Common/xmake.lua b/Project 19-/Common/xmake.lua new file mode 100644 index 00000000..912f0d7b --- /dev/null +++ b/Project 19-/Common/xmake.lua @@ -0,0 +1,14 @@ +target("Common") + set_group(GroupName) + set_kind("static") + if is_mode("debug") then + set_targetdir(path.join(os.projectdir(),"bin/Debug/Common")) + else + set_targetdir(path.join(os.projectdir(),"bin/Release/Common")) + end + add_deps("ImGui") + add_packages("assimp") + add_headerfiles("**.h") + add_files("**.cpp") + add_includedirs("./",{public = true}) +target_end() diff --git a/Project 19-/xmake.lua b/Project 19-/xmake.lua new file mode 100644 index 00000000..2c38a9d0 --- /dev/null +++ b/Project 19-/xmake.lua @@ -0,0 +1,28 @@ +if is_mode("debug") then + binDir = path.join(os.projectdir(),"bin/Debug/Project 19-") +else + binDir = path.join(os.projectdir(),"bin/Release/Project 19-") +end +includes("Common") +includes("19 Meshes") +includes("20 Instancing and Frustum Culling") +includes("21 Picking") +includes("22 Static Cube Mapping") +includes("23 Dynamic Cube Mapping") +includes("24 Render To Texture") +includes("25 Normal Mapping") +includes("26 Compute Shader Beginning") +includes("27 Bitonic Sort") +includes("28 Waves") +includes("29 OIT") +includes("30 Blur and Sobel") +includes("31 Shadow Mapping") +includes("32 SSAO") +includes("33 Tessellation") +includes("34 Displacement Mapping") +includes("35 Particle System") +includes("36 Deferred Rendering") +includes("37 Tile-Based Deferred Rendering") +includes("38 Cascaded Shadow Mapping") +includes("39 VSM and ESM") +includes("40 FXAA") \ No newline at end of file diff --git a/Project Archive/Mouse and Keyboard/xmake.lua b/Project Archive/Mouse and Keyboard/xmake.lua new file mode 100644 index 00000000..b983651d --- /dev/null +++ b/Project Archive/Mouse and Keyboard/xmake.lua @@ -0,0 +1,15 @@ +targetName = "Mouse_and_Keyboard" +target(targetName) + set_group("Project Archive") + set_kind("binary") + set_targetdir(path.join(binDir,targetName)) + add_rules("imguiini") + add_dx_sdk_options() + add_deps("Common") + add_headerfiles("**.h") + add_files("**.cpp") + -- shader + add_rules("hlsl_shader_complier") + add_headerfiles("HLSL/**.hlsl|HLSL/**.hlsli") + add_files("HLSL/**.hlsl|HLSL/**.hlsli") +target_end() \ No newline at end of file diff --git a/Project Archive/xmake.lua b/Project Archive/xmake.lua new file mode 100644 index 00000000..4ca261d7 --- /dev/null +++ b/Project Archive/xmake.lua @@ -0,0 +1,6 @@ +if is_mode("debug") then + binDir = path.join(os.projectdir(),"bin/Debug/Archive") +else + binDir = path.join(os.projectdir(),"bin/Release/Archive") +end +includes("Mouse and Keyboard") \ No newline at end of file diff --git a/README.md b/README.md index e30ae742..04d9a441 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,39 @@ > 2. **由于Assimp不支持Win32(x86),本项目仅支持64位系统** > 3. **Win7打开需要安装Service Pack 1以及KB2670838补丁** +## XMake构建项目(可选) + +安装好xmake后,根据如下命令构建与编译项目 + +``` +xmake f -p windows -a x64 -m debug/release +xmake +xmake build [target] +xmake run [target] +``` + +`target`如下: + +![image-20241010203626020](MarkdownFiles/005.png) + +可以使用如下命令生成`compile_commands.json`(推荐) + +``` +xmake project -k compile_commands +``` + +或者使用如下命令生成vs2019/2022项目 + +``` +xmake project -k [vsxmake2019|vsxmake2022] +``` + +项目代码库`assimp`目前使用`xrepo`进行包管理: + +``` +add_requires("assimp",{system = false }) +``` + ## 项目概况 语言:
diff --git a/scripts.lua b/scripts.lua new file mode 100644 index 00000000..9a71852f --- /dev/null +++ b/scripts.lua @@ -0,0 +1,64 @@ +rule("hlsl_shader_complier") + set_extensions(".hlsl",".hlsli") + on_buildcmd_files(function (target,batchcmds,sourcebatch, opt) + import("lib.detect.find_program") + local msvc = target:toolchain("msvc") + local runenvs = msvc:runenvs() + local fxcopt = {} + fxcopt.envs = runenvs + fxcopt.force = true + fxcopt.check = opt.check or function () end + fxc = find_program(opt.program or "fxc", fxcopt) + + for _,sourcefile_hlsl in ipairs(sourcebatch.sourcefiles) do + local ext = path.extension(sourcefile_hlsl) + if ext==".hlsl" then + local hlsl_basename = path.basename(sourcefile_hlsl) + local hlsl_relative_file_name = path.relative(sourcefile_hlsl,target:scriptdir()) + local hlsl_relative_path = path.directory(hlsl_relative_file_name) + local hlsl_output_path = path.join(target:targetdir() ,hlsl_relative_path) + if not os.isdir(hlsl_output_path) then + os.mkdir(hlsl_output_path) + end + local hlsl_output_file_name= path.join(hlsl_output_path,hlsl_basename..".cso") + local hlsl_shader_entrypoint = string.sub(hlsl_basename,-2) + batchcmds:show_progress(opt.progress, "${color.build.object}compiling.hlsl %s", sourcefile_hlsl) + if is_mode("debug") then + batchcmds:vrunv(fxc,{sourcefile_hlsl,"/Zi","/Od","/E",hlsl_shader_entrypoint,"/Fo",hlsl_output_file_name,"/T",string.lower(hlsl_shader_entrypoint).."_5_0","/nologo"}) + else + batchcmds:vrunv(fxc,{sourcefile_hlsl,"/E",hlsl_shader_entrypoint,"/Fo",hlsl_output_file_name,"/T",string.lower(hlsl_shader_entrypoint).."_5_0","/nologo"}) + end + end + end + end) +rule_end() + +rule("hlsl_shader_copy") + set_extensions(".hlsl",".hlsli") + after_build(function (target) + -- shader files + if os.exists(path.join(target:scriptdir(),"/Shaders")) then + os.cp(path.join(target:scriptdir(),"/Shaders"), path.join(target:targetdir(),"/Shaders")) + end + end) +rule_end() + +rule("imguiini") + after_build(function (target) + imguiini_file=path.join(target:scriptdir(),"imgui.ini") + if os.isfile(imguiini_file) then + os.cp(imguiini_file,target:targetdir()) + end + end) +rule_end() + +rule("asset_file") + after_build(function (target) + if os.exists(path.join(target:scriptdir(),"../Texture")) then + os.cp(path.join(target:scriptdir(),"../Texture"), path.join(target:targetdir(),"../Texture")) + end + if os.exists(path.join(target:scriptdir(),"../Model")) then + os.cp(path.join(target:scriptdir(),"../Model"), path.join(target:targetdir(),"../Model")) + end + end) +rule_end() diff --git a/xmake.lua b/xmake.lua new file mode 100644 index 00000000..7d1e3d12 --- /dev/null +++ b/xmake.lua @@ -0,0 +1,37 @@ +set_project("DirectX11 With Windows SDK") +set_xmakever("2.9.0") + +option("WIN7_SYSTEM_SUPPORT") + set_default(false) + set_description("Windows7 users need to select this option!") +option_end() + + +add_rules("mode.debug", "mode.release") +set_defaultmode("debug") +set_toolchains("msvc") +set_languages("c99", "cxx17") +set_encodings("utf-8") + +if is_os("windows") then + add_defines("UNICODE") + add_defines("_UNICODE") +end + +function add_dx_sdk_options() + if has_config("WIN7_SYSTEM_SUPPORT") then + add_defines("_WIN32_WINNT=0x601") + end + add_syslinks("d3d11","dxgi","dxguid","D3DCompiler","d2d1","dwrite","winmm","user32","gdi32","ole32") +end + +includes("scripts.lua") +--ImGui +includes("ImGui") +-- Assimp +add_requires("assimp",{system = false }) + +includes("Project 01-09") +includes("Project 10-17") +includes("Project 19-") +includes("Project Archive")