├── .clang-format ├── .editorconfig ├── .github └── workflows │ ├── build-website.yml │ └── docs-checker.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── docs ├── 1-introduction │ ├── 1-1-getting-started │ │ ├── 1-1-0-overview.md │ │ ├── 1-1-1-hello-window.md │ │ ├── 1-1-2-hello-d3d11.md │ │ └── 1-1-3-hello-triangle.md │ ├── 1-2-debug │ │ ├── 1-2-0-overview.md │ │ ├── 1-2-1-clear-state.md │ │ ├── 1-2-2-debug-layer.md │ │ ├── 1-2-3-naming-things.md │ │ ├── 1-2-4-renderdoc.md │ │ ├── 1-2-5-laptop-gpus.md │ │ └── media │ │ │ └── 1-2-3-naming-things │ │ │ ├── api-inspector.png │ │ │ ├── application-dirs.png │ │ │ ├── event-browser.png │ │ │ ├── opening-capture.png │ │ │ ├── pipeline-state.gif │ │ │ ├── render-doc-default.png │ │ │ ├── render-doc-overlay.png │ │ │ └── resource-inspector.png │ ├── 1-3-basics │ │ ├── 1-3-0-overview.md │ │ ├── 1-3-1-rasterizer-state.md │ │ ├── 1-3-2-texturing.md │ │ ├── 1-3-3-setting-up-3d-rendering.md │ │ ├── 1-3-4-3d-rendering.md │ │ ├── 1-3-5-models.md │ │ └── 1-3-6-dear-imgui.md │ └── images │ │ ├── 1-1-1-hello-window-1.png │ │ ├── 1-2-3-namingthings-nsight.png │ │ ├── 1-2-3-namingthings-renderdoc.png │ │ ├── 1-3-1-cullmode.png │ │ ├── 1-3-1-fillmode.png │ │ ├── 1-3-2-froge.png │ │ ├── 1-3-2-textureslots.png │ │ ├── 1-3-2-wrapmodes.png │ │ ├── 1-3-3-worldspacetriangle.png │ │ ├── 1-3-4-cube.png │ │ └── 1-3-4-insidecube.png ├── 8-code │ └── repository.md ├── about.md ├── index.md ├── javascripts │ └── mathjax.js └── license.md ├── lib ├── DirectXTex │ ├── include │ │ ├── DirectXTex.h │ │ └── DirectXTex.inl │ └── lib │ │ ├── Debug │ │ └── DirectXTex.lib │ │ └── Release │ │ └── DirectXTex.lib ├── FreeImage │ ├── include │ │ └── FreeImage.h │ └── lib │ │ ├── FreeImageLib.lib │ │ └── FreeImageLibd.lib ├── assimp │ ├── include │ │ └── assimp │ │ │ ├── .editorconfig │ │ │ ├── BaseImporter.h │ │ │ ├── Bitmap.h │ │ │ ├── BlobIOSystem.h │ │ │ ├── ByteSwapper.h │ │ │ ├── Compiler │ │ │ ├── poppack1.h │ │ │ ├── pstdint.h │ │ │ └── pushpack1.h │ │ │ ├── CreateAnimMesh.h │ │ │ ├── DefaultIOStream.h │ │ │ ├── DefaultIOSystem.h │ │ │ ├── DefaultLogger.hpp │ │ │ ├── Defines.h │ │ │ ├── Exceptional.h │ │ │ ├── Exporter.hpp │ │ │ ├── GenericProperty.h │ │ │ ├── Hash.h │ │ │ ├── IOStream.hpp │ │ │ ├── IOStreamBuffer.h │ │ │ ├── IOSystem.hpp │ │ │ ├── Importer.hpp │ │ │ ├── LineSplitter.h │ │ │ ├── LogAux.h │ │ │ ├── LogStream.hpp │ │ │ ├── Logger.hpp │ │ │ ├── Macros.h │ │ │ ├── MathFunctions.h │ │ │ ├── MemoryIOWrapper.h │ │ │ ├── NullLogger.hpp │ │ │ ├── ParsingUtils.h │ │ │ ├── Profiler.h │ │ │ ├── ProgressHandler.hpp │ │ │ ├── RemoveComments.h │ │ │ ├── SGSpatialSort.h │ │ │ ├── SceneCombiner.h │ │ │ ├── SkeletonMeshBuilder.h │ │ │ ├── SmoothingGroups.h │ │ │ ├── SmoothingGroups.inl │ │ │ ├── SpatialSort.h │ │ │ ├── StandardShapes.h │ │ │ ├── StreamReader.h │ │ │ ├── StreamWriter.h │ │ │ ├── StringComparison.h │ │ │ ├── StringUtils.h │ │ │ ├── Subdivision.h │ │ │ ├── TinyFormatter.h │ │ │ ├── Vertex.h │ │ │ ├── XMLTools.h │ │ │ ├── ai_assert.h │ │ │ ├── anim.h │ │ │ ├── camera.h │ │ │ ├── cexport.h │ │ │ ├── cfileio.h │ │ │ ├── cimport.h │ │ │ ├── color4.h │ │ │ ├── color4.inl │ │ │ ├── config.h │ │ │ ├── config.h.in │ │ │ ├── defs.h │ │ │ ├── fast_atof.h │ │ │ ├── importerdesc.h │ │ │ ├── irrXMLWrapper.h │ │ │ ├── light.h │ │ │ ├── material.h │ │ │ ├── material.inl │ │ │ ├── matrix3x3.h │ │ │ ├── matrix3x3.inl │ │ │ ├── matrix4x4.h │ │ │ ├── matrix4x4.inl │ │ │ ├── mesh.h │ │ │ ├── metadata.h │ │ │ ├── pbrmaterial.h │ │ │ ├── port │ │ │ └── AndroidJNI │ │ │ │ └── AndroidJNIIOSystem.h │ │ │ ├── postprocess.h │ │ │ ├── qnan.h │ │ │ ├── quaternion.h │ │ │ ├── quaternion.inl │ │ │ ├── scene.h │ │ │ ├── texture.h │ │ │ ├── types.h │ │ │ ├── vector2.h │ │ │ ├── vector2.inl │ │ │ ├── vector3.h │ │ │ ├── vector3.inl │ │ │ └── version.h │ └── lib │ │ ├── assimp.dll │ │ └── assimp.lib ├── glfw-3.3.6 │ ├── LICENSE.md │ ├── README.md │ ├── include │ │ └── GLFW │ │ │ ├── glfw3.h │ │ │ └── glfw3native.h │ └── lib-vc2022 │ │ ├── glfw3.dll │ │ ├── glfw3.lib │ │ ├── glfw3_mt.lib │ │ └── glfw3dll.lib └── imgui │ └── include │ └── imgui │ ├── backend │ ├── imgui_impl_dx11.cpp │ ├── imgui_impl_dx11.h │ ├── imgui_impl_glfw.cpp │ └── imgui_impl_glfw.h │ ├── imconfig.h │ ├── imgui.cpp │ ├── imgui.h │ ├── imgui_demo.cpp │ ├── imgui_draw.cpp │ ├── imgui_internal.h │ ├── imgui_tables.cpp │ ├── imgui_widgets.cpp │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ └── imstb_truetype.h ├── mkdocs.yml └── src ├── Cpp ├── 1-getting-started │ ├── 1-1-0-Empty │ │ ├── 1-1-0-Empty.vcxproj │ │ ├── 1-1-0-Empty.vcxproj.filters │ │ ├── 1-1-0-Empty.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ └── .gitkeep │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ └── Main.cpp │ ├── 1-1-1-HelloGLFWWindow │ │ ├── 1-1-1-HelloGLFWWindow.vcxproj │ │ ├── 1-1-1-HelloGLFWWindow.vcxproj.filters │ │ ├── 1-1-1-HelloGLFWWindow.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ └── .gitkeep │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ └── Main.cpp │ ├── 1-1-1-HelloWin32Window │ │ ├── 1-1-1-HelloWin32Window.vcxproj │ │ ├── 1-1-1-HelloWin32Window.vcxproj.filters │ │ ├── 1-1-1-HelloWin32Window.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ └── .gitkeep │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ └── Main.cpp │ ├── 1-1-1-HelloWindow │ │ ├── 1-1-1-HelloWindow.vcxproj │ │ ├── 1-1-1-HelloWindow.vcxproj.filters │ │ ├── 1-1-1-HelloWindow.vcxproj.user │ │ ├── Application.cpp │ │ ├── Application.hpp │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ └── .gitkeep │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ ├── HelloWindowApplication.cpp │ │ ├── HelloWindowApplication.hpp │ │ └── Main.cpp │ ├── 1-1-2-HelloD3D11-Raw │ │ ├── 1-1-2-HelloD3D11-Raw.vcxproj │ │ ├── 1-1-2-HelloD3D11-Raw.vcxproj.filters │ │ ├── 1-1-2-HelloD3D11-Raw.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ └── .gitkeep │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ └── Main.cpp │ ├── 1-1-2-HelloD3D11 │ │ ├── 1-1-2-HelloD3D11.vcxproj │ │ ├── 1-1-2-HelloD3D11.vcxproj.filters │ │ ├── 1-1-2-HelloD3D11.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ └── .gitkeep │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ ├── HelloD3D11Application.cpp │ │ ├── HelloD3D11Application.hpp │ │ └── Main.cpp │ ├── 1-1-3-HelloTriangle │ │ ├── 1-1-3-HelloTriangle.vcxproj │ │ ├── 1-1-3-HelloTriangle.vcxproj.filters │ │ ├── 1-1-3-HelloTriangle.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ ├── HelloTriangleApplication.cpp │ │ ├── HelloTriangleApplication.hpp │ │ └── Main.cpp │ ├── 1-2-2-DebugLayer │ │ ├── 1-2-2-DebugLayer.vcxproj │ │ ├── 1-2-2-DebugLayer.vcxproj.filters │ │ ├── 1-2-2-DebugLayer.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ ├── DebugLayerApplication.cpp │ │ ├── DebugLayerApplication.hpp │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ └── VertexType.hpp │ ├── 1-2-3-NamingThings │ │ ├── 1-2-3-NamingThings.vcxproj │ │ ├── 1-2-3-NamingThings.vcxproj.filters │ │ ├── 1-2-3-NamingThings.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── .gitkeep │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── NamingThingsApplication.cpp │ │ ├── NamingThingsApplication.hpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ └── VertexType.hpp │ ├── 1-3-1-RasterizerState │ │ ├── 1-3-1-RasterizerState.vcxproj │ │ ├── 1-3-1-RasterizerState.vcxproj.filters │ │ ├── 1-3-1-RasterizerState.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── SM_Good_Froge.fbx │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── T_Good_Froge.dds │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── RasterizerStateApplication.cpp │ │ ├── RasterizerStateApplication.hpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ └── VertexType.hpp │ ├── 1-3-2-Texturing │ │ ├── 1-3-2-Texturing.vcxproj │ │ ├── 1-3-2-Texturing.vcxproj.filters │ │ ├── 1-3-2-Texturing.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ ├── .gitkeep │ │ │ │ ├── T_Froge.dds │ │ │ │ └── default.png │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ ├── TexturingApplication.cpp │ │ ├── TexturingApplication.hpp │ │ └── VertexType.hpp │ ├── 1-3-3-SettingUp3DRendering │ │ ├── 1-3-3-SettingUp3DRendering.vcxproj │ │ ├── 1-3-3-SettingUp3DRendering.vcxproj.filters │ │ ├── 1-3-3-SettingUp3DRendering.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── .gitkeep │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ ├── .gitkeep │ │ │ │ ├── T_Froge.dds │ │ │ │ └── default.png │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── Setting3DApplication.cpp │ │ ├── Setting3DApplication.hpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ └── VertexType.hpp │ ├── 1-3-4-3DRendering │ │ ├── 1-3-4-3DRendering.vcxproj │ │ ├── 1-3-4-3DRendering.vcxproj.filters │ │ ├── 1-3-4-3DRendering.vcxproj.user │ │ ├── 3DRenderingApplication.cpp │ │ ├── 3DRenderingApplication.hpp │ │ ├── Assets │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ ├── T_Froge.dds │ │ │ │ └── default.png │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ └── VertexType.hpp │ ├── 1-3-5-Models-Refactored │ │ ├── 1-3-5-Models-Refactored.vcxproj │ │ ├── 1-3-5-Models-Refactored.vcxproj.filters │ │ ├── 1-3-5-Models-Refactored.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── SM_Good_Froge.fbx │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── T_Good_Froge.dds │ │ ├── Definitions.hpp │ │ ├── DeviceContext.cpp │ │ ├── DeviceContext.hpp │ │ ├── LoadingMeshesApplication.cpp │ │ ├── LoadingMeshesApplication.hpp │ │ ├── Main.cpp │ │ ├── ModelFactory.cpp │ │ ├── ModelFactory.hpp │ │ ├── Pipeline.cpp │ │ ├── Pipeline.hpp │ │ ├── PipelineFactory.cpp │ │ ├── PipelineFactory.hpp │ │ ├── ResourceDescriptor.hpp │ │ ├── TextureFactory.cpp │ │ ├── TextureFactory.hpp │ │ └── VertexType.hpp │ ├── 1-3-5-Models │ │ ├── 1-3-5-Models.vcxproj │ │ ├── 1-3-5-Models.vcxproj.filters │ │ ├── 1-3-5-Models.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── SM_Good_Froge.fbx │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── T_Good_Froge.dds │ │ ├── Definitions.hpp │ │ ├── LoadingMeshesApplication.cpp │ │ ├── LoadingMeshesApplication.hpp │ │ ├── Main.cpp │ │ ├── ResourceDescriptor.hpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ ├── TextureFactory.cpp │ │ ├── TextureFactory.hpp │ │ └── VertexType.hpp │ ├── 1-3-6-Camera │ │ ├── 1-3-6-Camera.vcxproj │ │ ├── 1-3-6-Camera.vcxproj.filters │ │ ├── 1-3-6-Camera.vcxproj.user │ │ ├── ApplicationWithInput.cpp │ │ ├── ApplicationWithInput.hpp │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── SM_Deccer_Cubes_Merged_Texture_Atlas.fbx │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── T_Atlas.dds │ │ ├── Camera.cpp │ │ ├── Camera.hpp │ │ ├── CameraApplication.cpp │ │ ├── CameraApplication.hpp │ │ ├── Definitions.hpp │ │ ├── DeviceContext.cpp │ │ ├── DeviceContext.hpp │ │ ├── Main.cpp │ │ ├── ModelFactory.cpp │ │ ├── ModelFactory.hpp │ │ ├── Pipeline.cpp │ │ ├── Pipeline.hpp │ │ ├── PipelineFactory.cpp │ │ ├── PipelineFactory.hpp │ │ ├── ResourceDescriptor.hpp │ │ ├── TextureFactory.cpp │ │ ├── TextureFactory.hpp │ │ └── VertexType.hpp │ ├── 1-3-7-DearImGui │ │ ├── 1-3-7-DearImGui.vcxproj │ │ ├── 1-3-7-DearImGui.vcxproj.filters │ │ ├── 1-3-7-DearImGui.vcxproj.user │ │ ├── Assets │ │ │ ├── Models │ │ │ │ └── SM_Good_Froge.fbx │ │ │ ├── Shaders │ │ │ │ ├── Main.ps.hlsl │ │ │ │ └── Main.vs.hlsl │ │ │ └── Textures │ │ │ │ └── T_Good_Froge.dds │ │ ├── DearImGuiApplication.cpp │ │ ├── DearImGuiApplication.hpp │ │ ├── Definitions.hpp │ │ ├── Main.cpp │ │ ├── ResourceDescriptor.hpp │ │ ├── ShaderCollection.cpp │ │ ├── ShaderCollection.hpp │ │ └── VertexType.hpp │ └── Shared │ │ └── CommonLibraries.h └── Framework │ ├── Application.cpp │ ├── Application.hpp │ ├── Framework.vcxproj │ ├── Framework.vcxproj.filters │ └── Framework.vcxproj.user ├── LearnD3D11.sln └── LearnD3D11.sln.DotSettings /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Microsoft 4 | Standard: c++17 5 | 6 | AccessModifierOffset: -4 7 | AlignAfterOpenBracket: Align 8 | AlignArrayOfStructures: Right 9 | AlignOperands: AlignAfterOperator 10 | AllowAllArgumentsOnNextLine: false 11 | AllowAllParametersOfDeclarationOnNextLine: false 12 | AllowShortFunctionsOnASingleLine: Empty 13 | BinPackArguments: false 14 | BinPackParameters: false 15 | BraceWrapping: 16 | AfterClass: true 17 | AfterEnum: true 18 | AfterFunction: true 19 | AfterNamespace: true 20 | AfterStruct: true 21 | AfterUnion: true 22 | BreakBeforeBinaryOperators: All 23 | BreakBeforeBraces: Custom 24 | BreakConstructorInitializers: BeforeColon 25 | Cpp11BracedListStyle: false 26 | ColumnLimit: 0 27 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 28 | ContinuationIndentWidth: 4 29 | IndentWidth: 4 30 | InsertTrailingCommas: Wrapped 31 | PointerAlignment: Left 32 | SpaceAfterTemplateKeyword: true 33 | SpaceBeforeParens: ControlStatements 34 | SpacesInLineCommentPrefix: 35 | Minimum: 1 36 | Maximum: 4 37 | SortIncludes: true 38 | TabWidth: 8 39 | UseTab: Never 40 | -------------------------------------------------------------------------------- /.github/workflows/build-website.yml: -------------------------------------------------------------------------------- 1 | name: Build Website 2 | on: 3 | push: 4 | branches: 5 | - main 6 | paths: 7 | - 'docs/**' 8 | - 'src/**' 9 | jobs: 10 | update-docs: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - uses: actions/setup-python@v2 15 | with: 16 | python-version: 3.x 17 | - run: pip install mkdocs-material 18 | - run: pip install mkdocs-literate-nav 19 | - run: pip install mkdocs-mermaid2-plugin 20 | - run: mkdocs gh-deploy --force 21 | -------------------------------------------------------------------------------- /.github/workflows/docs-checker.yml: -------------------------------------------------------------------------------- 1 | name: Docs checker 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | paths: 7 | - 'docs/**' 8 | jobs: 9 | validate-line-length: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | with: 14 | fetch-depth: 0 15 | - name: Make sure git is installed 16 | run: sudo apt-get update && sudo apt-get install git -y && git --version 17 | # "https://google.com/serch" 18 | 19 | # The first grep filters out everything that has a link in it. The second filters anything 20 | # that is not an addition (prefixed by a single '+'). 21 | - name: Get changed file names of files changed in PR 22 | run: git diff -U0 ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -P "^(?!.*(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])).*" | grep -P "^\+{1}(?!\+)" > diff_files.txt 23 | - name: Count line lengths in diff_files.txt 24 | run: "awk -F: '{ if(length>100) { err = 1; exit err; } }' diff_files.txt" 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Welcome graphics programming frogger. 2 | 3 | You decide(d) to contribute to the team effort of providing a cool learnd3d11 tutorial similar to learnopengl 4 | then all you need is the following things installed 5 | 6 | - python 7 | - mkdocs 8 | - mkdocs-material 9 | 10 | ```bash 11 | pip install mkdocs 12 | pip install mkdocs-material 13 | pip install mkdocs-literate-nav 14 | pip install mkdocs-mermaid2-plugin 15 | ``` 16 | 17 | Then you fork the repo, or when you have direct contribution access clone the repo as usual 18 | Open the folder in vscode for example and simply edit away, all in markdown. 19 | 20 | to watch what you are doing you can run (and should) 21 | 22 | ```bash 23 | mkdocs serve 24 | ``` 25 | (in windows if you did not add to path: ```python -m mkdocs serve```) 26 | 27 | that will provide a live version of your edit, running on your local machine. 28 | 29 | As soon as you want to commit, provide a meaningful commit message, please. 30 | 31 | That's it :) 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Graphics Programming 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LearnD3D11 2 | 3 | [Learn how to D3D11](https://graphicsprogramming.github.io/learnd3d11/) 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/1-introduction/1-1-getting-started/1-1-0-overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | As you may or may not know, there's a few choices in terms of what you can use for rendering, such 4 | as OpenGL, Vulkan, Metal, and what is commonly known as "DirectX". However, in word of mouth 5 | DirectX usually refers to Direct3D, which is one of the many API's that DirectX has. In fact 6 | DirectX provides tooling and libraries for more aspects of game development, including: 7 | 8 | - **Audio** 9 | - **Fonts** 10 | - **Input** 11 | - **Graphics** 12 | 13 | The goal of LearnD3D11 is, as one might guess, the targeted explanation and showcase of Direct3D11 14 | within C++, or as one generally refers to it: "DirectX 11". This guide does _NOT_ cover DirectX 12, 15 | the newer version of the API, as it is very low level and will usually require a good understanding 16 | of the GPU and how it works. We will cover concepts and some techniques used in graphics programming, 17 | and we do not expect you to have any prerequisites in this field. It is, however, not a guide 18 | covering C++ or programming in general; we expect at least the ability and understanding to write 19 | object-oriented programs in C++. 20 | 21 | During each step we'll provide a project for you to follow along as we explain everything for you 22 | to start rendering geometry using your GPU. 23 | 24 | Also note that DirectX is made by Microsoft and is generally only available on Windows. However, 25 | `DXVK` was developed to run D3D9 through D3D11 on Linux or Wine on top of Vulkan and would be the 26 | only way of developing and using D3D11 on those platforms. 27 | 28 | This initial section will cover creating the actual window, initializing Direct3D11 and getting our 29 | very first visuals (which is commonly known as the Hello Triangle) 30 | 31 | ## Project structure 32 | 33 | A few words about how each project will look like. 34 | 35 | Inside the project folder: 36 | 37 | ```bash 38 | Assets/ 39 | Assets/Models/ 40 | Assets/Shaders/ 41 | Assets/Textures/ 42 | bin/Debug/ 43 | bin/Release/ 44 | obj/Debug/ 45 | obj/Release/ 46 | Main.cpp 47 | x-x-x-project.vcxproj.filters 48 | x-x-x-project.vcxproj.user 49 | x-x-x-project.vcxproj 50 | ``` 51 | 52 | - The `vcxproj` files are part of Visual Studio's project system. 53 | - `Main.cpp` is the entry point of each application. (in the first few chapters we will have all the code in there, but later refactor them out into their own units) 54 | - `obj/` contains all intermediate junk the compiler produced, to keep the folder structure clean 55 | - `bin/` will contain the compiled program of the chapter along with all necessary `Assets` 56 | - `Assets/` will contain all the used assets, such as models, shaders and textures and other things. It will be empty for the first few chapters, and we will copy it and its contents to the bin/Debug or bin/Release directory, depending on which configuration you chose 57 | -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/1-2-0-overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | While developing your graphics engine, your game, or your small tool to 4 | visualize stuff, you sometimes end up in situations where you don't know what is going on, 5 | or can't explain why this dang triangle is not showing up, while the screen is black. 6 | 7 | There are various tools and techniques which can help us getting the triangle on the screen. 8 | 9 | [Clear State](1-2-1-clear-state.md) 10 | 11 | [Debug Layer](1-2-2-debug-layer.md) 12 | 13 | [Naming Things](1-2-3-naming-things.md) 14 | 15 | [RenderDoc](1-2-4-renderdoc.md) 16 | 17 | [Laptop GPUs](1-2-5-laptop-gpus.md) 18 | 19 | [Next chapter](./1-2-1-clear-state.md) 20 | -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/1-2-1-clear-state.md: -------------------------------------------------------------------------------- 1 | # Clear State 2 | 3 | The Clear State is useful to make sure no state from previous drawcalls is still being used. 4 | 5 | For example: 6 | 7 | Say we have just drawn our scene, all models and such are being drawn properly, but now we decide to add some UI, we adjust some state that normally is set-once and forget (at initialisation) like scissor rects or viewports. 8 | But now after we're done adding our UI element draw, suddenly our models are drawing in some weird square on the screen, or models that perhaps did not have a normal-map suddenly use a UI texture as if it were one. 9 | 10 | This is something that can happen if we don't have a clear state, and really only goes wrong if one did not think they'd had to set some part of the pipeline during some draws. 11 | 12 | The usefulness of a Clear State generally comes in being able to enable or disable it at will and it being used as a mechanic to spot rendering bugs caused by state that was not (re)set correctly. 13 | So as soon as weird things start to happen, you can use a clear state between say every draw, and if the bug then disappears you'll know it's very likely related to state set from a previous draw. 14 | 15 | One can accomplish this in a few ways: 16 | 17 | Setting their states/buffers/resources/targets to NULL where possible by hand. 18 | 19 | Or call a more "reset it all" function that exists on the ID3D11DeviceContext aptly called __ClearState()__. 20 | !!! info 21 | https://docs.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-clearstate 22 | 23 | Though keep in mind that using the latter function also resets stuff like the inputlayout, primitive topology and literally everything. This might require a bit more work in making sure all rendering state is setup correctly again afterwards 24 | 25 | In pure performance terms it can be quite wasteful to reset a whole bunch of state (or re-set it) every draw/pass/frame which is why this is viewed as a debugging option. 26 | 27 | In the end, one generally should make sure their draws always set (or have set) their required state so they do not need to use a clear-state. 28 | 29 | [Next chapter](./1-2-2-debug-layer.md) 30 | -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/1-2-3-naming-things.md: -------------------------------------------------------------------------------- 1 | # Naming things 2 | 3 | The debug layer might tell us possible leaks of various d3d11 related objects, the cool thing is, 4 | it can tell you exactly which object is leaking, via its name. 5 | 6 | We can give our d3d11 objects a name. 7 | 8 | Each D3D11 object (not the device itself) derives from `ID3D11DeviceChild` and that interface 9 | implements a method `SetPrivateData` which we can use to assign a name to all those objects. 10 | 11 | For that we will introduce a macro (hopefully the only one :)) 12 | 13 | ```cpp 14 | template 15 | inline void SetDebugName( 16 | _In_ ID3D11DeviceChild* deviceResource, 17 | _In_z_ const char(&debugName)[TDebugNameLength]) 18 | { 19 | deviceResource->SetPrivateData(WKPDID_D3DDebugObjectName, TDebugNameLength - 1, debugName); 20 | } 21 | ``` 22 | 23 | And we use it like 24 | 25 | ```cpp 26 | SetDebugName(_deviceContext.Get(), "CTX_Main"); 27 | ``` 28 | 29 | Unfortunately not every object is/implements `ID3D11DeviceChild` so for the other things like 30 | the dxgi factory or the device itself we have to use `SetPrivateData` the ordinary way 31 | 32 | ```cpp 33 | constexpr char factoryName[] = "Factory1"; 34 | _factory->SetPrivateData(WKPDID_D3DDebugObjectName, sizeof(factoryName), factoryName); 35 | 36 | constexpr char deviceName[] = "DEV_Main"; 37 | _device->SetPrivateData(WKPDID_D3DDebugObjectName, sizeof(deviceName), deviceName); 38 | ``` 39 | 40 | Now run the thing again and take a look at the summary report of the debug device in the output window 41 | 42 | ```bash 43 | D3D11 WARNING: Live ID3D11Device at 0x000002214E8A1B10, Name: DEV_Main, Refcount: 3 [ STATE_CREATION WARNING #441: LIVE_DEVICE] 44 | D3D11 WARNING: Live ID3D11Context at 0x000002214E8A5B50, Name: CTX_Main, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #2097226: LIVE_CONTEXT] 45 | ``` 46 | 47 | Notice anything? 48 | 49 | Exactly, they show names. 50 | 51 | Naming things is also useful while debugging your application. In debuggers such as RenderDoc or Nvidia Nsight, the resource name will show up in the Resource Inspector, making it easier to find your resources and check its contents / configuration. 52 | 53 | For example, if we name our Triangle vertex buffer using the follows 54 | ```cpp 55 | SetDebugName(_triangleVertices.Get(), "Triangle_Vertices"); 56 | ``` 57 | In RenderDoc's Resource Inspector tab, we see 58 | ![](../../images/1-2-3-namingthings-renderdoc.png) 59 | 60 | Similary, in Nsight's All Resources tab, we see 61 | ![](../../images/1-2-3-namingthings-nsight.png) 62 | 63 | [Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-2-3-NamingThings) 64 | 65 | [Next chapter](./1-2-4-renderdoc.md) 66 | -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/1-2-5-laptop-gpus.md: -------------------------------------------------------------------------------- 1 | # Laptop GPUs 2 | 3 | Some laptops come with dedicated graphics cards not just integrated ones. 4 | 5 | Sometimes default settings let your application only use the integrated gpu, which usually is not the best to run anything but very light games. Some games and programs have a way to select the desired graphics card, you can chose which graphics card to use via the control panel of your driver. 6 | 7 | You can also enforce the use of the dedicated graphics card per code. Thats what we are going to show here. 8 | 9 | Simply find a spot in your program and add the following code 10 | 11 | ```cpp 12 | extern "C" 13 | { 14 | __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; 15 | ​ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; 16 | } 17 | ``` 18 | 19 | This will enforce graphics cards from NVIDIA and AMD to use the dedicated graphics card, when available. 20 | 21 | You can find more information [here for NVIDIA](http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf) and [here for AMD](http://developer.amd.com/community/blog/2015/10/02/amd-enduro-system-for-developers/) 22 | 23 | Intel might have something similar, once they release their dedicated graphics cards for laptops. 24 | 25 | [Next chapter](../../1-3-basics/1-3-0-overview/) 26 | -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/api-inspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/api-inspector.png -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/application-dirs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/application-dirs.png -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/event-browser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/event-browser.png -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/opening-capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/opening-capture.png -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/pipeline-state.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/pipeline-state.gif -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/render-doc-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/render-doc-default.png -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/render-doc-overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/render-doc-overlay.png -------------------------------------------------------------------------------- /docs/1-introduction/1-2-debug/media/1-2-3-naming-things/resource-inspector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/1-2-debug/media/1-2-3-naming-things/resource-inspector.png -------------------------------------------------------------------------------- /docs/1-introduction/1-3-basics/1-3-0-overview.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Now that we know how to get a triangle on screen, we'll dive into the more simple topics in rendering. 4 | 5 | We'll talk about the rasterizer state and what it can do for us, get some textures onto our geometry, and explain everything we need to get a 3D model properly rendering. 6 | 7 | Finally we'll add a tool that almost everyone uses, "Dear ImGui" which allows is to very flexibly add some UI to control things in our scenes. 8 | 9 | [Rasterizer State](1-3-1-rasterizer-state.md) 10 | 11 | [Texturing](1-3-2-texturing.md) 12 | 13 | [Setting up 3D Rendering](1-3-3-setting-up-3d-rendering.md) 14 | 15 | [3D Rendering](1-3-4-3d-rendering.md) 16 | 17 | [Models](1-3-5-models.md) 18 | 19 | [Dear ImGui](1-3-6-dear-imgui.md) 20 | 21 | [Next chapter](./1-3-2-texturing.md) 22 | -------------------------------------------------------------------------------- /docs/1-introduction/1-3-basics/1-3-5-models.md: -------------------------------------------------------------------------------- 1 | # Models 2 | 3 | !!! error 4 | Please note that this chapter is unfinished and will be finished up at some point in the future. 5 | 6 | 7 | After being able to load and display an 3D cube the next step is getting some more exciting stuff on screen. 8 | Models are the next step! 9 | 10 | Just as with textures, there's no real support for what we call "Models" in D3D11 (or any other API), with the sole exception being D3D9 and their "x" format, which we can consider antique and very much deprecated. 11 | 12 | So we have to load models ourselves. 13 | But before we start we need to know what a model actually is. You might open a game and say "this character is a model" or "this house is a model", but that doesn't answer much as things can easily be a lot more complicated. 14 | 15 | Take this with a grain of salt because how a "model" is defined isn't concrete. 16 | But a model is generally composed out of a few things, each of them optional, some of them might exist in one format and not in others. 17 | 18 | 19 | | | | 20 | |------------|-------| 21 | | Meshes | A collection of vertices and optionally indices| 22 | | Materials | Some arbitrary collection of things that tell us what a mesh looks like| 23 | | Bones | A collection of "bones" which can be a collection of vertices with influence amounts| 24 | | Animations | Generally a collection of matrices for each set of bones| 25 | | ??? | Other things, anything! Other models, Scripts, Camera's, Lights, Plumbusses, You name it! | 26 | 27 | Now you might think: "If everything is optional, and models could have anything, how do we deal with this?" 28 | 29 | The answer is simple: We don't! 30 | 31 | There is no software in existance that can load and/or display all model formats and any feature they can support. 32 | Generally only the features 'most' people care about are supported, which is generally meshes and materials, and often enough animations as well. 33 | 34 | So how are we going to load these vague and arbitrary "models"? 35 | 36 | Well just as with textures, we're going to use a library for it. A common choice for this is [**Assimp**](https://assimp-docs.readthedocs.io/en/latest/about/introduction.html), it is not the fastest, but it is one of the more flexible ones. 37 | 38 | 39 | !!! error 40 | 41 | TODO: model loading 42 | 43 | 44 | [Project on GitHub](https://github.com/GraphicsProgramming/learnd3d11/tree/main/src/Cpp/1-getting-started/1-3-2-LoadingMeshes) 45 | 46 | [Next chapter](./1-3-6-dear-imgui.md) 47 | -------------------------------------------------------------------------------- /docs/1-introduction/1-3-basics/1-3-6-dear-imgui.md: -------------------------------------------------------------------------------- 1 | # Dear ImGui 2 | 3 | !!! error 4 | This chapter is coming later, this chapter is going to show you how to use Dear ImGui which is an amazing library to have fast and flexible UI for in your program. 5 | Meanwhile please visit: to get a look at this great tool for development, a must-have library to control your renderer/game/editor and whatever else you can think of! For a look at the amazing things people do with it, see: . -------------------------------------------------------------------------------- /docs/1-introduction/images/1-1-1-hello-window-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-1-1-hello-window-1.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-2-3-namingthings-nsight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-2-3-namingthings-nsight.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-2-3-namingthings-renderdoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-2-3-namingthings-renderdoc.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-1-cullmode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-1-cullmode.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-1-fillmode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-1-fillmode.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-2-froge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-2-froge.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-2-textureslots.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-2-textureslots.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-2-wrapmodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-2-wrapmodes.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-3-worldspacetriangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-3-worldspacetriangle.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-4-cube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-4-cube.png -------------------------------------------------------------------------------- /docs/1-introduction/images/1-3-4-insidecube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/docs/1-introduction/images/1-3-4-insidecube.png -------------------------------------------------------------------------------- /docs/8-code/repository.md: -------------------------------------------------------------------------------- 1 | # Code Repository 2 | -------------------------------------------------------------------------------- /docs/about.md: -------------------------------------------------------------------------------- 1 | # About Learn D3D11 2 | 3 | ## Disclaimer 4 | 5 | We are just a bunch of graphics programming enthusiasts doing all this on our own time. 6 | If you find typos, bugs or have questions, don't hesitate to open an issue or even send a PR, 7 | otherwise feel free to join us on our Discord server. 8 | 9 | [Join Graphics Programming](https://discord.gg/6mgNGk7) 10 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | # Welcome to LearnD3D11 2 | 3 | ## Goal 4 | 5 | This is LearnD3D11, a guide aimed at anyone trying to learn Direct3D11, commonly referred to as 6 | DirectX 11. This guide explains the basic usage of Direct3D11 and general graphics programming 7 | topics and techniques, without requiring any previous experience within this field. The guide's 8 | code itself is written in C++, although if one has experience with C++ and can understand how we 9 | use it, it is probably easily transferable to any other language. 10 | 11 | ## Disclaimer 12 | 13 | We are just a bunch of graphics programming enthusiasts doing all this on our own time. This 14 | project is also still a **work in progress**; a lot of content may be missing or faulty. 15 | If you find typos, bugs or have questions, don't hesitate to open an issue or even send a PR. 16 | Also feel free to join us on our [Discord server](https://discord.gg/6mgNGk7). 17 | 18 | ## Getting started 19 | 20 | To get started reading LearnD3D11, you can jump right into the 21 | [first chapter](1-introduction/1-1-getting-started/1-1-0-overview/)! 22 | -------------------------------------------------------------------------------- /docs/javascripts/mathjax.js: -------------------------------------------------------------------------------- 1 | window.MathJax = { 2 | tex: { 3 | inlineMath: [["\\(", "\\)"]], 4 | displayMath: [["\\[", "\\]"]], 5 | processEscapes: true, 6 | processEnvironments: true 7 | }, 8 | options: { 9 | ignoreHtmlClass: ".*|", 10 | processHtmlClass: "arithmatex" 11 | } 12 | }; 13 | 14 | document$.subscribe(() => { 15 | 16 | 17 | MathJax.typesetPromise() 18 | }) -------------------------------------------------------------------------------- /docs/license.md: -------------------------------------------------------------------------------- 1 | ``` 2 | MIT License 3 | 4 | Copyright (c) 2022 Graphics Programming 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | ``` 24 | -------------------------------------------------------------------------------- /lib/DirectXTex/lib/Debug/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/DirectXTex/lib/Debug/DirectXTex.lib -------------------------------------------------------------------------------- /lib/DirectXTex/lib/Release/DirectXTex.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/DirectXTex/lib/Release/DirectXTex.lib -------------------------------------------------------------------------------- /lib/FreeImage/include/FreeImage.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/FreeImage/include/FreeImage.h -------------------------------------------------------------------------------- /lib/FreeImage/lib/FreeImageLib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/FreeImage/lib/FreeImageLib.lib -------------------------------------------------------------------------------- /lib/FreeImage/lib/FreeImageLibd.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/FreeImage/lib/FreeImageLibd.lib -------------------------------------------------------------------------------- /lib/assimp/include/assimp/.editorconfig: -------------------------------------------------------------------------------- 1 | # See for details 2 | 3 | [*.{h,hpp,inl}] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | indent_size = 4 8 | indent_style = space 9 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/Compiler/poppack1.h: -------------------------------------------------------------------------------- 1 | 2 | // =============================================================================== 3 | // May be included multiple times - resets structure packing to the defaults 4 | // for all supported compilers. Reverts the changes made by #include 5 | // 6 | // Currently this works on the following compilers: 7 | // MSVC 7,8,9 8 | // GCC 9 | // BORLAND (complains about 'pack state changed but not reverted', but works) 10 | // =============================================================================== 11 | 12 | #ifndef AI_PUSHPACK_IS_DEFINED 13 | # error pushpack1.h must be included after poppack1.h 14 | #endif 15 | 16 | // reset packing to the original value 17 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) 18 | # pragma pack( pop ) 19 | #endif 20 | #undef PACK_STRUCT 21 | 22 | #undef AI_PUSHPACK_IS_DEFINED 23 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/Compiler/pushpack1.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // =============================================================================== 4 | // May be included multiple times - sets structure packing to 1 5 | // for all supported compilers. #include reverts the changes. 6 | // 7 | // Currently this works on the following compilers: 8 | // MSVC 7,8,9 9 | // GCC 10 | // BORLAND (complains about 'pack state changed but not reverted', but works) 11 | // Clang 12 | // 13 | // 14 | // USAGE: 15 | // 16 | // struct StructToBePacked { 17 | // } PACK_STRUCT; 18 | // 19 | // =============================================================================== 20 | 21 | #ifdef AI_PUSHPACK_IS_DEFINED 22 | # error poppack1.h must be included after pushpack1.h 23 | #endif 24 | 25 | #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) 26 | # pragma pack(push,1) 27 | # define PACK_STRUCT 28 | #elif defined( __GNUC__ ) || defined(__clang__) 29 | # if !defined(HOST_MINGW) 30 | # define PACK_STRUCT __attribute__((__packed__)) 31 | # else 32 | # define PACK_STRUCT __attribute__((gcc_struct, __packed__)) 33 | # endif 34 | #else 35 | # error Compiler not supported 36 | #endif 37 | 38 | #if defined(_MSC_VER) 39 | // C4103: Packing was changed after the inclusion of the header, probably missing #pragma pop 40 | # pragma warning (disable : 4103) 41 | #endif 42 | 43 | #define AI_PUSHPACK_IS_DEFINED 44 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/CreateAnimMesh.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2018, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | /** @file CreateAnimMesh.h 44 | * Create AnimMesh from Mesh 45 | */ 46 | #ifndef INCLUDED_AI_CREATE_ANIM_MESH_H 47 | #define INCLUDED_AI_CREATE_ANIM_MESH_H 48 | 49 | #include 50 | 51 | namespace Assimp { 52 | 53 | /** Create aiAnimMesh from aiMesh. */ 54 | ASSIMP_API aiAnimMesh *aiCreateAnimMesh(const aiMesh *mesh); 55 | 56 | } // end of namespace Assimp 57 | #endif // INCLUDED_AI_CREATE_ANIM_MESH_H 58 | 59 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2012, assimp team 6 | All rights reserved. 7 | 8 | Redistribution and use of this software in source and binary forms, 9 | with or without modification, are permitted provided that the 10 | following conditions are met: 11 | 12 | * Redistributions of source code must retain the above 13 | copyright notice, this list of conditions and the 14 | following disclaimer. 15 | 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer in the documentation and/or other 19 | materials provided with the distribution. 20 | 21 | * Neither the name of the assimp team, nor the names of its 22 | contributors may be used to endorse or promote products 23 | derived from this software without specific prior 24 | written permission of the assimp team. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 | 38 | ---------------------------------------------------------------------- 39 | */ 40 | 41 | // We need those constants, workaround for any platforms where nobody defined them yet 42 | #if (!defined SIZE_MAX) 43 | # define SIZE_MAX (~((size_t)0)) 44 | #endif 45 | 46 | #if (!defined UINT_MAX) 47 | # define UINT_MAX (~((unsigned int)0)) 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/Macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2018, assimp team 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the following 12 | conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | --------------------------------------------------------------------------- 40 | */ 41 | 42 | /* Helper macro to set a pointer to NULL in debug builds 43 | */ 44 | #if (defined ASSIMP_BUILD_DEBUG) 45 | # define AI_DEBUG_INVALIDATE_PTR(x) x = NULL; 46 | #else 47 | # define AI_DEBUG_INVALIDATE_PTR(x) 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/MathFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2016, assimp team 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the following 12 | conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | --------------------------------------------------------------------------- 40 | */ 41 | 42 | /** @file MathFunctions.h 43 | * @brief Implementation of the math functions (gcd and lcm) 44 | * 45 | * Copied from BoostWorkaround/math 46 | */ 47 | 48 | namespace Assimp { 49 | namespace Math { 50 | 51 | // TODO: use binary GCD for unsigned integers .... 52 | template < typename IntegerType > 53 | IntegerType gcd( IntegerType a, IntegerType b ) 54 | { 55 | const IntegerType zero = (IntegerType)0; 56 | while ( true ) 57 | { 58 | if ( a == zero ) 59 | return b; 60 | b %= a; 61 | 62 | if ( b == zero ) 63 | return a; 64 | a %= b; 65 | } 66 | } 67 | 68 | template < typename IntegerType > 69 | IntegerType lcm( IntegerType a, IntegerType b ) 70 | { 71 | const IntegerType t = gcd (a,b); 72 | if (!t)return t; 73 | return a / t * b; 74 | } 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/XMLTools.h: -------------------------------------------------------------------------------- 1 | /* 2 | Open Asset Import Library (assimp) 3 | ---------------------------------------------------------------------- 4 | 5 | Copyright (c) 2006-2018, assimp team 6 | 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use of this software in source and binary forms, 11 | with or without modification, are permitted provided that the 12 | following conditions are met: 13 | 14 | * Redistributions of source code must retain the above 15 | copyright notice, this list of conditions and the 16 | following disclaimer. 17 | 18 | * Redistributions in binary form must reproduce the above 19 | copyright notice, this list of conditions and the 20 | following disclaimer in the documentation and/or other 21 | materials provided with the distribution. 22 | 23 | * Neither the name of the assimp team, nor the names of its 24 | contributors may be used to endorse or promote products 25 | derived from this software without specific prior 26 | written permission of the assimp team. 27 | 28 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 | 40 | ---------------------------------------------------------------------- 41 | */ 42 | 43 | #ifndef INCLUDED_ASSIMP_XML_TOOLS_H 44 | #define INCLUDED_ASSIMP_XML_TOOLS_H 45 | 46 | #include 47 | 48 | namespace Assimp { 49 | // XML escape the 5 XML special characters (",',<,> and &) in |data| 50 | // Based on http://stackoverflow.com/questions/5665231 51 | std::string XMLEscape(const std::string& data) { 52 | std::string buffer; 53 | 54 | const size_t size = data.size(); 55 | buffer.reserve(size + size / 8); 56 | for(size_t i = 0; i < size; ++i) { 57 | const char c = data[i]; 58 | switch(c) { 59 | case '&' : 60 | buffer.append("&"); 61 | break; 62 | case '\"': 63 | buffer.append("""); 64 | break; 65 | case '\'': 66 | buffer.append("'"); 67 | break; 68 | case '<' : 69 | buffer.append("<"); 70 | break; 71 | case '>' : 72 | buffer.append(">"); 73 | break; 74 | default: 75 | buffer.append(&c, 1); 76 | break; 77 | } 78 | } 79 | return buffer; 80 | } 81 | } 82 | 83 | #endif // INCLUDED_ASSIMP_XML_TOOLS_H 84 | -------------------------------------------------------------------------------- /lib/assimp/include/assimp/ai_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | --------------------------------------------------------------------------- 3 | Open Asset Import Library (assimp) 4 | --------------------------------------------------------------------------- 5 | 6 | Copyright (c) 2006-2018, assimp team 7 | 8 | 9 | 10 | All rights reserved. 11 | 12 | Redistribution and use of this software in source and binary forms, 13 | with or without modification, are permitted provided that the following 14 | conditions are met: 15 | 16 | * Redistributions of source code must retain the above 17 | copyright notice, this list of conditions and the 18 | following disclaimer. 19 | 20 | * Redistributions in binary form must reproduce the above 21 | copyright notice, this list of conditions and the 22 | following disclaimer in the documentation and/or other 23 | materials provided with the distribution. 24 | 25 | * Neither the name of the assimp team, nor the names of its 26 | contributors may be used to endorse or promote products 27 | derived from this software without specific prior 28 | written permission of the assimp team. 29 | 30 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 33 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 35 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 36 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 37 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 38 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 39 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 40 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | --------------------------------------------------------------------------- 42 | */ 43 | #pragma once 44 | #ifndef AI_ASSERT_H_INC 45 | #define AI_ASSERT_H_INC 46 | 47 | #ifdef ASSIMP_BUILD_DEBUG 48 | # include 49 | # define ai_assert(expression) assert(expression) 50 | #else 51 | # define ai_assert(expression) 52 | #endif // 53 | 54 | #endif // AI_ASSERT_H_INC 55 | -------------------------------------------------------------------------------- /lib/assimp/lib/assimp.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/assimp/lib/assimp.dll -------------------------------------------------------------------------------- /lib/assimp/lib/assimp.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/assimp/lib/assimp.lib -------------------------------------------------------------------------------- /lib/glfw-3.3.6/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | 3 | Copyright (c) 2006-2019 Camilla Löwy 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would 16 | be appreciated but is not required. 17 | 18 | 2. Altered source versions must be plainly marked as such, and must not 19 | be misrepresented as being the original software. 20 | 21 | 3. This notice may not be removed or altered from any source 22 | distribution. 23 | 24 | -------------------------------------------------------------------------------- /lib/glfw-3.3.6/README.md: -------------------------------------------------------------------------------- 1 | # GLFW binaries for 64-bit Windows 2 | 3 | This archive contains documentation, headers, pre-compiled static libraries, 4 | import libraries and DLLs for GLFW 3.3.6. 5 | 6 | Binaries for the following compilers are included 7 | 8 | - Visual C++ 2022 (built with 17.1.0 preview 1.1) 9 | - Visual C++ 2019 (built with 16.11.7) 10 | - Visual C++ 2017 (built with 15.9.41) 11 | - Visual C++ 2015 (built with 14.0.25431.01) 12 | - Visual C++ 2013 (built with 12.0.40629.00) 13 | - Visual C++ 2012 (built with 11.0.61219.00) 14 | - MinGW-w64 (built with GCC 8.1.0) 15 | 16 | 17 | ## Binaries for Visual C++ 18 | 19 | All binaries for Visual C++ 2017 and earlier are compatible with Windows XP, but 20 | this is not supported by Visual C++ 2019. 21 | 22 | ### GLFW as a DLL 23 | 24 | To use GLFW as a DLL, link against the `glfw3dll.lib` file for your 25 | environment. This will add a load time dependency on `glfw3.dll`. The 26 | remaining files in the same directory are not needed. 27 | 28 | This DLL is built in release mode for the Multithreaded DLL runtime library. 29 | 30 | There is also a GLFW DLL and import library pair in the `lib-static-ucrt` 31 | directory. These are built with Visual C++ 2019 and the static Multithreaded 32 | runtime library. 33 | 34 | ### GLFW as a static library 35 | 36 | To use GLFW as a static library, link against `glfw3.lib` if your application 37 | is using the Multithreaded DLL runtime library, or `glfw3_mt.lib` if it is 38 | using the static Multithreaded runtime library. The remaining files in the same 39 | directory are not needed. 40 | 41 | The static libraries are built in release mode and do not contain debug 42 | information but can still be linked with the debug versions of the runtime 43 | library. 44 | 45 | 46 | ## Binaries for MinGW-w64 47 | 48 | ### GLFW as a DLL 49 | 50 | To use GLFW as a DLL, link against the `libglfw3dll.a` file for your 51 | environment. This will add a load time dependency on `glfw3.dll`. The 52 | remaining files in the same directory are not needed. 53 | 54 | The DLLs are built in release mode. 55 | 56 | The DLLs depend on the `msvcrt.dll` C runtime library. There is also a GLFW 57 | DLL and import library in the `lib-static-ucrt` directory that is built with 58 | Visual C++ 2019 and statically linked against the UCRT. 59 | 60 | All DLLs in this archive provide the same ABI and can be used as drop-in 61 | replacements for one another, as long as the C runtime library they depend on is 62 | available. 63 | 64 | ### GLFW as a static library 65 | 66 | To use GLFW as a static library, link against the `libglfw3.a` file for your 67 | environment. The other files in the same directory are not needed. 68 | 69 | The library is built in release mode and do not contain debug information. 70 | -------------------------------------------------------------------------------- /lib/glfw-3.3.6/lib-vc2022/glfw3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/glfw-3.3.6/lib-vc2022/glfw3.dll -------------------------------------------------------------------------------- /lib/glfw-3.3.6/lib-vc2022/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/glfw-3.3.6/lib-vc2022/glfw3.lib -------------------------------------------------------------------------------- /lib/glfw-3.3.6/lib-vc2022/glfw3_mt.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/glfw-3.3.6/lib-vc2022/glfw3_mt.lib -------------------------------------------------------------------------------- /lib/glfw-3.3.6/lib-vc2022/glfw3dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/lib/glfw-3.3.6/lib-vc2022/glfw3dll.lib -------------------------------------------------------------------------------- /lib/imgui/include/imgui/backend/imgui_impl_dx11.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX11 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 7 | 8 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 9 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include // IMGUI_IMPL_API 15 | 16 | struct ID3D11Device; 17 | struct ID3D11DeviceContext; 18 | 19 | IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); 20 | IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); 21 | IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); 22 | IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); 23 | 24 | // Use if you want to reset your rendering device without losing Dear ImGui state. 25 | IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); 26 | IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-0-Empty/1-1-0-Empty.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-0-Empty/1-1-0-Empty.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-0-Empty/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-0-Empty/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-0-Empty/Assets/Shaders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-0-Empty/Assets/Shaders/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-0-Empty/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-0-Empty/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-0-Empty/Main.cpp: -------------------------------------------------------------------------------- 1 | int main() 2 | { 3 | // And so your journey begins... 4 | return 0; 5 | } 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/1-1-1-HelloGLFWWindow.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/1-1-1-HelloGLFWWindow.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Assets/Shaders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Assets/Shaders/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloGLFWWindow/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | int main(int argc, char* argv[]) 6 | { 7 | if (!glfwInit()) 8 | { 9 | std::cerr << "GLFW: Failed to initialize\n"; 10 | return -1; 11 | } 12 | 13 | GLFWmonitor* primaryMonitor = glfwGetPrimaryMonitor(); 14 | const GLFWvidmode* videoMode = glfwGetVideoMode(primaryMonitor); 15 | const int32_t width = static_cast(videoMode->width * 0.9f); 16 | const int32_t height = static_cast(videoMode->height * 0.9f); 17 | 18 | glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); 19 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); 20 | GLFWwindow* window = glfwCreateWindow( 21 | width, 22 | height, 23 | "LearnD3D11 - Hello Window", 24 | nullptr, 25 | nullptr); 26 | if (window == nullptr) 27 | { 28 | std::cerr << "GLFW: Failed to create window\n"; 29 | glfwTerminate(); 30 | return -1; 31 | } 32 | 33 | const int32_t windowLeft = videoMode->width / 2 - width / 2; 34 | const int32_t windowTop = videoMode->height / 2 - height / 2; 35 | glfwSetWindowPos( 36 | window, 37 | windowLeft, 38 | windowTop); 39 | 40 | while (!glfwWindowShouldClose(window)) 41 | { 42 | glfwPollEvents(); 43 | // future update code 44 | // future render code 45 | } 46 | 47 | glfwDestroyWindow(window); 48 | glfwTerminate(); 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWin32Window/1-1-1-HelloWin32Window.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWin32Window/1-1-1-HelloWin32Window.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Assets/Shaders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Assets/Shaders/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWin32Window/Main.cpp: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #include 3 | 4 | #include 5 | 6 | LRESULT CALLBACK WindowCallback( 7 | HWND hWnd, 8 | UINT uMsg, 9 | WPARAM wParam, 10 | LPARAM lParam) 11 | { 12 | return DefWindowProc(hWnd, uMsg, wParam, lParam); 13 | } 14 | 15 | int main(int argc, char* argv[]) 16 | { 17 | const int32_t monitorWidth = GetSystemMetrics(SM_CXSCREEN); 18 | const int32_t monitorHeight = GetSystemMetrics(SM_CYSCREEN); 19 | const int32_t windowWidth = static_cast(monitorWidth * 0.9f); 20 | const int32_t windowHeight = static_cast(monitorHeight * 0.9f); 21 | const int32_t windowLeft = monitorWidth / 2 - windowWidth / 2; 22 | const int32_t windowTop = monitorHeight / 2 - windowHeight / 2; 23 | const wchar_t* windowClassName = L"SampleWindowClass"; 24 | const wchar_t* windowTitle = L"Learn D3D11 - Hello Win32 Window"; 25 | const HMODULE currentInstance = GetModuleHandle(nullptr); // Equivalent to the first parameter in WinMain() 26 | // Registers the Window class 27 | WNDCLASSEX windowClassInfo; 28 | windowClassInfo.cbSize = sizeof(WNDCLASSEX); 29 | windowClassInfo.style = CS_HREDRAW | CS_VREDRAW; 30 | windowClassInfo.lpfnWndProc = WindowCallback; 31 | windowClassInfo.cbClsExtra = 0; 32 | windowClassInfo.cbWndExtra = 0; 33 | windowClassInfo.hInstance = currentInstance; 34 | windowClassInfo.hIcon = LoadIcon(windowClassInfo.hInstance, IDI_APPLICATION); 35 | windowClassInfo.hCursor = LoadCursor(nullptr, IDC_ARROW); 36 | windowClassInfo.hbrBackground = reinterpret_cast(COLOR_WINDOW + 1); 37 | windowClassInfo.lpszMenuName = nullptr; 38 | windowClassInfo.lpszClassName = windowClassName; 39 | windowClassInfo.hIconSm = LoadIcon(windowClassInfo.hInstance, IDI_APPLICATION); 40 | if (!RegisterClassEx(&windowClassInfo)) 41 | { 42 | std::cerr << "Failed to register window class\n"; 43 | return -1; 44 | } 45 | // Actually creates the window and returns a handle to it 46 | HWND windowHandle = CreateWindowEx( 47 | WS_EX_OVERLAPPEDWINDOW, 48 | windowClassName, 49 | windowTitle, 50 | WS_OVERLAPPEDWINDOW, 51 | windowLeft, 52 | windowTop, 53 | windowWidth, 54 | windowHeight, 55 | nullptr, 56 | nullptr, 57 | currentInstance, 58 | nullptr); 59 | if (windowHandle == nullptr) 60 | { 61 | std::cerr << "Failed to create Win32 window\n"; 62 | return -1; 63 | } 64 | ShowWindow(windowHandle, SW_NORMAL); 65 | MSG msg = {}; 66 | while (GetMessage(&msg, nullptr, 0, 0) > 0) 67 | { 68 | TranslateMessage(&msg); 69 | DispatchMessage(&msg); 70 | } 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/1-1-1-HelloWindow.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 4 | 5 | 6 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 7 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 8 | 9 | 10 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 11 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 12 | 13 | 14 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 15 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 16 | 17 | 18 | 19 | 20 | Source Files 21 | 22 | 23 | Source Files 24 | 25 | 26 | Source Files 27 | 28 | 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/1-1-1-HelloWindow.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/Application.cpp: -------------------------------------------------------------------------------- 1 | #include "Application.hpp" 2 | 3 | #include 4 | 5 | #include 6 | 7 | Application::Application(const std::string& title) 8 | { 9 | _title = title; 10 | } 11 | 12 | Application::~Application() 13 | { 14 | Application::Cleanup(); 15 | } 16 | 17 | void Application::Run() 18 | { 19 | if (!Initialize()) 20 | { 21 | return; 22 | } 23 | 24 | if (!Load()) 25 | { 26 | return; 27 | } 28 | 29 | while (!glfwWindowShouldClose(_window)) 30 | { 31 | glfwPollEvents(); 32 | Update(); 33 | Render(); 34 | } 35 | } 36 | 37 | // ReSharper disable once CppMemberFunctionMayBeConst 38 | void Application::Cleanup() 39 | { 40 | glfwTerminate(); 41 | } 42 | 43 | bool Application::Initialize() 44 | { 45 | if (!glfwInit()) 46 | { 47 | std::cerr << "GLFW: Failed to initialize\n"; 48 | return false; 49 | } 50 | 51 | GLFWmonitor* primaryMonitor = glfwGetPrimaryMonitor(); 52 | const GLFWvidmode* videoMode = glfwGetVideoMode(primaryMonitor); 53 | _width = static_cast(videoMode->width * 0.9f); 54 | _height = static_cast(videoMode->height * 0.9f); 55 | 56 | glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); 57 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); 58 | _window = glfwCreateWindow( 59 | _width, 60 | _height, 61 | _title.data(), 62 | nullptr, 63 | nullptr); 64 | if (_window == nullptr) 65 | { 66 | std::cerr << "GLFW: Failed to create a window\n"; 67 | Cleanup(); 68 | return false; 69 | } 70 | 71 | const int32_t windowLeft = videoMode->width / 2 - _width / 2; 72 | const int32_t windowTop = videoMode->height / 2 - _height / 2; 73 | glfwSetWindowPos( 74 | _window, 75 | windowLeft, 76 | windowTop); 77 | 78 | return true; 79 | } 80 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/Application.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | // ReSharper disable once CppInconsistentNaming 7 | struct GLFWwindow; 8 | 9 | class Application 10 | { 11 | public: 12 | Application(const std::string& title); 13 | virtual ~Application(); 14 | void Run(); 15 | 16 | protected: 17 | virtual bool Initialize(); 18 | virtual bool Load() = 0; 19 | virtual void Render() = 0; 20 | virtual void Update() = 0; 21 | 22 | private: 23 | virtual void Cleanup(); 24 | 25 | GLFWwindow* _window = nullptr; 26 | int32_t _width = 0; 27 | int32_t _height = 0; 28 | std::string _title; 29 | }; 30 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloWindow/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/Assets/Shaders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloWindow/Assets/Shaders/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-1-HelloWindow/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/HelloWindowApplication.cpp: -------------------------------------------------------------------------------- 1 | #include "HelloWindowApplication.hpp" 2 | 3 | #include 4 | 5 | HelloWindowApplication::HelloWindowApplication(const std::string& title) 6 | : Application(title) 7 | { 8 | } 9 | 10 | bool HelloWindowApplication::Load() 11 | { 12 | return true; 13 | } 14 | 15 | void HelloWindowApplication::Render() 16 | { 17 | } 18 | 19 | void HelloWindowApplication::Update() 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/HelloWindowApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Application.hpp" 4 | 5 | class HelloWindowApplication final : public Application 6 | { 7 | public: 8 | HelloWindowApplication(const std::string& title); 9 | 10 | protected: 11 | bool Load() override; 12 | void Update() override; 13 | void Render() override; 14 | }; 15 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-1-HelloWindow/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "HelloWindowApplication.hpp" 2 | 3 | int main(int argc, char* argv[]) 4 | { 5 | HelloWindowApplication app{ "LearnD3D11 - Hello Window" }; 6 | app.Run(); 7 | } 8 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/1-1-2-HelloD3D11-Raw.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/1-1-2-HelloD3D11-Raw.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Assets/Shaders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Assets/Shaders/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-2-HelloD3D11-Raw/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/1-1-2-HelloD3D11.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/1-1-2-HelloD3D11.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-2-HelloD3D11/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/Assets/Shaders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-2-HelloD3D11/Assets/Shaders/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-2-HelloD3D11/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/HelloD3D11Application.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class HelloD3D11Application final : public Application 10 | { 11 | template 12 | using ComPtr = Microsoft::WRL::ComPtr; 13 | 14 | public: 15 | HelloD3D11Application(const std::string& title); 16 | ~HelloD3D11Application() override; 17 | 18 | protected: 19 | bool Initialize() override; 20 | bool Load() override; 21 | void OnResize( 22 | int32_t width, 23 | int32_t height) override; 24 | void Update() override; 25 | void Render() override; 26 | 27 | private: 28 | bool CreateSwapchainResources(); 29 | void DestroySwapchainResources(); 30 | 31 | ComPtr _device = nullptr; 32 | ComPtr _deviceContext = nullptr; 33 | ComPtr _dxgiFactory = nullptr; 34 | ComPtr _swapChain = nullptr; 35 | ComPtr _renderTarget = nullptr; 36 | }; 37 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-2-HelloD3D11/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "HelloD3D11Application.hpp" 2 | 3 | int main() 4 | { 5 | HelloD3D11Application app{ "LearnD3D11 - Hello D3D11" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/1-1-3-HelloTriangle.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/1-1-3-HelloTriangle.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-3-HelloTriangle/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct PSInput 2 | { 3 | float4 position: SV_Position; 4 | float3 color: COLOR0; 5 | }; 6 | 7 | struct PSOutput 8 | { 9 | float4 color: SV_Target0; 10 | }; 11 | 12 | PSOutput Main(PSInput input) 13 | { 14 | PSOutput output = (PSOutput)0; 15 | output.color = float4(input.color, 1.0); 16 | return output; 17 | } 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 position: POSITION; 4 | float3 color: COLOR0; 5 | }; 6 | 7 | struct VSOutput 8 | { 9 | float4 position: SV_Position; 10 | float3 color: COLOR0; 11 | }; 12 | 13 | VSOutput Main(VSInput input) 14 | { 15 | VSOutput output = (VSOutput)0; 16 | output.position = float4(input.position, 1.0); 17 | output.color = input.color; 18 | return output; 19 | } 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-1-3-HelloTriangle/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/HelloTriangleApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class HelloTriangleApplication final : public Application 10 | { 11 | template 12 | using ComPtr = Microsoft::WRL::ComPtr; 13 | 14 | public: 15 | HelloTriangleApplication(const std::string& title); 16 | ~HelloTriangleApplication() override; 17 | 18 | protected: 19 | bool Initialize() override; 20 | bool Load() override; 21 | void OnResize( 22 | int32_t width, 23 | int32_t height) override; 24 | void Update() override; 25 | void Render() override; 26 | 27 | private: 28 | bool CreateSwapchainResources(); 29 | void DestroySwapchainResources(); 30 | 31 | bool CompileShader( 32 | const std::wstring& fileName, 33 | const std::string& entryPoint, 34 | const std::string& profile, 35 | ComPtr& shaderBlob) const; 36 | [[nodiscard]] ComPtr CreateVertexShader( 37 | const std::wstring& fileName, 38 | ComPtr& vertexShaderBlob) const; 39 | [[nodiscard]] ComPtr CreatePixelShader(const std::wstring& fileName) const; 40 | 41 | ComPtr _device = nullptr; 42 | ComPtr _deviceContext = nullptr; 43 | ComPtr _dxgiFactory = nullptr; 44 | ComPtr _swapChain = nullptr; 45 | ComPtr _renderTarget = nullptr; 46 | ComPtr _triangleVertices = nullptr; 47 | ComPtr _vertexLayout = nullptr; 48 | ComPtr _vertexShader = nullptr; 49 | ComPtr _pixelShader = nullptr; 50 | }; 51 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-1-3-HelloTriangle/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "HelloTriangleApplication.hpp" 2 | 3 | int main() 4 | { 5 | HelloTriangleApplication app{ "LearnD3D11 - Hello Triangle" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/1-2-2-DebugLayer.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/1-2-2-DebugLayer.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-2-2-DebugLayer/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 position: SV_Position; 4 | float3 color: COLOR0; 5 | }; 6 | 7 | float4 Main(VSOutput input): SV_Target 8 | { 9 | return float4(input.color, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 position: POSITION; 4 | float3 color: COLOR0; 5 | }; 6 | 7 | struct VSOutput 8 | { 9 | float4 position: SV_Position; 10 | float3 color: COLOR0; 11 | }; 12 | 13 | VSOutput Main(VSInput input) 14 | { 15 | VSOutput output = (VSOutput)0; 16 | output.position = float4(input.position, 1.0); 17 | output.color = input.color; 18 | return output; 19 | } 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-2-2-DebugLayer/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/DebugLayerApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | #include "ShaderCollection.hpp" 6 | 7 | #include 8 | 9 | #include 10 | 11 | class DebugLayerApplication final : public Application 12 | { 13 | public: 14 | DebugLayerApplication(const std::string& title); 15 | ~DebugLayerApplication() override; 16 | 17 | protected: 18 | bool Initialize() override; 19 | bool Load() override; 20 | void OnResize( 21 | int32_t width, 22 | int32_t height) override; 23 | void Update() override; 24 | void Render() override; 25 | 26 | private: 27 | bool CreateSwapchainResources(); 28 | void DestroySwapchainResources(); 29 | 30 | ShaderCollection _shaderCollection; 31 | 32 | WRL::ComPtr _device = nullptr; 33 | WRL::ComPtr _deviceContext = nullptr; 34 | WRL::ComPtr _dxgiFactory = nullptr; 35 | WRL::ComPtr _swapChain = nullptr; 36 | WRL::ComPtr _renderTarget = nullptr; 37 | WRL::ComPtr _triangleVertices = nullptr; 38 | WRL::ComPtr _debug = nullptr; 39 | }; 40 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "DebugLayerApplication.hpp" 2 | 3 | int main() 4 | { 5 | DebugLayerApplication app{ "LearnD3D11 - Debug Layer" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static UINT GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | WRL::ComPtr _vertexShader = nullptr; 51 | WRL::ComPtr _pixelShader = nullptr; 52 | WRL::ComPtr _inputLayout = nullptr; 53 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 54 | uint32_t _vertexSize = 0; 55 | static std::unordered_map> _layoutMap; 56 | }; 57 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-2-DebugLayer/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor 8 | }; 9 | 10 | using Position = DirectX::XMFLOAT3; 11 | using Color = DirectX::XMFLOAT3; 12 | 13 | struct VertexPositionColor 14 | { 15 | Position position; 16 | Color color; 17 | }; 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/1-2-3-NamingThings.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/1-2-3-NamingThings.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-2-3-NamingThings/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 position: SV_Position; 4 | float3 color: COLOR0; 5 | }; 6 | 7 | float4 Main(VSOutput input): SV_Target 8 | { 9 | return float4(input.color, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 position: POSITION; 4 | float3 color: COLOR0; 5 | }; 6 | 7 | struct VSOutput 8 | { 9 | float4 position: SV_Position; 10 | float3 color: COLOR0; 11 | }; 12 | 13 | VSOutput Main(VSInput input) 14 | { 15 | VSOutput output = (VSOutput)0; 16 | output.position = float4(input.position, 1.0); 17 | output.color = input.color; 18 | return output; 19 | } 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-2-3-NamingThings/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "NamingThingsApplication.hpp" 2 | 3 | int main() 4 | { 5 | NamingThingsApplication app{ "LearnD3D11 - Naming Things" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/NamingThingsApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | #include "ShaderCollection.hpp" 11 | 12 | class NamingThingsApplication final : public Application 13 | { 14 | public: 15 | NamingThingsApplication(const std::string& title); 16 | ~NamingThingsApplication() override; 17 | 18 | protected: 19 | bool Initialize() override; 20 | bool Load() override; 21 | void OnResize( 22 | int32_t width, 23 | int32_t height) override; 24 | void Update() override; 25 | void Render() override; 26 | 27 | private: 28 | bool CreateSwapchainResources(); 29 | void DestroySwapchainResources(); 30 | 31 | WRL::ComPtr _deviceContext = nullptr; 32 | WRL::ComPtr _device = nullptr; 33 | WRL::ComPtr _dxgiFactory = nullptr; 34 | WRL::ComPtr _swapChain = nullptr; 35 | WRL::ComPtr _renderTarget = nullptr; 36 | WRL::ComPtr _triangleVertices = nullptr; 37 | WRL::ComPtr _debug = nullptr; 38 | 39 | ShaderCollection _shaderCollection; 40 | }; 41 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static UINT GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | 51 | WRL::ComPtr _vertexShader = nullptr; 52 | WRL::ComPtr _pixelShader = nullptr; 53 | WRL::ComPtr _inputLayout = nullptr; 54 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 55 | uint32_t _vertexSize = 0; 56 | static std::unordered_map> _layoutMap; 57 | }; 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-2-3-NamingThings/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor 8 | }; 9 | 10 | using Position = DirectX::XMFLOAT3; 11 | using Color = DirectX::XMFLOAT3; 12 | 13 | struct VertexPositionColor 14 | { 15 | Position position; 16 | Color color; 17 | }; 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/1-3-1-RasterizerState.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/1-3-1-RasterizerState.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/Assets/Models/SM_Good_Froge.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-1-RasterizerState/Assets/Models/SM_Good_Froge.fbx -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | }; 6 | 7 | 8 | float4 Main(VSOutput input): SV_Target 9 | { 10 | return float4(input.Color, 1.0f); 11 | } 12 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | }; 6 | 7 | struct VSOutput 8 | { 9 | float4 Position: SV_Position; 10 | float3 Color: COLOR0; 11 | }; 12 | 13 | VSOutput Main(VSInput input) 14 | { 15 | VSOutput output = (VSOutput)0; 16 | output.Position = float4(input.Position, 1.0f); 17 | output.Color = input.Color; 18 | return output; 19 | } 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/Assets/Textures/T_Good_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-1-RasterizerState/Assets/Textures/T_Good_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "RasterizerStateApplication.hpp" 2 | 3 | int main() 4 | { 5 | RasterizerStateApplication app{ "LearnD3D11 - Rasterizer State" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/RasterizerStateApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include "ShaderCollection.hpp" 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | class RasterizerStateApplication final : public Application 14 | { 15 | public: 16 | RasterizerStateApplication(const std::string& title); 17 | ~RasterizerStateApplication() override; 18 | 19 | protected: 20 | bool Initialize() override; 21 | bool Load() override; 22 | void OnResize( 23 | int32_t width, 24 | int32_t height) override; 25 | void Update() override; 26 | void Render() override; 27 | 28 | private: 29 | bool CreateSwapchainResources(); 30 | void DestroySwapchainResources(); 31 | 32 | bool CreateRasterizerStates(); 33 | 34 | enum ConstantBufferType 35 | { 36 | PerApplication, 37 | PerFrame, 38 | PerObject, 39 | NumConstantBufferTypes 40 | }; 41 | 42 | ShaderCollection _shaderCollection; 43 | 44 | WRL::ComPtr _device = nullptr; 45 | WRL::ComPtr _deviceContext = nullptr; 46 | WRL::ComPtr _dxgiFactory = nullptr; 47 | WRL::ComPtr _swapChain = nullptr; 48 | WRL::ComPtr _renderTarget = nullptr; 49 | std::array,6> _triangleVertices; 50 | WRL::ComPtr _debug = nullptr; 51 | 52 | WRL::ComPtr _wireFrameCullBackRasterizerState = nullptr; 53 | WRL::ComPtr _wireFrameCullFrontRasterizerState = nullptr; 54 | WRL::ComPtr _wireFrameCullNoneRasterizerState = nullptr; 55 | 56 | WRL::ComPtr _solidFrameCullBackRasterizerState = nullptr; 57 | WRL::ComPtr _solidFrameCullFrontRasterizerState = nullptr; 58 | WRL::ComPtr _solidFrameCullNoneRasterizerState = nullptr; 59 | }; 60 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static UINT GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | WRL::ComPtr _vertexShader = nullptr; 51 | WRL::ComPtr _pixelShader = nullptr; 52 | WRL::ComPtr _inputLayout = nullptr; 53 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 54 | uint32_t _vertexSize = 0; 55 | static std::unordered_map> _layoutMap; 56 | }; 57 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-1-RasterizerState/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/1-3-2-Texturing.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/1-3-2-Texturing.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | sampler LinearSampler : register(s0); 9 | 10 | Texture2D Texture : register(t0); 11 | 12 | float4 Main(VSOutput input): SV_Target 13 | { 14 | float4 texel = Texture.Sample(LinearSampler, input.Uv); 15 | return float4(input.Color, 0.50f) * texel; 16 | } 17 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | VSOutput Main(VSInput input) 16 | { 17 | VSOutput output = (VSOutput)0; 18 | output.Position = float4(input.Position, 1.0); 19 | output.Color = input.Color; 20 | output.Uv = input.Uv; 21 | return output; 22 | } 23 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Textures/T_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Textures/T_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Textures/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-2-Texturing/Assets/Textures/default.png -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "TexturingApplication.hpp" 2 | 3 | int main() 4 | { 5 | TexturingApplication app{ "LearnD3D11 - Texturing" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static UINT GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | 51 | WRL::ComPtr _vertexShader = nullptr; 52 | WRL::ComPtr _pixelShader = nullptr; 53 | WRL::ComPtr _inputLayout = nullptr; 54 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 55 | uint32_t _vertexSize = 0; 56 | static std::unordered_map> _layoutMap; 57 | }; 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/TexturingApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include "ShaderCollection.hpp" 10 | 11 | class TexturingApplication final : public Application 12 | { 13 | public: 14 | TexturingApplication(const std::string& title); 15 | ~TexturingApplication() override; 16 | 17 | protected: 18 | bool Initialize() override; 19 | bool Load() override; 20 | void OnResize( 21 | int32_t width, 22 | int32_t height) override; 23 | void Update() override; 24 | void Render() override; 25 | 26 | private: 27 | bool CreateSwapchainResources(); 28 | void DestroySwapchainResources(); 29 | 30 | 31 | WRL::ComPtr _device = nullptr; 32 | WRL::ComPtr _deviceContext = nullptr; 33 | WRL::ComPtr _dxgiFactory = nullptr; 34 | WRL::ComPtr _swapChain = nullptr; 35 | WRL::ComPtr _renderTarget = nullptr; 36 | WRL::ComPtr _rasterState = nullptr; 37 | WRL::ComPtr _triangleVertices = nullptr; 38 | WRL::ComPtr _debug = nullptr; 39 | 40 | WRL::ComPtr _linearSamplerState = nullptr; 41 | WRL::ComPtr _textureSrv = nullptr; 42 | WRL::ComPtr _fallbackTextureSrv = nullptr; 43 | 44 | ShaderCollection _shaderCollection; 45 | }; 46 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-2-Texturing/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/1-3-3-SettingUp3DRendering.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | Header Files 24 | 25 | 26 | Header Files 27 | 28 | 29 | Header Files 30 | 31 | 32 | Header Files 33 | 34 | 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/1-3-3-SettingUp3DRendering.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Models/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Models/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | sampler LinearSampler : register(s0); 9 | 10 | Texture2D Texture : register(t0); 11 | 12 | float4 Main(VSOutput input): SV_Target 13 | { 14 | float4 texel = Texture.Sample(LinearSampler, input.Uv); 15 | return float4(input.Color, 0.50f) * texel; 16 | } 17 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | cbuffer PerFrame : register(b0) 16 | { 17 | matrix viewprojection; 18 | }; 19 | 20 | cbuffer PerObject : register(b1) 21 | { 22 | matrix modelmatrix; 23 | }; 24 | 25 | VSOutput Main(VSInput input) 26 | { 27 | VSOutput output = (VSOutput)0; 28 | 29 | matrix world = mul(viewprojection, modelmatrix); 30 | output.Position = mul(world, float4(input.Position, 1.0)); 31 | output.Color = input.Color; 32 | output.Uv = input.Uv; 33 | return output; 34 | } 35 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Textures/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Textures/.gitkeep -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Textures/T_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Textures/T_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Textures/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Assets/Textures/default.png -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Setting3DApplication.hpp" 2 | 3 | int main() 4 | { 5 | Setting3DApplication app{ "LearnD3D11 - Setting up 3D Rendering" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/Setting3DApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include "ShaderCollection.hpp" 11 | 12 | struct PerFrameConstantBuffer 13 | { 14 | DirectX::XMFLOAT4X4 viewProjectionMatrix; 15 | }; 16 | 17 | struct PerObjectConstantBuffer 18 | { 19 | DirectX::XMFLOAT4X4 modelMatrix; 20 | }; 21 | 22 | 23 | class Setting3DApplication final : public Application 24 | { 25 | public: 26 | Setting3DApplication(const std::string& title); 27 | ~Setting3DApplication() override; 28 | 29 | protected: 30 | bool Initialize() override; 31 | bool Load() override; 32 | void OnResize( 33 | int32_t width, 34 | int32_t height) override; 35 | void Update() override; 36 | void Render() override; 37 | 38 | private: 39 | void CreateConstantBuffers(); 40 | bool CreateSwapchainResources(); 41 | void DestroySwapchainResources(); 42 | 43 | WRL::ComPtr _device = nullptr; 44 | WRL::ComPtr _deviceContext = nullptr; 45 | WRL::ComPtr _dxgiFactory = nullptr; 46 | WRL::ComPtr _swapChain = nullptr; 47 | WRL::ComPtr _renderTarget = nullptr; 48 | WRL::ComPtr _rasterState = nullptr; 49 | WRL::ComPtr _triangleVertices = nullptr; 50 | WRL::ComPtr _debug = nullptr; 51 | 52 | WRL::ComPtr _linearSamplerState = nullptr; 53 | WRL::ComPtr _textureSrv = nullptr; 54 | WRL::ComPtr _fallbackTextureSrv = nullptr; 55 | 56 | WRL::ComPtr _perFrameConstantBuffer = nullptr; 57 | WRL::ComPtr _perObjectConstantBuffer = nullptr; 58 | 59 | ShaderCollection _shaderCollection; 60 | 61 | PerFrameConstantBuffer _perFrameConstantBufferData{}; 62 | PerObjectConstantBuffer _perObjectConstantBufferData{}; 63 | }; 64 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | 24 | static UINT GetLayoutByteSize(VertexType vertexType); 25 | 26 | void ApplyToContext(ID3D11DeviceContext* context); 27 | void Destroy(); 28 | 29 | private: 30 | 31 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 32 | ID3D11Device* device, 33 | const std::wstring& filePath, 34 | WRL::ComPtr& vertexShaderBlob); 35 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 36 | ID3D11Device* device, 37 | const std::wstring& filePath); 38 | 39 | static bool CreateInputLayout( 40 | ID3D11Device* device, 41 | const VertexType layoutInfo, 42 | const WRL::ComPtr& vertexBlob, 43 | WRL::ComPtr& inputLayout); 44 | 45 | static bool CompileShader( 46 | const std::wstring& filePath, 47 | const std::string& entryPoint, 48 | const std::string& profile, 49 | WRL::ComPtr& shaderBlob); 50 | 51 | 52 | WRL::ComPtr _vertexShader = nullptr; 53 | WRL::ComPtr _pixelShader = nullptr; 54 | WRL::ComPtr _inputLayout = nullptr; 55 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 56 | uint32_t _vertexSize = 0; 57 | static std::unordered_map> _layoutMap; 58 | }; 59 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-3-SettingUp3DRendering/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/1-3-4-3DRendering.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {65594d11-0ce4-46ca-954c-37cfb4e90093} 6 | 7 | 8 | {bc1b63d8-0a47-4d97-ad71-b603d5a65214} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Assets\Shaders 25 | 26 | 27 | Assets\Shaders 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/1-3-4-3DRendering.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/3DRenderingApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include "ShaderCollection.hpp" 11 | 12 | struct PerFrameConstantBuffer 13 | { 14 | DirectX::XMFLOAT4X4 viewProjectionMatrix; 15 | }; 16 | 17 | struct PerObjectConstantBuffer 18 | { 19 | DirectX::XMFLOAT4X4 modelMatrix; 20 | }; 21 | 22 | 23 | class Rendering3DApplication final : public Application 24 | { 25 | public: 26 | Rendering3DApplication(const std::string& title); 27 | ~Rendering3DApplication() override; 28 | 29 | protected: 30 | bool Initialize() override; 31 | bool Load() override; 32 | void OnResize( 33 | int32_t width, 34 | int32_t height) override; 35 | void Update() override; 36 | void Render() override; 37 | 38 | private: 39 | 40 | void CreateRasterState(); 41 | void CreateDepthStencilView(); 42 | void CreateDepthState(); 43 | void CreateConstantBuffers(); 44 | bool CreateSwapchainResources(); 45 | void DestroySwapchainResources(); 46 | 47 | WRL::ComPtr _device = nullptr; 48 | WRL::ComPtr _deviceContext = nullptr; 49 | WRL::ComPtr _dxgiFactory = nullptr; 50 | WRL::ComPtr _swapChain = nullptr; 51 | WRL::ComPtr _renderTarget = nullptr; 52 | WRL::ComPtr _depthTarget = nullptr; 53 | WRL::ComPtr _rasterState = nullptr; 54 | WRL::ComPtr _depthState = nullptr; 55 | WRL::ComPtr _cubeVertices = nullptr; 56 | WRL::ComPtr _cubeIndices = nullptr; 57 | WRL::ComPtr _debug = nullptr; 58 | 59 | WRL::ComPtr _linearSamplerState = nullptr; 60 | WRL::ComPtr _textureSrv = nullptr; 61 | WRL::ComPtr _fallbackTextureSrv = nullptr; 62 | 63 | WRL::ComPtr _perFrameConstantBuffer = nullptr; 64 | WRL::ComPtr _perObjectConstantBuffer = nullptr; 65 | 66 | ShaderCollection _shaderCollection; 67 | 68 | PerFrameConstantBuffer _perFrameConstantBufferData{}; 69 | PerObjectConstantBuffer _perObjectConstantBufferData{}; 70 | }; 71 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | float4 Main(VSOutput input): SV_Target 9 | { 10 | return input.Color.xyzz; 11 | } 12 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | cbuffer PerFrame : register(b0) 16 | { 17 | matrix viewprojection; 18 | }; 19 | 20 | cbuffer PerObject : register(b1) 21 | { 22 | matrix modelmatrix; 23 | }; 24 | 25 | VSOutput Main(VSInput input) 26 | { 27 | VSOutput output = (VSOutput)0; 28 | 29 | matrix world = mul(viewprojection, modelmatrix); 30 | output.Position = mul(world, float4(input.Position, 1.0)); 31 | output.Color = input.Color; 32 | output.Uv = input.Uv; 33 | return output; 34 | } 35 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/Assets/Textures/T_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-4-3DRendering/Assets/Textures/T_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/Assets/Textures/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-4-3DRendering/Assets/Textures/default.png -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "3DRenderingApplication.hpp" 2 | 3 | int main() 4 | { 5 | Rendering3DApplication app{ "LearnD3D11 - 3D Rendering" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static UINT GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | 51 | WRL::ComPtr _vertexShader = nullptr; 52 | WRL::ComPtr _pixelShader = nullptr; 53 | WRL::ComPtr _inputLayout = nullptr; 54 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 55 | uint32_t _vertexSize = 0; 56 | static std::unordered_map> _layoutMap; 57 | }; 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-4-3DRendering/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/1-3-5-Models-Refactored.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | Header Files 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/1-3-5-Models-Refactored.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Assets/Models/SM_Good_Froge.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-5-Models-Refactored/Assets/Models/SM_Good_Froge.fbx -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | sampler LinearSampler : register(s0); 9 | 10 | Texture2D Texture : register(t0); 11 | 12 | float4 Main(VSOutput input): SV_Target 13 | { 14 | float4 texel = Texture.Sample(LinearSampler, input.Uv); 15 | //return float4(input.Color, 1.0f) + 0.5 * texel; 16 | return texel; 17 | } 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | cbuffer PerApplication 16 | { 17 | row_major matrix ProjectionMatrix; 18 | } 19 | 20 | cbuffer PerFrame 21 | { 22 | row_major matrix ViewMatrix; 23 | } 24 | 25 | cbuffer PerObject 26 | { 27 | row_major matrix WorldMatrix; 28 | } 29 | 30 | VSOutput Main(VSInput input) 31 | { 32 | const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix)); 33 | 34 | VSOutput output = (VSOutput)0; 35 | output.Position = mul(float4(input.Position, 1.0f), modelViewProjection); 36 | output.Color = input.Color; 37 | output.Uv = input.Uv; 38 | return output; 39 | } 40 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Assets/Textures/T_Good_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-5-Models-Refactored/Assets/Textures/T_Good_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/DeviceContext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | class Pipeline; 11 | 12 | class DeviceContext 13 | { 14 | public: 15 | DeviceContext(WRL::ComPtr&& deviceContext); 16 | 17 | void Clear( 18 | ID3D11RenderTargetView* renderTarget, 19 | float clearColor[4]) const; 20 | void SetPipeline(const Pipeline* pipeline); 21 | void SetVertexBuffer( 22 | ID3D11Buffer* vertexBuffer, 23 | uint32_t vertexOffset); 24 | void SetIndexBuffer( 25 | ID3D11Buffer* indexBuffer, 26 | uint32_t indexOffset); 27 | void UpdateSubresource(ID3D11Buffer* buffer, const void* data) const; 28 | 29 | void Draw() const; 30 | void DrawIndexed() const; 31 | void Flush() const; 32 | 33 | private: 34 | uint32_t _drawVertices; 35 | uint32_t _drawIndices; 36 | const Pipeline* _activePipeline; 37 | WRL::ComPtr _deviceContext; 38 | }; 39 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/LoadingMeshesApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | class Pipeline; 12 | class PipelineFactory; 13 | class DeviceContext; 14 | class TextureFactory; 15 | class ModelFactory; 16 | 17 | class LoadingMeshesApplication final : public Application 18 | { 19 | public: 20 | LoadingMeshesApplication(const std::string& title); 21 | ~LoadingMeshesApplication() override; 22 | 23 | protected: 24 | bool Initialize() override; 25 | bool Load() override; 26 | void OnResize( 27 | int32_t width, 28 | int32_t height) override; 29 | void Update() override; 30 | void Render() override; 31 | 32 | private: 33 | bool CreateSwapchainResources(); 34 | void DestroySwapchainResources(); 35 | 36 | enum ConstantBufferType 37 | { 38 | PerApplication, 39 | PerFrame, 40 | PerObject, 41 | NumConstantBufferTypes 42 | }; 43 | 44 | std::unique_ptr _pipeline = nullptr; 45 | std::unique_ptr _deviceContext = nullptr; 46 | std::unique_ptr _pipelineFactory = nullptr; 47 | std::unique_ptr _textureFactory = nullptr; 48 | std::unique_ptr _modelFactory = nullptr; 49 | 50 | WRL::ComPtr _device = nullptr; 51 | WRL::ComPtr _dxgiFactory = nullptr; 52 | WRL::ComPtr _swapChain = nullptr; 53 | WRL::ComPtr _renderTarget = nullptr; 54 | WRL::ComPtr _modelVertices = nullptr; 55 | WRL::ComPtr _modelIndices = nullptr; 56 | WRL::ComPtr _debug = nullptr; 57 | 58 | WRL::ComPtr _linearSamplerState = nullptr; 59 | WRL::ComPtr _textureSrv = nullptr; 60 | WRL::ComPtr _constantBuffers[NumConstantBufferTypes]; 61 | 62 | DirectX::XMMATRIX _projectionMatrix = {}; 63 | DirectX::XMMATRIX _viewMatrix = {}; 64 | DirectX::XMMATRIX _worldMatrix = {}; 65 | 66 | uint32_t _modelVertexCount = 0; 67 | uint32_t _modelIndexCount = 0; 68 | }; 69 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "LoadingMeshesApplication.hpp" 2 | 3 | int main() 4 | { 5 | LoadingMeshesApplication app{ "LearnD3D11 - Loading Meshes" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/ModelFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Definitions.hpp" 6 | 7 | #include 8 | 9 | class ModelFactory 10 | { 11 | public: 12 | ModelFactory(const WRL::ComPtr& device); 13 | 14 | bool LoadModel( 15 | const std::string& filePath, 16 | WRL::ComPtr& vertexBuffer, 17 | uint32_t* vertexCount, 18 | WRL::ComPtr& indexBuffer, 19 | uint32_t* indexCount); 20 | 21 | private: 22 | WRL::ComPtr _device = nullptr; 23 | }; 24 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Pipeline.cpp: -------------------------------------------------------------------------------- 1 | #include "Pipeline.hpp" 2 | 3 | void Pipeline::BindTexture(uint32_t slotIndex, ID3D11ShaderResourceView* texture) 4 | { 5 | ResourceDescriptor descriptor = {}; 6 | descriptor.SlotIndex = slotIndex; 7 | descriptor.Type = ResourceType::Texture; 8 | _resources[descriptor] = static_cast(texture); 9 | } 10 | 11 | void Pipeline::BindSampler(uint32_t slotIndex, ID3D11SamplerState* sampler) 12 | { 13 | ResourceDescriptor descriptor = {}; 14 | descriptor.SlotIndex = slotIndex; 15 | descriptor.Type = ResourceType::Sampler; 16 | _resources[descriptor] = static_cast(sampler); 17 | } 18 | 19 | void Pipeline::BindVertexStageConstantBuffer(uint32_t slotIndex, ID3D11Buffer* buffer) 20 | { 21 | ResourceDescriptor descriptor = {}; 22 | descriptor.SlotIndex = slotIndex; 23 | descriptor.Stage = ResourceStage::VertexStage; 24 | descriptor.Type = ResourceType::Buffer; 25 | _resources[descriptor] = static_cast(buffer); 26 | } 27 | 28 | void Pipeline::SetViewport( 29 | const float left, 30 | const float top, 31 | const float width, 32 | const float height) 33 | { 34 | _viewport.TopLeftX = left; 35 | _viewport.TopLeftY = top; 36 | _viewport.Width = width; 37 | _viewport.Height = height; 38 | _viewport.MinDepth = 0.0f; 39 | _viewport.MaxDepth = 1.0f; 40 | } 41 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/Pipeline.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include "ResourceDescriptor.hpp" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | class Pipeline 12 | { 13 | public: 14 | friend class PipelineFactory; 15 | friend class DeviceContext; 16 | 17 | void BindTexture(uint32_t slotIndex, ID3D11ShaderResourceView* texture); 18 | void BindSampler(uint32_t slotIndex, ID3D11SamplerState* sampler); 19 | void BindVertexStageConstantBuffer(uint32_t slotIndex, ID3D11Buffer* buffer); 20 | void SetViewport( 21 | float left, 22 | float top, 23 | float width, 24 | float height); 25 | 26 | private: 27 | WRL::ComPtr _vertexShader = nullptr; 28 | WRL::ComPtr _pixelShader = nullptr; 29 | WRL::ComPtr _inputLayout = nullptr; 30 | std::unordered_map _resources; 31 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 32 | uint32_t _vertexSize = 0; 33 | D3D11_VIEWPORT _viewport = {}; 34 | }; 35 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/PipelineFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include "Pipeline.hpp" 5 | #include "VertexType.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | struct PipelineDescriptor 12 | { 13 | std::wstring VertexFilePath; 14 | std::wstring PixelFilePath; 15 | VertexType VertexType; 16 | }; 17 | 18 | class PipelineFactory 19 | { 20 | public: 21 | PipelineFactory(const WRL::ComPtr& device); 22 | 23 | bool CreatePipeline( 24 | const PipelineDescriptor& settings, 25 | std::unique_ptr& pipeline); 26 | 27 | private: 28 | static size_t GetLayoutByteSize(VertexType vertexType); 29 | 30 | [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | const std::wstring& filePath, 32 | WRL::ComPtr& vertexShaderBlob) const; 33 | [[nodiscard]] WRL::ComPtr CreatePixelShader(const std::wstring& filePath) const; 34 | 35 | bool CreateInputLayout( 36 | VertexType layoutInfo, 37 | const WRL::ComPtr& vertexBlob, 38 | WRL::ComPtr& inputLayout); 39 | 40 | bool CompileShader( 41 | const std::wstring& filePath, 42 | const std::string& entryPoint, 43 | const std::string& profile, 44 | WRL::ComPtr& shaderBlob) const; 45 | 46 | WRL::ComPtr _device = nullptr; 47 | std::unordered_map> _layoutMap; 48 | }; 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/ResourceDescriptor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | enum class ResourceType : uint32_t 7 | { 8 | Texture, 9 | Sampler, 10 | Buffer 11 | }; 12 | 13 | enum class ResourceStage : uint32_t 14 | { 15 | VertexStage, 16 | PixelStage 17 | }; 18 | 19 | struct ResourceDescriptor 20 | { 21 | ResourceType Type; 22 | ResourceStage Stage; 23 | uint32_t SlotIndex; 24 | }; 25 | 26 | namespace std 27 | { 28 | template <> 29 | struct hash 30 | { 31 | size_t operator()(const ResourceDescriptor& resource) const noexcept 32 | { 33 | const hash hash; 34 | return hash(static_cast(resource.SlotIndex) << 32) ^ hash(static_cast(resource.Type)); 35 | } 36 | }; 37 | 38 | template <> 39 | struct equal_to 40 | { 41 | bool operator()( 42 | const ResourceDescriptor& lhs, 43 | const ResourceDescriptor& rhs) const noexcept 44 | { 45 | return lhs.SlotIndex == rhs.SlotIndex && lhs.Type == rhs.Type; 46 | } 47 | }; 48 | } // namespace std 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/TextureFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "TextureFactory.hpp" 2 | 3 | #include 4 | 5 | #include 6 | 7 | TextureFactory::TextureFactory(const WRL::ComPtr& device) 8 | { 9 | _device = device; 10 | } 11 | 12 | bool TextureFactory::CreateShaderResourceViewFromFile( 13 | const std::wstring& filePath, 14 | WRL::ComPtr& shaderResourceView) const 15 | { 16 | DirectX::TexMetadata metaData = {}; 17 | DirectX::ScratchImage scratchImage; 18 | if (FAILED(DirectX::LoadFromDDSFile(filePath.data(), DirectX::DDS_FLAGS_NONE, &metaData, scratchImage))) 19 | { 20 | std::cout << "DXTEX: Failed to load image\n"; 21 | return false; 22 | } 23 | 24 | WRL::ComPtr texture = nullptr; 25 | if (FAILED(DirectX::CreateTexture( 26 | _device.Get(), 27 | scratchImage.GetImages(), 28 | scratchImage.GetImageCount(), 29 | metaData, 30 | &texture))) 31 | { 32 | std::cout << "DXTEX: Failed to create texture out of image\n"; 33 | scratchImage.Release(); 34 | return false; 35 | } 36 | 37 | if (FAILED(DirectX::CreateShaderResourceView( 38 | _device.Get(), 39 | scratchImage.GetImages(), 40 | scratchImage.GetImageCount(), 41 | metaData, 42 | &shaderResourceView))) 43 | { 44 | std::cout << "DXTEX: Failed to create shader resource view out of texture\n"; 45 | scratchImage.Release(); 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/TextureFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | class TextureFactory 9 | { 10 | public: 11 | TextureFactory(const WRL::ComPtr& device); 12 | 13 | bool CreateShaderResourceViewFromFile( 14 | const std::wstring& filePath, 15 | WRL::ComPtr& shaderResourceView) const; 16 | 17 | private: 18 | WRL::ComPtr _device = nullptr; 19 | }; 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models-Refactored/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/1-3-5-Models.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/1-3-5-Models.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/Assets/Models/SM_Good_Froge.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-5-Models/Assets/Models/SM_Good_Froge.fbx -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | sampler LinearSampler : register(s0); 9 | 10 | Texture2D Texture : register(t0); 11 | 12 | float4 Main(VSOutput input): SV_Target 13 | { 14 | float4 texel = Texture.Sample(LinearSampler, input.Uv); 15 | //return float4(input.Color, 1.0f) + 0.5 * texel; 16 | return texel; 17 | } 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | cbuffer PerApplication : register(b0) 16 | { 17 | row_major matrix ProjectionMatrix; 18 | } 19 | 20 | cbuffer PerFrame : register(b1) 21 | { 22 | row_major matrix ViewMatrix; 23 | } 24 | 25 | cbuffer PerObject : register(b2) 26 | { 27 | row_major matrix WorldMatrix; 28 | } 29 | 30 | VSOutput Main(VSInput input) 31 | { 32 | const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix)); 33 | 34 | VSOutput output = (VSOutput)0; 35 | output.Position = mul(float4(input.Position, 1.0f), modelViewProjection); 36 | output.Color = input.Color; 37 | output.Uv = input.Uv; 38 | return output; 39 | } 40 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/Assets/Textures/T_Good_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-5-Models/Assets/Textures/T_Good_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/LoadingMeshesApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | class Pipeline; 13 | class PipelineFactory; 14 | class DeviceContext; 15 | class TextureFactory; 16 | 17 | class LoadingMeshesApplication final : public Application 18 | { 19 | public: 20 | LoadingMeshesApplication(const std::string& title); 21 | ~LoadingMeshesApplication() override; 22 | 23 | protected: 24 | bool Initialize() override; 25 | bool Load() override; 26 | void OnResize( 27 | int32_t width, 28 | int32_t height) override; 29 | void Update() override; 30 | void Render() override; 31 | 32 | private: 33 | bool CreateSwapchainResources(); 34 | void DestroySwapchainResources(); 35 | 36 | bool LoadModel(const std::string& filePath); 37 | 38 | enum ConstantBufferType 39 | { 40 | PerApplication, 41 | PerFrame, 42 | PerObject, 43 | NumConstantBufferTypes 44 | }; 45 | 46 | std::unique_ptr _pipeline = nullptr; 47 | std::unique_ptr _deviceContext = nullptr; 48 | std::unique_ptr _pipelineFactory = nullptr; 49 | std::unique_ptr _textureFactory = nullptr; 50 | 51 | WRL::ComPtr _device = nullptr; 52 | WRL::ComPtr _dxgiFactory = nullptr; 53 | WRL::ComPtr _swapChain = nullptr; 54 | WRL::ComPtr _renderTarget = nullptr; 55 | WRL::ComPtr _modelVertices = nullptr; 56 | WRL::ComPtr _modelIndices = nullptr; 57 | WRL::ComPtr _debug = nullptr; 58 | 59 | WRL::ComPtr _linearSamplerState = nullptr; 60 | WRL::ComPtr _textureSrv = nullptr; 61 | 62 | WRL::ComPtr _constantBuffers[NumConstantBufferTypes]; 63 | DirectX::XMMATRIX _projectionMatrix = DirectX::XMMATRIX(); 64 | DirectX::XMMATRIX _viewMatrix = DirectX::XMMATRIX(); 65 | DirectX::XMMATRIX _worldMatrix = DirectX::XMMATRIX(); 66 | 67 | uint32_t _modelVertexCount = 0; 68 | uint32_t _modelIndexCount = 0; 69 | }; 70 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "LoadingMeshesApplication.hpp" 2 | 3 | int main() 4 | { 5 | LoadingMeshesApplication app{ "LearnD3D11 - Loading Meshes" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/ResourceDescriptor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | enum class ResourceType : uint32_t 7 | { 8 | Texture, 9 | Sampler, 10 | Buffer 11 | }; 12 | 13 | enum class ResourceStage : uint32_t 14 | { 15 | VertexStage, 16 | PixelStage 17 | }; 18 | 19 | struct ResourceDescriptor 20 | { 21 | ResourceType Type; 22 | ResourceStage Stage; 23 | uint32_t SlotIndex; 24 | }; 25 | 26 | namespace std 27 | { 28 | template <> 29 | struct hash 30 | { 31 | size_t operator()(const ResourceDescriptor& resource) const noexcept 32 | { 33 | const hash hash; 34 | return hash(static_cast(resource.SlotIndex) << 32) ^ hash(static_cast(resource.Type)); 35 | } 36 | }; 37 | 38 | template <> 39 | struct equal_to 40 | { 41 | bool operator()( 42 | const ResourceDescriptor& lhs, 43 | const ResourceDescriptor& rhs) const noexcept 44 | { 45 | return lhs.SlotIndex == rhs.SlotIndex && lhs.Type == rhs.Type; 46 | } 47 | }; 48 | } // namespace std 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static size_t GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | 51 | WRL::ComPtr _vertexShader = nullptr; 52 | WRL::ComPtr _pixelShader = nullptr; 53 | WRL::ComPtr _inputLayout = nullptr; 54 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 55 | uint32_t _vertexSize = 0; 56 | static std::unordered_map> _layoutMap; 57 | }; 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/TextureFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "TextureFactory.hpp" 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | #if defined(_DEBUG) 9 | #pragma comment(lib, "FreeImageLibd.lib") 10 | #else 11 | #pragma comment(lib, "FreeImageLib.lib") 12 | #endif 13 | 14 | TextureFactory::TextureFactory(const WRL::ComPtr& device) 15 | { 16 | _device = device; 17 | } 18 | 19 | bool TextureFactory::CreateShaderResourceViewFromFile( 20 | const std::wstring& filePath, 21 | WRL::ComPtr& shaderResourceView) const 22 | { 23 | DirectX::TexMetadata metaData = {}; 24 | DirectX::ScratchImage scratchImage; 25 | if (FAILED(DirectX::LoadFromDDSFile(filePath.data(), DirectX::DDS_FLAGS_NONE, &metaData, scratchImage))) 26 | { 27 | std::cerr << "DXTEX: Failed to load image\n"; 28 | return false; 29 | } 30 | 31 | WRL::ComPtr texture = nullptr; 32 | if (FAILED(DirectX::CreateTexture( 33 | _device.Get(), 34 | scratchImage.GetImages(), 35 | scratchImage.GetImageCount(), 36 | metaData, 37 | &texture))) 38 | { 39 | std::cerr << "DXTEX: Failed to create texture out of image\n"; 40 | scratchImage.Release(); 41 | return false; 42 | } 43 | 44 | if (FAILED(DirectX::CreateShaderResourceView( 45 | _device.Get(), 46 | scratchImage.GetImages(), 47 | scratchImage.GetImageCount(), 48 | metaData, 49 | &shaderResourceView))) 50 | { 51 | std::cerr << "DXTEX: Failed to create shader resource view out of texture\n"; 52 | scratchImage.Release(); 53 | return false; 54 | } 55 | 56 | return true; 57 | } 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/TextureFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | class TextureFactory 9 | { 10 | public: 11 | TextureFactory(const WRL::ComPtr& device); 12 | 13 | bool CreateShaderResourceViewFromFile( 14 | const std::wstring& filePath, 15 | WRL::ComPtr& shaderResourceView) const; 16 | 17 | private: 18 | WRL::ComPtr _device = nullptr; 19 | }; 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-5-Models/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/1-3-6-Camera.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/ApplicationWithInput.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | struct GLFWwindow; 12 | 13 | class ApplicationWithInput : public Application 14 | { 15 | public: 16 | ApplicationWithInput(const std::string& title); 17 | virtual ~ApplicationWithInput(); 18 | 19 | protected: 20 | void OnKey( 21 | int32_t key, 22 | int32_t action); 23 | void OnMouseButton( 24 | int32_t button, 25 | int32_t action); 26 | void OnMouseMove( 27 | float x, 28 | float y); 29 | 30 | virtual bool Initialize() override; 31 | virtual void Cleanup() override; 32 | void Close(); 33 | virtual void Update() override; 34 | 35 | [[nodiscard]] bool IsButtonPressed(int32_t button) const; 36 | [[nodiscard]] bool IsButtonDown(int32_t button) const; 37 | [[nodiscard]] bool IsButtonUp(int32_t button) const; 38 | [[nodiscard]] bool IsKeyDown(int32_t key) const; 39 | [[nodiscard]] bool IsKeyPressed(int32_t key) const; 40 | [[nodiscard]] bool IsKeyUp(int32_t key) const; 41 | 42 | DirectX::XMFLOAT2 DeltaPosition = { 0.0f, 0.0f }; 43 | DirectX::XMFLOAT2 CursorPosition = { 0.0f, 0.0f }; 44 | 45 | private: 46 | static void HandleResize( 47 | GLFWwindow* window, 48 | int32_t width, 49 | int32_t height); 50 | 51 | static void HandleKeyboard( 52 | GLFWwindow* window, 53 | int32_t key, 54 | int32_t scanCode, 55 | int32_t action, 56 | int32_t modifier); 57 | static void HandleMouseButton( 58 | GLFWwindow* window, 59 | int32_t button, 60 | int32_t action, 61 | int32_t modifiers); 62 | static void HandleMouseMovement( 63 | GLFWwindow* window, 64 | double x, 65 | double y); 66 | 67 | void UpdateInput( 68 | float centerX, 69 | float centerY); 70 | 71 | std::array _keys{}; 72 | std::array _buttons{}; 73 | bool _isCaptured = false; 74 | }; 75 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Assets/Models/SM_Deccer_Cubes_Merged_Texture_Atlas.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-6-Camera/Assets/Models/SM_Deccer_Cubes_Merged_Texture_Atlas.fbx -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | sampler LinearSampler : register(s0); 9 | 10 | Texture2D Texture : register(t0); 11 | 12 | float4 Main(VSOutput input): SV_Target 13 | { 14 | float4 texel = Texture.Sample(LinearSampler, input.Uv); 15 | //return float4(input.Color, 1.0f) + 0.5 * texel; 16 | return texel; 17 | } 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | cbuffer CameraBuffer 16 | { 17 | row_major matrix ProjectionMatrix; 18 | row_major matrix ViewMatrix; 19 | } 20 | 21 | cbuffer Object 22 | { 23 | row_major matrix WorldMatrix; 24 | }; 25 | 26 | VSOutput Main(VSInput input) 27 | { 28 | const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix)); 29 | 30 | VSOutput output = (VSOutput)0; 31 | output.Position = mul(float4(input.Position, 1.0f), modelViewProjection); 32 | output.Color = input.Color; 33 | output.Uv = input.Uv; 34 | return output; 35 | } 36 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Assets/Textures/T_Atlas.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-6-Camera/Assets/Textures/T_Atlas.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Camera.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct CameraConstants 6 | { 7 | DirectX::XMFLOAT4X4 ProjectionMatrix; 8 | DirectX::XMFLOAT4X4 ViewMatrix; 9 | }; 10 | 11 | class Camera 12 | { 13 | public: 14 | virtual void Resize( 15 | int32_t width, 16 | int32_t height) 17 | = 0; 18 | 19 | void Update(); 20 | 21 | void SetPosition(const DirectX::XMFLOAT3& position); 22 | void SetDirection(const DirectX::XMFLOAT3& direction); 23 | void SetUp(const DirectX::XMFLOAT3& up); 24 | 25 | void Move(float speed); 26 | void Slide(float speed); 27 | void Lift(float speed); 28 | 29 | void AddYaw(float yawInDegrees); 30 | void AddPitch(float pitchInDegrees); 31 | 32 | [[nodiscard]] DirectX::XMFLOAT4X4 GetViewMatrix(); 33 | [[nodiscard]] DirectX::XMFLOAT4X4 GetProjectionMatrix(); 34 | [[nodiscard]] CameraConstants& GetCameraConstants(); 35 | 36 | protected: 37 | Camera( 38 | float nearPlane, 39 | float farPlane); 40 | 41 | virtual void UpdateProjectionMatrix() = 0; 42 | 43 | float _nearPlane = 0.0f; 44 | float _farPlane = 0.0f; 45 | 46 | DirectX::XMFLOAT4X4 _projectionMatrix = DirectX::XMFLOAT4X4(); 47 | DirectX::XMFLOAT4X4 _viewMatrix = DirectX::XMFLOAT4X4(); 48 | CameraConstants _cameraConstants = {}; 49 | 50 | private: 51 | void UpdateVectors(); 52 | void UpdateViewMatrix(); 53 | 54 | DirectX::XMFLOAT3 _position = {}; 55 | DirectX::XMFLOAT3 _direction = {}; 56 | DirectX::XMFLOAT3 _up = {}; 57 | DirectX::XMFLOAT3 _right = {}; 58 | float _pitch = 0.0f; 59 | float _yaw = -90.0f; 60 | }; 61 | 62 | class PerspectiveCamera final : public Camera 63 | { 64 | public: 65 | PerspectiveCamera( 66 | float fieldOfViewInDegrees, 67 | int32_t width, 68 | int32_t height, 69 | float nearPlane, 70 | float farPlane); 71 | 72 | void Resize( 73 | int32_t width, 74 | int32_t height) override; 75 | 76 | protected: 77 | void UpdateProjectionMatrix() override; 78 | 79 | private: 80 | float _fieldOfViewInRadians = 0.0f; 81 | float _width = 0.0f; 82 | float _height = 0.0f; 83 | }; 84 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/DeviceContext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | class Pipeline; 11 | 12 | class DeviceContext 13 | { 14 | public: 15 | DeviceContext( 16 | const WRL::ComPtr& device, 17 | WRL::ComPtr&& deviceContext); 18 | ~DeviceContext(); 19 | 20 | void Clear( 21 | ID3D11RenderTargetView* renderTarget, 22 | float clearColor[4], 23 | ID3D11DepthStencilView* depthStencilView, 24 | float clearDepth) const; 25 | void SetPipeline(const Pipeline* pipeline); 26 | void SetVertexBuffer( 27 | ID3D11Buffer* vertexBuffer, 28 | uint32_t vertexOffset); 29 | void SetIndexBuffer( 30 | ID3D11Buffer* indexBuffer, 31 | uint32_t indexOffset); 32 | void UpdateSubresource(ID3D11Buffer* buffer, const void* data) const; 33 | void Draw() const; 34 | void DrawIndexed() const; 35 | void Flush() const; 36 | 37 | private: 38 | uint32_t _drawVertices; 39 | uint32_t _drawIndices; 40 | const Pipeline* _activePipeline; 41 | WRL::ComPtr _deviceContext; 42 | }; 43 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "CameraApplication.hpp" 2 | 3 | int main() 4 | { 5 | CameraApplication app{ "LearnD3D11 - Camera" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/ModelFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Definitions.hpp" 6 | 7 | #include 8 | 9 | class ModelFactory 10 | { 11 | public: 12 | ModelFactory(const WRL::ComPtr& device); 13 | 14 | bool LoadModel( 15 | const std::string& filePath, 16 | WRL::ComPtr& vertexBuffer, 17 | uint32_t* vertexCount, 18 | WRL::ComPtr& indexBuffer, 19 | uint32_t* indexCount); 20 | 21 | private: 22 | WRL::ComPtr _device = nullptr; 23 | }; 24 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Pipeline.cpp: -------------------------------------------------------------------------------- 1 | #include "Pipeline.hpp" 2 | 3 | void Pipeline::BindTexture(uint32_t slotIndex, ID3D11ShaderResourceView* texture) 4 | { 5 | ResourceDescriptor descriptor = {}; 6 | descriptor.SlotIndex = slotIndex; 7 | descriptor.Type = ResourceType::Texture; 8 | _resources[descriptor] = static_cast(texture); 9 | } 10 | 11 | void Pipeline::BindSampler(uint32_t slotIndex, ID3D11SamplerState* sampler) 12 | { 13 | ResourceDescriptor descriptor = {}; 14 | descriptor.SlotIndex = slotIndex; 15 | descriptor.Type = ResourceType::Sampler; 16 | _resources[descriptor] = static_cast(sampler); 17 | } 18 | 19 | void Pipeline::BindVertexStageConstantBuffer(uint32_t slotIndex, ID3D11Buffer* buffer) 20 | { 21 | ResourceDescriptor descriptor = {}; 22 | descriptor.SlotIndex = slotIndex; 23 | descriptor.Stage = ResourceStage::VertexStage; 24 | descriptor.Type = ResourceType::Buffer; 25 | _resources[descriptor] = static_cast(buffer); 26 | } 27 | 28 | void Pipeline::SetViewport( 29 | const float left, 30 | const float top, 31 | const float width, 32 | const float height) 33 | { 34 | _viewport.TopLeftX = left; 35 | _viewport.TopLeftY = top; 36 | _viewport.Width = width; 37 | _viewport.Height = height; 38 | _viewport.MinDepth = 0.0f; 39 | _viewport.MaxDepth = 1.0f; 40 | } 41 | 42 | void Pipeline::SetDepthStencilState(ID3D11DepthStencilState* depthStencilState) 43 | { 44 | _depthStencilState = depthStencilState; 45 | } 46 | 47 | void Pipeline::SetRasterizerState(ID3D11RasterizerState* rasterizerState) 48 | { 49 | _rasterizerState = rasterizerState; 50 | } 51 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/Pipeline.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include "ResourceDescriptor.hpp" 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | class Pipeline 12 | { 13 | public: 14 | friend class PipelineFactory; 15 | friend class DeviceContext; 16 | 17 | void BindTexture(uint32_t slotIndex, ID3D11ShaderResourceView* texture); 18 | void BindSampler(uint32_t slotIndex, ID3D11SamplerState* sampler); 19 | void BindVertexStageConstantBuffer(uint32_t slotIndex, ID3D11Buffer* buffer); 20 | void SetViewport( 21 | float left, 22 | float top, 23 | float width, 24 | float height); 25 | void SetDepthStencilState(ID3D11DepthStencilState* depthStencilState); 26 | void SetRasterizerState(ID3D11RasterizerState* rasterizerState); 27 | 28 | private: 29 | WRL::ComPtr _vertexShader = nullptr; 30 | WRL::ComPtr _pixelShader = nullptr; 31 | WRL::ComPtr _inputLayout = nullptr; 32 | WRL::ComPtr _depthStencilState = nullptr; 33 | WRL::ComPtr _rasterizerState = nullptr; 34 | std::unordered_map _resources; 35 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 36 | uint32_t _vertexSize = 0; 37 | D3D11_VIEWPORT _viewport = {}; 38 | }; 39 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/PipelineFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include "Pipeline.hpp" 5 | #include "VertexType.hpp" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | struct PipelineDescriptor 12 | { 13 | std::wstring VertexFilePath; 14 | std::wstring PixelFilePath; 15 | VertexType VertexType; 16 | }; 17 | 18 | class PipelineFactory 19 | { 20 | public: 21 | PipelineFactory(const WRL::ComPtr& device); 22 | 23 | bool CreatePipeline( 24 | const PipelineDescriptor& settings, 25 | std::unique_ptr& pipeline); 26 | 27 | private: 28 | static size_t GetLayoutByteSize(VertexType vertexType); 29 | 30 | [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | const std::wstring& filePath, 32 | WRL::ComPtr& vertexShaderBlob) const; 33 | [[nodiscard]] WRL::ComPtr CreatePixelShader(const std::wstring& filePath) const; 34 | 35 | bool CreateInputLayout( 36 | VertexType layoutInfo, 37 | const WRL::ComPtr& vertexBlob, 38 | WRL::ComPtr& inputLayout); 39 | 40 | bool CompileShader( 41 | const std::wstring& filePath, 42 | const std::string& entryPoint, 43 | const std::string& profile, 44 | WRL::ComPtr& shaderBlob) const; 45 | 46 | WRL::ComPtr _device = nullptr; 47 | std::unordered_map> _layoutMap; 48 | }; 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/ResourceDescriptor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | enum class ResourceType : uint32_t 7 | { 8 | Texture, 9 | Sampler, 10 | Buffer 11 | }; 12 | 13 | enum class ResourceStage : uint32_t 14 | { 15 | VertexStage, 16 | PixelStage 17 | }; 18 | 19 | struct ResourceDescriptor 20 | { 21 | ResourceType Type; 22 | ResourceStage Stage; 23 | uint32_t SlotIndex; 24 | }; 25 | 26 | namespace std 27 | { 28 | template <> 29 | struct hash 30 | { 31 | size_t operator()(const ResourceDescriptor& resource) const noexcept 32 | { 33 | const hash hash; 34 | return hash(static_cast(resource.SlotIndex) << 32) ^ hash(static_cast(resource.Type)); 35 | } 36 | }; 37 | 38 | template <> 39 | struct equal_to 40 | { 41 | bool operator()( 42 | const ResourceDescriptor& lhs, 43 | const ResourceDescriptor& rhs) const noexcept 44 | { 45 | return lhs.SlotIndex == rhs.SlotIndex && lhs.Type == rhs.Type; 46 | } 47 | }; 48 | } // namespace std 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/TextureFactory.cpp: -------------------------------------------------------------------------------- 1 | #include "TextureFactory.hpp" 2 | 3 | #include 4 | 5 | #include 6 | 7 | TextureFactory::TextureFactory(const WRL::ComPtr& device) 8 | { 9 | _device = device; 10 | } 11 | 12 | bool TextureFactory::CreateShaderResourceViewFromFile( 13 | const std::wstring& filePath, 14 | WRL::ComPtr& shaderResourceView) const 15 | { 16 | DirectX::TexMetadata metaData = {}; 17 | DirectX::ScratchImage scratchImage; 18 | if (FAILED(DirectX::LoadFromDDSFile(filePath.data(), DirectX::DDS_FLAGS_NONE, &metaData, scratchImage))) 19 | { 20 | std::cout << "DXTEX: Failed to load image\n"; 21 | return false; 22 | } 23 | 24 | WRL::ComPtr texture = nullptr; 25 | if (FAILED(DirectX::CreateTexture( 26 | _device.Get(), 27 | scratchImage.GetImages(), 28 | scratchImage.GetImageCount(), 29 | metaData, 30 | &texture))) 31 | { 32 | std::cout << "DXTEX: Failed to create texture out of image\n"; 33 | scratchImage.Release(); 34 | return false; 35 | } 36 | 37 | if (FAILED(DirectX::CreateShaderResourceView( 38 | _device.Get(), 39 | scratchImage.GetImages(), 40 | scratchImage.GetImageCount(), 41 | metaData, 42 | &shaderResourceView))) 43 | { 44 | std::cout << "DXTEX: Failed to create shader resource view out of texture\n"; 45 | scratchImage.Release(); 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/TextureFactory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | 8 | class TextureFactory 9 | { 10 | public: 11 | TextureFactory(const WRL::ComPtr& device); 12 | 13 | bool CreateShaderResourceViewFromFile( 14 | const std::wstring& filePath, 15 | WRL::ComPtr& shaderResourceView) const; 16 | 17 | private: 18 | WRL::ComPtr _device = nullptr; 19 | }; 20 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-6-Camera/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/1-3-7-DearImGui.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | 50 | 51 | Header Files 52 | 53 | 54 | Header Files 55 | 56 | 57 | Header Files 58 | 59 | 60 | Header Files 61 | 62 | 63 | Header Files 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/1-3-7-DearImGui.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | 7 | $(OutDir) 8 | WindowsLocalDebugger 9 | 10 | 11 | $(OutDir) 12 | WindowsLocalDebugger 13 | 14 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/Assets/Models/SM_Good_Froge.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-7-DearImGui/Assets/Models/SM_Good_Froge.fbx -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/Assets/Shaders/Main.ps.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 Position: SV_Position; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | sampler LinearSampler : register(s0); 9 | 10 | Texture2D Texture : register(t0); 11 | 12 | float4 Main(VSOutput input): SV_Target 13 | { 14 | float4 texel = Texture.Sample(LinearSampler, input.Uv); 15 | //return float4(input.Color, 1.0f) + 0.5 * texel; 16 | return texel; 17 | } 18 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/Assets/Shaders/Main.vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VSInput 2 | { 3 | float3 Position: POSITION; 4 | float3 Color: COLOR0; 5 | float2 Uv: TEXCOORD0; 6 | }; 7 | 8 | struct VSOutput 9 | { 10 | float4 Position: SV_Position; 11 | float3 Color: COLOR0; 12 | float2 Uv: TEXCOORD0; 13 | }; 14 | 15 | cbuffer PerApplication 16 | { 17 | row_major matrix ProjectionMatrix; 18 | } 19 | 20 | cbuffer PerFrame 21 | { 22 | row_major matrix ViewMatrix; 23 | } 24 | 25 | cbuffer PerObject 26 | { 27 | row_major matrix WorldMatrix; 28 | } 29 | 30 | VSOutput Main(VSInput input) 31 | { 32 | const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix)); 33 | 34 | VSOutput output = (VSOutput)0; 35 | output.Position = mul(float4(input.Position, 1.0f), modelViewProjection); 36 | output.Color = input.Color; 37 | output.Uv = input.Uv; 38 | return output; 39 | } 40 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/Assets/Textures/T_Good_Froge.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GraphicsProgramming/learnd3d11/bd9c5f3d1bddbc7a59b4f8f4be6d5f3b18f757d0/src/Cpp/1-getting-started/1-3-7-DearImGui/Assets/Textures/T_Good_Froge.dds -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/DearImGuiApplication.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.hpp" 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | class Pipeline; 12 | class PipelineFactory; 13 | class DeviceContext; 14 | class TextureFactory; 15 | class ModelFactory; 16 | 17 | struct ImGuiContext; 18 | 19 | class DearImGuiApplication final : public Application 20 | { 21 | public: 22 | DearImGuiApplication(const std::string& title); 23 | ~DearImGuiApplication() override; 24 | 25 | protected: 26 | bool Initialize() override; 27 | bool Load() override; 28 | void OnResize( 29 | int32_t width, 30 | int32_t height) override; 31 | void Update() override; 32 | void Render() override; 33 | 34 | private: 35 | bool CreateSwapchainResources(); 36 | void DestroySwapchainResources(); 37 | 38 | void InitializeImGui(); 39 | void RenderUi(); 40 | 41 | enum ConstantBufferType 42 | { 43 | PerApplication, 44 | PerFrame, 45 | PerObject, 46 | NumConstantBufferTypes 47 | }; 48 | 49 | std::unique_ptr _pipeline = nullptr; 50 | std::unique_ptr _deviceContext = nullptr; 51 | std::unique_ptr _pipelineFactory = nullptr; 52 | std::unique_ptr _textureFactory = nullptr; 53 | std::unique_ptr _modelFactory = nullptr; 54 | 55 | ImGuiContext* _imGuiContext = nullptr; 56 | 57 | WRL::ComPtr _device = nullptr; 58 | WRL::ComPtr _dxgiFactory = nullptr; 59 | WRL::ComPtr _swapChain = nullptr; 60 | WRL::ComPtr _renderTarget = nullptr; 61 | WRL::ComPtr _modelVertices = nullptr; 62 | WRL::ComPtr _modelIndices = nullptr; 63 | WRL::ComPtr _debug = nullptr; 64 | 65 | WRL::ComPtr _linearSamplerState = nullptr; 66 | WRL::ComPtr _textureSrv = nullptr; 67 | WRL::ComPtr _constantBuffers[NumConstantBufferTypes]; 68 | 69 | DirectX::XMMATRIX _projectionMatrix = DirectX::XMMATRIX(); 70 | DirectX::XMMATRIX _viewMatrix = DirectX::XMMATRIX(); 71 | DirectX::XMMATRIX _worldMatrix = DirectX::XMMATRIX(); 72 | 73 | uint32_t _modelVertexCount = 0; 74 | uint32_t _modelIndexCount = 0; 75 | bool _toggledRotation = false; 76 | }; 77 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/Definitions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace WRL = Microsoft::WRL; 6 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "DearImGuiApplication.hpp" 2 | 3 | int main() 4 | { 5 | DearImGuiApplication app{ "LearnD3D11 - Dear ImGui" }; 6 | app.Run(); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/ResourceDescriptor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | enum class ResourceType : uint32_t 7 | { 8 | Texture, 9 | Sampler, 10 | Buffer 11 | }; 12 | 13 | enum class ResourceStage : uint32_t 14 | { 15 | VertexStage, 16 | PixelStage 17 | }; 18 | 19 | struct ResourceDescriptor 20 | { 21 | ResourceType Type; 22 | ResourceStage Stage; 23 | uint32_t SlotIndex; 24 | }; 25 | 26 | namespace std 27 | { 28 | template <> 29 | struct hash 30 | { 31 | size_t operator()(const ResourceDescriptor& resource) const noexcept 32 | { 33 | const hash hash; 34 | return hash(static_cast(resource.SlotIndex) << 32) ^ hash(static_cast(resource.Type)); 35 | } 36 | }; 37 | 38 | template <> 39 | struct equal_to 40 | { 41 | bool operator()( 42 | const ResourceDescriptor& lhs, 43 | const ResourceDescriptor& rhs) const noexcept 44 | { 45 | return lhs.SlotIndex == rhs.SlotIndex && lhs.Type == rhs.Type; 46 | } 47 | }; 48 | } // namespace std 49 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/ShaderCollection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VertexType.hpp" 4 | #include "Definitions.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | struct ShaderCollectionDescriptor 11 | { 12 | std::wstring VertexShaderFilePath; 13 | std::wstring PixelShaderFilePath; 14 | VertexType VertexType; 15 | }; 16 | 17 | class ShaderCollection 18 | { 19 | public: 20 | 21 | static ShaderCollection CreateShaderCollection( 22 | const ShaderCollectionDescriptor& settings, ID3D11Device* device); 23 | static size_t GetLayoutByteSize(VertexType vertexType); 24 | 25 | void ApplyToContext(ID3D11DeviceContext* context); 26 | void Destroy(); 27 | 28 | private: 29 | 30 | static [[nodiscard]] WRL::ComPtr CreateVertexShader( 31 | ID3D11Device* device, 32 | const std::wstring& filePath, 33 | WRL::ComPtr& vertexShaderBlob); 34 | static [[nodiscard]] WRL::ComPtr CreatePixelShader( 35 | ID3D11Device* device, 36 | const std::wstring& filePath); 37 | 38 | static bool CreateInputLayout( 39 | ID3D11Device* device, 40 | const VertexType layoutInfo, 41 | const WRL::ComPtr& vertexBlob, 42 | WRL::ComPtr& inputLayout); 43 | 44 | static bool CompileShader( 45 | const std::wstring& filePath, 46 | const std::string& entryPoint, 47 | const std::string& profile, 48 | WRL::ComPtr& shaderBlob); 49 | 50 | 51 | WRL::ComPtr _vertexShader = nullptr; 52 | WRL::ComPtr _pixelShader = nullptr; 53 | WRL::ComPtr _inputLayout = nullptr; 54 | D3D11_PRIMITIVE_TOPOLOGY _primitiveTopology = {}; 55 | uint32_t _vertexSize = 0; 56 | static std::unordered_map> _layoutMap; 57 | }; 58 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/1-3-7-DearImGui/VertexType.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class VertexType 6 | { 7 | PositionColor, 8 | PositionColorUv 9 | }; 10 | 11 | using Position = DirectX::XMFLOAT3; 12 | using Color = DirectX::XMFLOAT3; 13 | using Uv = DirectX::XMFLOAT2; 14 | 15 | struct VertexPositionColor 16 | { 17 | Position position; 18 | Color color; 19 | }; 20 | 21 | struct VertexPositionColorUv 22 | { 23 | Position position; 24 | Color color; 25 | Uv uv; 26 | }; 27 | -------------------------------------------------------------------------------- /src/Cpp/1-getting-started/Shared/CommonLibraries.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Main Direct3D11 library https://docs.microsoft.com/en-us/windows/win32/direct3d11/atoc-dx-graphics-direct3d-11 4 | #pragma comment(lib, "d3d11.lib") 5 | // DXGI https://docs.microsoft.com/en-us/windows/win32/direct3ddxgi/d3d10-graphics-programming-guide-dxgi 6 | #pragma comment(lib, "dxgi.lib") 7 | // Runtime shader compilation https://docs.microsoft.com/en-us/windows/win32/api/d3dcompiler/ 8 | #pragma comment(lib, "d3dcompiler.lib") 9 | // Collection of GUIDs for usage with SetPrivateData and ComPtr 10 | #pragma comment(lib, "dxguid.lib") -------------------------------------------------------------------------------- /src/Cpp/Framework/Application.cpp: -------------------------------------------------------------------------------- 1 | #include "Application.hpp" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | Application::Application(const std::string& title) 9 | : _title(title) 10 | { 11 | } 12 | 13 | Application::~Application() 14 | { 15 | Application::Cleanup(); 16 | } 17 | 18 | bool Application::Initialize() 19 | { 20 | if (!glfwInit()) 21 | { 22 | std::cerr << "GLFW: Failed to initialize\n"; 23 | return false; 24 | } 25 | 26 | GLFWmonitor* primaryMonitor = glfwGetPrimaryMonitor(); 27 | const GLFWvidmode* videoMode = glfwGetVideoMode(primaryMonitor); 28 | _width = static_cast(videoMode->width * 0.9f); 29 | _height = static_cast(videoMode->height * 0.9f); 30 | 31 | glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE); 32 | glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); 33 | _window = glfwCreateWindow( 34 | _width, 35 | _height, 36 | _title.data(), 37 | nullptr, 38 | nullptr); 39 | 40 | if (_window == nullptr) 41 | { 42 | std::cerr << "GLFW: Failed to create a window\n"; 43 | Cleanup(); 44 | return false; 45 | } 46 | 47 | const int32_t windowLeft = videoMode->width / 2 - _width / 2; 48 | const int32_t windowTop = videoMode->height / 2 - _height / 2; 49 | glfwSetWindowPos(_window, windowLeft, windowTop); 50 | 51 | glfwSetWindowUserPointer(_window, this); 52 | glfwSetFramebufferSizeCallback(_window, HandleResize); 53 | 54 | _currentTime = std::chrono::high_resolution_clock::now(); 55 | return true; 56 | } 57 | 58 | void Application::OnResize( 59 | const int32_t width, 60 | const int32_t height) 61 | { 62 | _width = width; 63 | _height = height; 64 | } 65 | 66 | void Application::Cleanup() 67 | { 68 | glfwDestroyWindow(_window); 69 | glfwTerminate(); 70 | } 71 | 72 | void Application::Run() 73 | { 74 | if (!Initialize()) 75 | { 76 | return; 77 | } 78 | 79 | if (!Load()) 80 | { 81 | return; 82 | } 83 | 84 | while (!glfwWindowShouldClose(_window)) 85 | { 86 | Update(); 87 | Render(); 88 | } 89 | } 90 | 91 | void Application::HandleResize( 92 | GLFWwindow* window, 93 | const int32_t width, 94 | const int32_t height) 95 | { 96 | Application* application = static_cast(glfwGetWindowUserPointer(window)); 97 | application->OnResize(width, height); 98 | } 99 | 100 | GLFWwindow* Application::GetWindow() const 101 | { 102 | return _window; 103 | } 104 | 105 | int32_t Application::GetWindowWidth() const 106 | { 107 | return _width; 108 | } 109 | 110 | int32_t Application::GetWindowHeight() const 111 | { 112 | return _height; 113 | } 114 | 115 | void Application::Update() 116 | { 117 | auto oldTime = _currentTime; 118 | _currentTime = std::chrono::high_resolution_clock::now(); 119 | 120 | std::chrono::duration timeSpan = (_currentTime - oldTime); 121 | _deltaTime = static_cast(timeSpan.count() / 1000.0); 122 | glfwPollEvents(); 123 | } 124 | -------------------------------------------------------------------------------- /src/Cpp/Framework/Application.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | // ReSharper disable once CppInconsistentNaming 8 | struct GLFWwindow; 9 | 10 | class Application 11 | { 12 | public: 13 | Application(const std::string& title); 14 | virtual ~Application(); 15 | 16 | void Run(); 17 | 18 | protected: 19 | static void HandleResize( 20 | GLFWwindow* window, 21 | int32_t width, 22 | int32_t height); 23 | virtual void OnResize( 24 | int32_t width, 25 | int32_t height); 26 | 27 | virtual bool Initialize(); 28 | virtual bool Load() = 0; 29 | virtual void Cleanup(); 30 | virtual void Render() = 0; 31 | virtual void Update(); 32 | 33 | [[nodiscard]] GLFWwindow* GetWindow() const; 34 | [[nodiscard]] int32_t GetWindowWidth() const; 35 | [[nodiscard]] int32_t GetWindowHeight() const; 36 | 37 | int32_t _width = 0; 38 | int32_t _height = 0; 39 | float _deltaTime = 0.016f; 40 | private: 41 | std::chrono::high_resolution_clock::time_point _currentTime; 42 | GLFWwindow* _window = nullptr; 43 | std::string _title; 44 | }; 45 | -------------------------------------------------------------------------------- /src/Cpp/Framework/Framework.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Cpp/Framework/Framework.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/LearnD3D11.sln.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True --------------------------------------------------------------------------------