├── .gitignore ├── Assignment01 ├── Library │ ├── Camera │ │ ├── Camera.cpp │ │ └── Camera.h │ ├── Common.h │ ├── Game │ │ ├── Game.cpp │ │ └── Game.h │ ├── Renderer │ │ ├── DataTypes.h │ │ ├── Renderable.cpp │ │ ├── Renderable.h │ │ ├── Renderer.cpp │ │ └── Renderer.h │ ├── Resource.h │ ├── Resource.rc │ ├── Window │ │ ├── BaseWindow.h │ │ ├── MainWindow.cpp │ │ └── MainWindow.h │ └── directx.ico └── README.md ├── Assignment02 ├── Game │ ├── Main.cpp │ └── Shaders │ │ └── VoxelShaders.fxh └── Library │ ├── Common.h │ ├── Renderer │ ├── DataTypes.h │ ├── InstancedRenderable.cpp │ ├── InstancedRenderable.h │ ├── Renderer.cpp │ └── Renderer.h │ └── Scene │ ├── Scene.cpp │ ├── Scene.h │ ├── Voxel.cpp │ └── Voxel.h ├── Assignment03 ├── Content │ └── Common │ │ ├── Maskonaive2_1024.dds │ │ └── Sphere.obj ├── Game │ ├── Main.cpp │ └── Shaders │ │ ├── CubeMap.fxh │ │ ├── CubeMap_PS.hlsl │ │ └── CubeMap_VS.hlsl └── Library │ ├── Light │ ├── PointLight.cpp │ └── PointLight.h │ ├── Renderer │ ├── Skybox.cpp │ └── Skybox.h │ ├── Scene │ ├── Scene.cpp │ └── Scene.h │ ├── Shader │ ├── SkyMapVertexShader.cpp │ └── SkyMapVertexShader.h │ └── Texture │ ├── Texture.cpp │ └── Texture.h ├── Lab00 ├── Game │ └── Main.cpp ├── Library │ ├── Common.h │ └── Game │ │ ├── Game.cpp │ │ └── Game.h └── README.md ├── Lab01 ├── Game │ └── Main.cpp ├── Library │ ├── Common.h │ ├── Game │ │ ├── Game.cpp │ │ └── Game.h │ ├── Resource.h │ ├── Resource.rc │ └── directx.ico └── README.md ├── Lab02 ├── Game │ └── Main.cpp ├── Library │ ├── Common.h │ ├── Game │ │ ├── Game.cpp │ │ └── Game.h │ ├── Renderer │ │ ├── Renderer.cpp │ │ └── Renderer.h │ ├── Resource.h │ ├── Resource.rc │ ├── Window │ │ ├── BaseWindow.h │ │ ├── MainWindow.cpp │ │ └── MainWindow.h │ └── directx.ico └── README.md ├── Lab03 ├── Game │ └── Main.cpp ├── Library │ ├── Common.h │ ├── Game │ │ ├── Game.cpp │ │ └── Game.h │ ├── Renderer │ │ ├── Renderer.cpp │ │ └── Renderer.h │ ├── Resource.h │ ├── Resource.rc │ ├── Shaders │ │ ├── Lab03.fxh │ │ ├── Lab03_PS.hlsl │ │ └── Lab03_VS.hlsl │ ├── Window │ │ ├── BaseWindow.h │ │ ├── MainWindow.cpp │ │ └── MainWindow.h │ └── directx.ico └── README.md ├── Lab04 ├── Game │ ├── Cube │ │ ├── BaseCube.cpp │ │ └── BaseCube.h │ ├── Main.cpp │ └── Shaders │ │ ├── PS.hlsl │ │ ├── Shaders.fxh │ │ └── VS.hlsl └── Library │ ├── Common.h │ ├── Game │ ├── Game.cpp │ └── Game.h │ ├── Renderer │ ├── DataTypes.h │ ├── Renderable.cpp │ ├── Renderable.h │ ├── Renderer.cpp │ └── Renderer.h │ ├── Shader │ ├── PixelShader.cpp │ ├── PixelShader.h │ ├── Shader.cpp │ ├── Shader.h │ ├── VertexShader.cpp │ └── VertexShader.h │ └── Window │ ├── BaseWindow.h │ ├── MainWindow.cpp │ └── MainWindow.h ├── Lab05 ├── Game │ ├── Cube │ │ ├── BaseCube.cpp │ │ ├── BaseCube.h │ │ ├── Cube.cpp │ │ └── Cube.h │ ├── Main.cpp │ ├── Shaders │ │ ├── PS.hlsl │ │ ├── Shaders.fxh │ │ └── VS.hlsl │ └── seafloor.dds └── Library │ ├── Camera │ ├── Camera.cpp │ └── Camera.h │ ├── Common.h │ ├── Renderer │ ├── DataTypes.h │ ├── Renderable.cpp │ ├── Renderable.h │ ├── Renderer.cpp │ └── Renderer.h │ └── Texture │ ├── DDSTextureLoader.cpp │ └── DDSTextureLoader.h ├── Lab06 ├── Game │ ├── Cube │ │ ├── BaseCube.cpp │ │ ├── BaseCube.h │ │ ├── Cube.cpp │ │ ├── Cube.h │ │ ├── RotatingCube.cpp │ │ └── RotatingCube.h │ ├── Light │ │ ├── RotatingPointLight.cpp │ │ └── RotatingPointLight.h │ ├── Main.cpp │ └── Shaders │ │ └── PhongShaders.fxh └── Library │ ├── Common.h │ ├── Light │ ├── PointLight.cpp │ └── PointLight.h │ └── Renderer │ ├── DataTypes.h │ ├── Renderable.cpp │ ├── Renderable.h │ ├── Renderer.cpp │ └── Renderer.h ├── Lab07 ├── Game │ └── Main.cpp └── Library │ ├── Common.h │ ├── Model │ ├── Model.cpp │ └── Model.h │ ├── Renderer │ ├── Renderable.cpp │ └── Renderable.h │ └── Texture │ ├── Material.cpp │ ├── Material.h │ ├── Texture.cpp │ ├── Texture.h │ ├── WICTextureLoader.cpp │ └── WICTextureLoader.h ├── Lab08 ├── Game │ ├── Content │ │ └── BobLampClean │ │ │ ├── boblampclean.md5anim │ │ │ ├── boblampclean.md5mesh │ │ │ ├── guard1_body.jpg │ │ │ ├── guard1_face.jpg │ │ │ ├── guard1_helmet.jpg │ │ │ ├── iron_grill.jpg │ │ │ └── round_grill.jpg │ ├── Main.cpp │ └── Shaders │ │ └── SkinningShaders.fxh └── Library │ ├── Model │ ├── Model.cpp │ └── Model.h │ ├── Renderer │ ├── DataTypes.h │ ├── Renderer.cpp │ └── Renderer.h │ └── Shader │ ├── SkinningVertexShader.cpp │ └── SkinningVertexShader.h ├── Lab09 ├── Game │ ├── Content │ │ ├── Common │ │ │ └── InvalidTexture.png │ │ ├── Cube │ │ │ ├── diffuse.png │ │ │ └── normal.png │ │ └── cyborg │ │ │ ├── LICENSE.txt │ │ │ ├── cyborg.blend │ │ │ ├── cyborg.blend1 │ │ │ ├── cyborg.mtl │ │ │ ├── cyborg.obj │ │ │ ├── cyborg_diffuse.png │ │ │ ├── cyborg_normal.png │ │ │ └── cyborg_specular.png │ ├── Main.cpp │ └── Shaders │ │ ├── PhongShaders.fxh │ │ └── VoxelShaders.fxh └── Library │ ├── Common.h │ ├── Model │ ├── Model.cpp │ └── Model.h │ ├── Renderer │ ├── DataTypes.h │ ├── Renderable.cpp │ ├── Renderable.h │ ├── Renderer.cpp │ └── Renderer.h │ ├── Scene │ ├── Scene.cpp │ ├── Scene.h │ └── Voxel.cpp │ └── Texture │ ├── Material.cpp │ └── Material.h ├── Lab10 ├── Game │ ├── Content │ │ └── plane.jpg │ ├── Cube │ │ ├── Cube.cpp │ │ └── Cube.h │ ├── Light │ │ └── RotatingPointLight.cpp │ ├── Main.cpp │ └── Shaders │ │ ├── PhongShaders.fxh │ │ └── ShadowShaders.fxh └── Library │ ├── Light │ ├── PointLight.cpp │ └── PointLight.h │ ├── Renderer │ ├── DataTypes.h │ ├── Renderer.cpp │ └── Renderer.h │ ├── Shader │ ├── ShadowVertexShader.cpp │ └── ShadowVertexShader.h │ └── Texture │ ├── RenderTexture.cpp │ └── RenderTexture.h └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Assignment01/Game 2 | Assignment01/Library/Shader -------------------------------------------------------------------------------- /Assignment01/Library/Camera/Camera.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: CUBE.H 3 | 4 | Summary: Cube header file contains declarations of Cube class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Cube 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/DataTypes.h" 17 | 18 | namespace library 19 | { 20 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 21 | Class: Camera 22 | 23 | Summary: Immitates a camera that moves according to the WASD and 24 | mouse input. 25 | 26 | Methods: GetEye 27 | Getter for the eye vector 28 | GetAt 29 | Getter for the at vector 30 | GetUp 31 | Getter for the up vector 32 | GetView 33 | Getter for the view transform matrix 34 | HandleInput 35 | Handles the keyboard / mouse input 36 | Update 37 | Update the camera according to the input 38 | Camera 39 | Constructor. 40 | ~Camera 41 | Destructor. 42 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 43 | class Camera 44 | { 45 | public: 46 | Camera() = delete; 47 | Camera(_In_ const XMVECTOR& position); 48 | Camera(const Camera& other) = delete; 49 | Camera(Camera&& other) = delete; 50 | Camera& operator=(const Camera& other) = delete; 51 | Camera& operator=(Camera&& other) = delete; 52 | virtual ~Camera() = default; 53 | 54 | const XMVECTOR& GetEye() const; 55 | const XMVECTOR& GetAt() const; 56 | const XMVECTOR& GetUp() const; 57 | const XMMATRIX& GetView() const; 58 | 59 | virtual void HandleInput(_In_ const DirectionsInput& directions, _In_ const MouseRelativeMovement& mouseRelativeMovement, _In_ FLOAT deltaTime); 60 | virtual void Update(_In_ FLOAT deltaTime); 61 | 62 | protected: 63 | static constexpr const XMVECTORF32 DEFAULT_FORWARD = { 0.0f, 0.0f, 1.0f, 0.0f }; 64 | static constexpr const XMVECTORF32 DEFAULT_RIGHT = { 1.0f, 0.0f, 0.0f, 0.0f }; 65 | static constexpr const XMVECTORF32 DEFAULT_UP = { 0.0f, 1.0f, 0.0f, 0.0f }; 66 | 67 | FLOAT m_yaw; 68 | FLOAT m_pitch; 69 | 70 | FLOAT m_moveLeftRight; 71 | FLOAT m_moveBackForward; 72 | FLOAT m_moveUpDown; 73 | 74 | FLOAT m_travelSpeed; 75 | FLOAT m_rotationSpeed; 76 | 77 | DWORD m_padding; 78 | 79 | XMVECTOR m_cameraForward; 80 | XMVECTOR m_cameraRight; 81 | XMVECTOR m_cameraUp; 82 | 83 | XMVECTOR m_eye; 84 | XMVECTOR m_at; 85 | XMVECTOR m_up; 86 | 87 | XMMATRIX m_rotation; 88 | XMMATRIX m_view; 89 | }; 90 | } -------------------------------------------------------------------------------- /Assignment01/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define _CRTDBG_MAP_ALLOC 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "Resource.h" 46 | 47 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 48 | 49 | using namespace Microsoft::WRL; 50 | using namespace DirectX; 51 | 52 | namespace library 53 | { 54 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 55 | Struct: DirectionsInput 56 | 57 | Summary: Data structure that stores keyboard movement data 58 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 59 | struct DirectionsInput 60 | { 61 | BOOL bFront; 62 | BOOL bLeft; 63 | BOOL bBack; 64 | BOOL bRight; 65 | BOOL bUp; 66 | BOOL bDown; 67 | }; 68 | 69 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 70 | Struct: MouseRelativeMovement 71 | 72 | Summary: Data structure that stores mouse relative movement data 73 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 74 | struct MouseRelativeMovement 75 | { 76 | LONG X; 77 | LONG Y; 78 | }; 79 | } -------------------------------------------------------------------------------- /Assignment01/Library/Game/Game.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: GAME.H 3 | 4 | Summary: Game header file contains declarations of functions 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Game 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/Renderer.h" 17 | #include "Window/MainWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: Game 23 | 24 | Summary: Main game engine class 25 | 26 | Methods: Initialize 27 | Initializes the components of the game 28 | Run 29 | Runs the game loop 30 | GetGameName 31 | Returns the name of the game 32 | GetWindow 33 | Returns the reference to the unique pointer to the 34 | main window 35 | GetRenderer 36 | Returns the reference to the unique pointer to the 37 | renderer 38 | Game 39 | Constructor. 40 | ~Game 41 | Destructor. 42 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 43 | class Game final 44 | { 45 | public: 46 | Game(_In_ PCWSTR pszGameName); 47 | Game(const Game& other) = delete; 48 | Game(Game&& other) = delete; 49 | Game& operator=(const Game& other) = delete; 50 | Game& operator=(Game&& other) = delete; 51 | ~Game() = default; 52 | 53 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow); 54 | INT Run(); 55 | 56 | PCWSTR GetGameName() const; 57 | std::unique_ptr& GetWindow(); 58 | std::unique_ptr& GetRenderer(); 59 | private: 60 | PCWSTR m_pszGameName; 61 | std::unique_ptr m_mainWindow; 62 | std::unique_ptr m_renderer; 63 | }; 64 | } -------------------------------------------------------------------------------- /Assignment01/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace library 4 | { 5 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 6 | Struct: SimpleVertex 7 | 8 | Summary: Simple vertex structure containing a single field of the 9 | type XMFLOAT3 10 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 11 | struct SimpleVertex 12 | { 13 | XMFLOAT3 Position; 14 | }; 15 | 16 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 17 | Struct: ConstantBuffer 18 | 19 | Summary: Simple constant buffer structure containing world, view, 20 | projection matrices 21 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 22 | struct ConstantBuffer 23 | { 24 | XMMATRIX World; 25 | XMMATRIX View; 26 | XMMATRIX Projection; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /Assignment01/Library/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | #define IDR_MAINFRAME 128 9 | #define IDD_TUTORIAL_DIALOG 102 10 | #define IDD_ABOUTBOX 103 11 | #define IDM_ABOUT 104 12 | #define IDM_EXIT 105 13 | #define IDI_TUTORIAL 107 14 | #define IDI_SMALL 108 15 | #define IDC_TUTORIAL 109 16 | #define IDC_MYICON 2 17 | #define IDC_STATIC -1 18 | // Next default values for new objects 19 | // 20 | #ifdef APSTUDIO_INVOKED 21 | #ifndef APSTUDIO_READONLY_SYMBOLS 22 | 23 | #define _APS_NO_MFC 130 24 | #define _APS_NEXT_RESOURCE_VALUE 129 25 | #define _APS_NEXT_COMMAND_VALUE 32771 26 | #define _APS_NEXT_CONTROL_VALUE 1000 27 | #define _APS_NEXT_SYMED_VALUE 110 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /Assignment01/Library/Resource.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 17 | LANGUAGE 9, 1 18 | #pragma code_page(1252) 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | // 22 | // Icon 23 | // 24 | 25 | // Icon with lowest ID value placed first to ensure application icon 26 | // remains consistent on all systems. 27 | 28 | IDI_TUTORIAL ICON "directx.ico" 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | // 32 | // Menu 33 | // 34 | 35 | IDC_TUTORIAL MENU 36 | BEGIN 37 | POPUP "&File" 38 | BEGIN 39 | MENUITEM "E&xit", IDM_EXIT 40 | END 41 | POPUP "&Help" 42 | BEGIN 43 | MENUITEM "&About ...", IDM_ABOUT 44 | END 45 | END 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Accelerator 51 | // 52 | 53 | IDC_TUTORIAL ACCELERATORS 54 | BEGIN 55 | "?", IDM_ABOUT, ASCII, ALT 56 | "/", IDM_ABOUT, ASCII, ALT 57 | END 58 | 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Dialog 63 | // 64 | 65 | IDD_ABOUTBOX DIALOG 22, 17, 230, 75 66 | STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU 67 | CAPTION "About" 68 | FONT 8, "System" 69 | BEGIN 70 | ICON IDI_TUTORIAL, IDC_MYICON, 14, 9, 16, 16 71 | LTEXT "Lab02 Version 1.0", IDC_STATIC, 49, 10, 119, 8, SS_NOPREFIX 72 | LTEXT "Copyright (c) Microsoft Corporation.", IDC_STATIC, 49, 20, 119, 8 73 | DEFPUSHBUTTON "OK", IDOK, 195, 6, 30, 11, WS_GROUP 74 | END 75 | 76 | 77 | #ifdef APSTUDIO_INVOKED 78 | ///////////////////////////////////////////////////////////////////////////// 79 | // 80 | // TEXTINCLUDE 81 | // 82 | 1 TEXTINCLUDE 83 | BEGIN 84 | "resource.h\0" 85 | END 86 | 87 | 2 TEXTINCLUDE 88 | BEGIN 89 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 90 | "#include ""windows.h""\r\n" 91 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 92 | "\0" 93 | END 94 | 95 | 3 TEXTINCLUDE 96 | BEGIN 97 | "\r\n" 98 | "\0" 99 | END 100 | 101 | #endif // APSTUDIO_INVOKED 102 | 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // String Table 106 | // 107 | 108 | STRINGTABLE 109 | BEGIN 110 | IDC_TUTORIAL "Lab02" 111 | IDS_APP_TITLE "Lab02" 112 | END 113 | 114 | #endif 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | 118 | 119 | #ifndef APSTUDIO_INVOKED 120 | ///////////////////////////////////////////////////////////////////////////// 121 | // 122 | // Generated from the TEXTINCLUDE 3 resource. 123 | // 124 | 125 | 126 | ///////////////////////////////////////////////////////////////////////////// 127 | #endif // not APSTUDIO_INVOKED -------------------------------------------------------------------------------- /Assignment01/Library/Window/MainWindow.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: BASEWINDOW.H 3 | 4 | Summary: BaseWindow header file contains declarations of the 5 | base class of all windows used in the library. 6 | 7 | Classes: BaseWindow 8 | 9 | Functions: InitWindow, InitDevice 10 | 11 | � 2022 Kyung Hee University 12 | ===================================================================+*/ 13 | #pragma once 14 | 15 | #include "Common.h" 16 | 17 | #include "Window/BaseWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: MainWindow 23 | 24 | Summary: Main window to be used in game engine 25 | 26 | Methods: Initialize 27 | Initializes window 28 | GetWindowClassName 29 | Returns the name of the window class 30 | HandleMessage 31 | Handles the messages 32 | GetDirections 33 | Returns the keyboard direction input 34 | GetMouseRelativeMovement 35 | Returns the mouse relative movement 36 | ResetMouseMovement 37 | Reset the mouse relative movement to zero 38 | MainWindow 39 | Constructor. 40 | ~MainWindow 41 | Destructor. 42 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 43 | class MainWindow : public BaseWindow 44 | { 45 | public: 46 | MainWindow() = default; 47 | MainWindow(const MainWindow& other) = delete; 48 | MainWindow(MainWindow&& other) = delete; 49 | MainWindow& operator=(const MainWindow& other) = delete; 50 | MainWindow& operator=(MainWindow&& other) = delete; 51 | virtual ~MainWindow() = default; 52 | 53 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow, _In_ PCWSTR pszWindowName) override; 54 | PCWSTR GetWindowClassName() const override; 55 | LRESULT HandleMessage(_In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) override; 56 | 57 | const DirectionsInput& GetDirections() const; 58 | const MouseRelativeMovement& GetMouseRelativeMovement() const; 59 | void ResetMouseMovement(); 60 | 61 | private: 62 | DirectionsInput m_directions; 63 | MouseRelativeMovement m_mouseRelativeMovement; 64 | }; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /Assignment01/Library/directx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Assignment01/Library/directx.ico -------------------------------------------------------------------------------- /Assignment01/README.md: -------------------------------------------------------------------------------- 1 | # Assignment 01: Minecraft's Creative-Mode-Like First-Person Camera 2 | 3 | Students registered in the Game Graphics Programming course will conduct each assignment based on Direct3D 11. Each assignment work is an incremental development of a basic rendering engine, thus they are not independent. For this reason, we recommend the students to stay focused to the teaching assistant (TA). Through this assignment, one can develop a no-clip frea-roaming camera similar to that of the game Minecraft. 4 | 5 | [Helper slide](https://docs.google.com/presentation/d/1OZfN-D3o1eYLqKaZyEXQS0NcomWv67ZPkT8MnlTA3sU/edit?usp=sharing) -------------------------------------------------------------------------------- /Assignment02/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | #pragma comment(lib, "dxguid.lib") 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #define _CRTDBG_MAP_ALLOC 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "Resource.h" 47 | 48 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 49 | 50 | using namespace Microsoft::WRL; 51 | using namespace DirectX; 52 | 53 | #define ASSIMP_LOAD_FLAGS (aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices | aiProcess_ConvertToLeftHanded) 54 | 55 | namespace library 56 | { 57 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 58 | Struct: DirectionsInput 59 | 60 | Summary: Data structure that stores keyboard movement data 61 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 62 | struct DirectionsInput 63 | { 64 | BOOL bFront; 65 | BOOL bLeft; 66 | BOOL bBack; 67 | BOOL bRight; 68 | BOOL bUp; 69 | BOOL bDown; 70 | }; 71 | 72 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 73 | Struct: MouseRelativeMovement 74 | 75 | Summary: Data structure that stores mouse relative movement data 76 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 77 | struct MouseRelativeMovement 78 | { 79 | LONG X; 80 | LONG Y; 81 | }; 82 | 83 | /*E+E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E 84 | Enum: eBlockType 85 | 86 | Summary: Enumeration of block types 87 | E---E---E---E---E---E---E---E---E---E---E---E---E---E---E---E---E-E*/ 88 | enum class eBlockType : CHAR 89 | { 90 | GRASSLAND = 21, 91 | SNOW, 92 | OCEAN, 93 | SAND, 94 | SCORCHED, 95 | BARE, 96 | TUNDRA, 97 | TEMPERATE_DESERT, 98 | SHRUBLAND, 99 | TAIGA, 100 | TEMPERATE_DECIDUOUS_FOREST, 101 | TEMPERATE_RAIN_FOREST, 102 | SUBTROPICAL_DESERT, 103 | TROPICAL_SEASONAL_FOREST, 104 | TROPICAL_RAIN_FOREST, 105 | COUNT, 106 | }; 107 | } -------------------------------------------------------------------------------- /Assignment02/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | namespace library 6 | { 7 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 8 | Struct: SimpleVertex 9 | 10 | Summary: Simple vertex structure containing a single field of the 11 | type XMFLOAT3 12 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 13 | struct SimpleVertex 14 | { 15 | XMFLOAT3 Position; 16 | XMFLOAT2 TexCoord; 17 | XMFLOAT3 Normal; 18 | }; 19 | 20 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 21 | Struct: InstanceData 22 | 23 | Summary: Instance data containing a per instance transformation 24 | matrix 25 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 26 | struct InstanceData 27 | { 28 | XMMATRIX Transformation; 29 | }; 30 | 31 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 32 | Struct: CBChangeOnCameraMovement 33 | 34 | Summary: Constant buffer containing view matrix 35 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 36 | struct CBChangeOnCameraMovement 37 | { 38 | XMMATRIX View; 39 | XMFLOAT4 CameraPosition; // This is for shading. You may comment this out until then. 40 | }; 41 | 42 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 43 | Struct: CBChangeOnResize 44 | 45 | Summary: Constant buffer containing projection matrix 46 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 47 | struct CBChangeOnResize 48 | { 49 | XMMATRIX Projection; 50 | }; 51 | 52 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 53 | Struct: CBChangesEveryFrame 54 | 55 | Summary: Constant buffer containing world matrix 56 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 57 | struct CBChangesEveryFrame 58 | { 59 | XMMATRIX World; 60 | XMFLOAT4 OutputColor; 61 | }; 62 | 63 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 64 | Struct: CBLights 65 | 66 | Summary: Constant buffer containing lights' information 67 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 68 | struct CBLights 69 | { 70 | XMFLOAT4 LightPositions[NUM_LIGHTS]; 71 | XMFLOAT4 LightColors[NUM_LIGHTS]; 72 | }; 73 | } -------------------------------------------------------------------------------- /Assignment02/Library/Renderer/InstancedRenderable.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: V0XEL.H 3 | 4 | Summary: InstancedRenderable header file contains declarations of InstancedRenderable class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: InstancedRenderable 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/DataTypes.h" 17 | #include "Renderer/Renderable.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: InstancedRenderable 23 | 24 | Summary: Base class for renderable 3d cube object 25 | 26 | Methods: SetInstanceData 27 | Sets the instance data 28 | GetInstanceBuffer 29 | Returns a instance buffer 30 | GetNumInstances 31 | Returns the number of instance data 32 | initializeInstance 33 | Initialize the instance buffer 34 | InstancedRenderable 35 | Constructor. 36 | ~InstancedRenderable 37 | Destructor. 38 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 39 | class InstancedRenderable : public Renderable 40 | { 41 | public: 42 | InstancedRenderable(_In_ const XMFLOAT4& outputColor); 43 | InstancedRenderable(_In_ std::vector&& aInstanceData, _In_ const XMFLOAT4& outputColor); 44 | InstancedRenderable(const InstancedRenderable& other) = delete; 45 | InstancedRenderable(InstancedRenderable&& other) = delete; 46 | InstancedRenderable& operator=(const InstancedRenderable& other) = delete; 47 | InstancedRenderable& operator=(InstancedRenderable&& other) = delete; 48 | ~InstancedRenderable() = default; 49 | 50 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) override = 0; 51 | virtual void Update(_In_ FLOAT deltaTime) override = 0; 52 | 53 | void SetInstanceData(_In_ std::vector&& aInstanceData); 54 | 55 | virtual ComPtr& GetInstanceBuffer(); 56 | virtual UINT GetNumInstances() const; 57 | 58 | UINT GetNumVertices() const override = 0; 59 | UINT GetNumIndices() const override = 0; 60 | 61 | protected: 62 | const SimpleVertex* getVertices() const override = 0; 63 | const WORD* getIndices() const override = 0; 64 | 65 | virtual HRESULT initializeInstance(_In_ ID3D11Device* pDevice); 66 | 67 | protected: 68 | ComPtr m_instanceBuffer; 69 | std::vector m_aInstanceData; 70 | 71 | private: 72 | BYTE m_padding[8]; 73 | }; 74 | } -------------------------------------------------------------------------------- /Assignment02/Library/Scene/Scene.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: V0XEL.H 3 | 4 | Summary: Voxel header file contains declarations of Voxel class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Voxel 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include 17 | 18 | #include "Renderer/Renderable.h" 19 | #include "Scene/Voxel.h" 20 | 21 | namespace library 22 | { 23 | class Scene 24 | { 25 | public: 26 | static FLOAT GetPerlin2d(FLOAT x, FLOAT y, FLOAT frequency, UINT uDepth); 27 | 28 | Scene(const std::filesystem::path& filePath); 29 | Scene(const Scene& other) = delete; 30 | Scene(Scene&& other) = delete; 31 | Scene& operator=(const Scene& other) = delete; 32 | Scene& operator=(Scene&& other) = delete; 33 | virtual ~Scene() = default; 34 | 35 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext); 36 | 37 | std::vector>& GetVoxels(); 38 | const std::filesystem::path& GetFilePath() const; 39 | PCWSTR GetFileName() const; 40 | 41 | private: 42 | static FLOAT getNoise2(UINT x, UINT y); 43 | static FLOAT getNoise2d(FLOAT x, FLOAT y); 44 | static FLOAT lerp(FLOAT x, FLOAT y, FLOAT s); 45 | static FLOAT smoothLerp(FLOAT x, FLOAT y, FLOAT s); 46 | 47 | private: 48 | static constexpr const UINT ms_aHashes[] = 49 | { 50 | 208,34,231,213,32,248,233,56,161,78,24,140,71,48,140,254,245,255,247,247,40, 51 | 185,248,251,245,28,124,204,204,76,36,1,107,28,234,163,202,224,245,128,167,204, 52 | 9,92,217,54,239,174,173,102,193,189,190,121,100,108,167,44,43,77,180,204,8,81, 53 | 70,223,11,38,24,254,210,210,177,32,81,195,243,125,8,169,112,32,97,53,195,13, 54 | 203,9,47,104,125,117,114,124,165,203,181,235,193,206,70,180,174,0,167,181,41, 55 | 164,30,116,127,198,245,146,87,224,149,206,57,4,192,210,65,210,129,240,178,105, 56 | 228,108,245,148,140,40,35,195,38,58,65,207,215,253,65,85,208,76,62,3,237,55,89, 57 | 232,50,217,64,244,157,199,121,252,90,17,212,203,149,152,140,187,234,177,73,174, 58 | 193,100,192,143,97,53,145,135,19,103,13,90,135,151,199,91,239,247,33,39,145, 59 | 101,120,99,3,186,86,99,41,237,203,111,79,220,135,158,42,30,154,120,67,87,167, 60 | 135,176,183,191,253,115,184,21,233,58,129,233,142,39,128,211,118,137,139,255, 61 | 114,20,218,113,154,27,127,246,250,1,8,198,250,209,92,222,173,21,88,102,219 62 | }; 63 | 64 | private: 65 | std::filesystem::path m_filePath; 66 | std::vector> m_voxels; 67 | }; 68 | } -------------------------------------------------------------------------------- /Assignment03/Content/Common/Maskonaive2_1024.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Assignment03/Content/Common/Maskonaive2_1024.dds -------------------------------------------------------------------------------- /Assignment03/Game/Shaders/CubeMap_PS.hlsl: -------------------------------------------------------------------------------- 1 | #include "CubeMap.fxh" 2 | -------------------------------------------------------------------------------- /Assignment03/Game/Shaders/CubeMap_VS.hlsl: -------------------------------------------------------------------------------- 1 | #include "CubeMap.fxh" 2 | -------------------------------------------------------------------------------- /Assignment03/Library/Light/PointLight.cpp: -------------------------------------------------------------------------------- 1 | #include "Light/PointLight.h" 2 | 3 | #include "Renderer/DataTypes.h" 4 | 5 | namespace library 6 | { 7 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 8 | Method: PointLight::PointLight 9 | 10 | Summary: Constructor 11 | 12 | Args: const XMFLOAT4& position 13 | Position of the light 14 | const XMFLOAT4& color 15 | Position of the color 16 | FLOAT attenuationDistance 17 | Attenuation distance 18 | 19 | Modifies: [m_position, m_color, m_attenuationDistance]. 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: PointLight::PointLight definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: PointLight::GetPosition 27 | 28 | Summary: Returns the position of the light 29 | 30 | Returns: const XMFLOAT4& 31 | Position of the light 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: PointLight::GetPosition definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: PointLight::GetColor 39 | 40 | Summary: Returns the color of the light 41 | 42 | Returns: const XMFLOAT4& 43 | Color of the light 44 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 45 | /*-------------------------------------------------------------------- 46 | TODO: PointLight::GetColor definition (remove the comment) 47 | --------------------------------------------------------------------*/ 48 | 49 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 50 | Method: PointLight::GetAttenuationDistance 51 | 52 | Summary: Returns the attenuation distance 53 | 54 | Returns: FLOAT 55 | Attenuation distance 56 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 57 | /*-------------------------------------------------------------------- 58 | TODO: PointLight::GetAttenuationDistance definition (remove the comment) 59 | --------------------------------------------------------------------*/ 60 | 61 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 62 | Method: PointLight::Update 63 | 64 | Summary: Updates the light every frame 65 | 66 | Args: FLOAT deltaTime 67 | Elapsed time 68 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 69 | void PointLight::Update(_In_ FLOAT deltaTime) 70 | { 71 | UNREFERENCED_PARAMETER(deltaTime); 72 | } 73 | } -------------------------------------------------------------------------------- /Assignment03/Library/Light/PointLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | #include "Shader/PixelShader.h" 6 | 7 | namespace library 8 | { 9 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 10 | Class: PointLight 11 | 12 | Summary: Point light that emits a light from a single point to 13 | every direction 14 | 15 | Methods: GetPosition 16 | Returns the position of the light 17 | GetColor 18 | Returns the color of the light 19 | Update 20 | Updates the light 21 | PointLight 22 | Constructor. 23 | ~PointLight 24 | Destructor. 25 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 26 | class PointLight 27 | { 28 | public: 29 | PointLight() = delete; 30 | PointLight(_In_ const XMFLOAT4& position, _In_ const XMFLOAT4& color, _In_ FLOAT attenuationDistance); 31 | PointLight(const PointLight& other) = default; 32 | PointLight(PointLight&& other) = default; 33 | PointLight& operator=(const PointLight& other) = default; 34 | PointLight& operator=(PointLight&& other) = default; 35 | virtual ~PointLight() = default; 36 | 37 | const XMFLOAT4& GetPosition() const; 38 | const XMFLOAT4& GetColor() const; 39 | FLOAT GetAttenuationDistance() const; 40 | 41 | virtual void Update(_In_ FLOAT deltaTime); 42 | 43 | protected: 44 | XMFLOAT4 m_position; 45 | XMFLOAT4 m_color; 46 | FLOAT m_attenuationDistance; 47 | }; 48 | } -------------------------------------------------------------------------------- /Assignment03/Library/Renderer/Skybox.cpp: -------------------------------------------------------------------------------- 1 | #include "Renderer/Skybox.h" 2 | 3 | #include "assimp/Importer.hpp" // C++ importer interface 4 | #include "assimp/scene.h" // output data structure 5 | #include "assimp/postprocess.h" // post processing flags 6 | 7 | namespace library 8 | { 9 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 10 | Method: Skybox::Skybox 11 | 12 | Summary: Constructor 13 | 14 | Args: const std::filesystem::path& cubeMapFilePath 15 | Path to the cube map texture to use 16 | FLOAT scale 17 | Scaling factor 18 | 19 | Modifies: [m_cubeMapFileName, m_scale]. 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: Skybox::Skybox definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: Skybox::Initialize 27 | 28 | Summary: Initializes the skybox and cube map texture 29 | 30 | Args: ID3D11Device* pDevice 31 | The Direct3D device to create the buffers 32 | ID3D11DeviceContext* pImmediateContext 33 | The Direct3D context to set buffers 34 | 35 | Modifies: [m_aMeshes, m_aMaterials]. 36 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 37 | /*-------------------------------------------------------------------- 38 | TODO: Skybox::Initialize definition (remove the comment) 39 | --------------------------------------------------------------------*/ 40 | 41 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 42 | Method: Skybox::GetSkyboxTexture 43 | 44 | Summary: Returns the cube map texture 45 | 46 | Returns: const std::shared_ptr& 47 | Cube map texture object 48 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 49 | /*-------------------------------------------------------------------- 50 | TODO: Skybox::GetSkyboxTexture definition (remove the comment) 51 | --------------------------------------------------------------------*/ 52 | 53 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 54 | Method: Skybox::initSingleMesh 55 | 56 | Summary: Initialize single mesh from a given assimp mesh 57 | 58 | Args: UINT uMeshIndex 59 | Mesh index 60 | const aiMesh* pMesh 61 | Point to an assimp mesh object 62 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 63 | /*-------------------------------------------------------------------- 64 | TODO: Skybox::initSingleMesh definition (remove the comment) 65 | --------------------------------------------------------------------*/ 66 | } -------------------------------------------------------------------------------- /Assignment03/Library/Renderer/Skybox.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: SKYBOX.H 3 | 4 | Summary: Skybox header file contains declarations of Skybox class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Skybox 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Model/Model.h" 17 | 18 | namespace library 19 | { 20 | class Skybox : public Model 21 | { 22 | public: 23 | Skybox(_In_ const std::filesystem::path& cubeMapFilePath, _In_ FLOAT scale); 24 | Skybox(const Skybox& other) = delete; 25 | Skybox(Skybox&& other) = delete; 26 | Skybox& operator=(const Skybox& other) = delete; 27 | Skybox& operator=(Skybox&& other) = delete; 28 | ~Skybox() = default; 29 | 30 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) override; 31 | //virtual void Update(_In_ FLOAT deltaTime, _In_ const XMVECTOR& lightPosition); 32 | 33 | const std::shared_ptr& GetSkyboxTexture() const; 34 | 35 | protected: 36 | virtual void initSingleMesh(_In_ UINT uMeshIndex, _In_ const aiMesh* pMesh) override; 37 | 38 | protected: 39 | std::filesystem::path m_cubeMapFileName; 40 | FLOAT m_scale; 41 | }; 42 | } -------------------------------------------------------------------------------- /Assignment03/Library/Shader/SkyMapVertexShader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader/SkyMapVertexShader.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: SkyMapVertexShader::SkyMapVertexShader 7 | 8 | Summary: Constructor 9 | 10 | Args: PCWSTR pszFileName 11 | Name of the file that contains the shader code 12 | PCSTR pszEntryPoint 13 | Name of the shader entry point functino where shader 14 | execution begins 15 | PCSTR pszShaderModel 16 | Specifies the shader target or set of shader features 17 | to compile against 18 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 19 | /*-------------------------------------------------------------------- 20 | TODO: SkyMapVertexShader::SkyMapVertexShader definition (remove the comment) 21 | --------------------------------------------------------------------*/ 22 | 23 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 24 | Method: SkyMapVertexShader::Initialize 25 | 26 | Summary: Initializes the vertex shader and the input layout 27 | 28 | Args: ID3D11Device* pDevice 29 | The Direct3D device to create the vertex shader 30 | 31 | Returns: HRESULT 32 | Status code 33 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 34 | /*-------------------------------------------------------------------- 35 | TODO: SkyMapVertexShader::Initialize definition (remove the comment) 36 | --------------------------------------------------------------------*/ 37 | } -------------------------------------------------------------------------------- /Assignment03/Library/Shader/SkyMapVertexShader.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: SKYMAPVERTEXSHADER.H 3 | 4 | Summary: SkyMapVertexShader header file contains declarations of 5 | SkyMapVertexShader class used for the lab samples of 6 | Game Graphics Programming course. 7 | 8 | Classes: SkyMapVertexShader 9 | 10 | ?2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Shader/VertexShader.h" 17 | 18 | namespace library 19 | { 20 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 21 | Class: SkyMapVertexShader 22 | 23 | Summary: Sky map vertex shader 24 | 25 | Methods: Initialize 26 | Initializes the vertex shader and the input layout 27 | SkyMapVertexShader 28 | Constructor. 29 | ~SkyMapVertexShader 30 | Destructor. 31 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 32 | class SkyMapVertexShader : public VertexShader 33 | { 34 | public: 35 | SkyMapVertexShader() = delete; 36 | SkyMapVertexShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel); 37 | SkyMapVertexShader(const SkyMapVertexShader& other) = delete; 38 | SkyMapVertexShader(SkyMapVertexShader&& other) = delete; 39 | SkyMapVertexShader& operator=(const SkyMapVertexShader& other) = delete; 40 | SkyMapVertexShader& operator=(SkyMapVertexShader&& other) = delete; 41 | virtual ~SkyMapVertexShader() = default; 42 | 43 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice) override; 44 | }; 45 | } -------------------------------------------------------------------------------- /Assignment03/Library/Texture/Texture.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: TEXTURE.H 3 | 4 | Summary: Texture header file contains declaration of class 5 | Texture used to abstract texture data. 6 | 7 | Classes: Texture 8 | 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | namespace library 16 | { 17 | enum class eTextureSamplerType : size_t 18 | { 19 | TRILINEAR_WRAP = 0, 20 | TRILINEAR_CLAMP, 21 | COUNT, 22 | }; 23 | 24 | class Texture 25 | { 26 | public: 27 | Texture() = delete; 28 | Texture(_In_ const std::filesystem::path& filePath, _In_opt_ eTextureSamplerType textureSamplerType = eTextureSamplerType::TRILINEAR_WRAP); 29 | Texture(const Texture& other) = delete; 30 | Texture(Texture&& other) = delete; 31 | Texture& operator=(const Texture& other) = delete; 32 | Texture& operator=(Texture&& other) = delete; 33 | virtual ~Texture() = default; 34 | 35 | // Should be called once to load the texture 36 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext); 37 | 38 | ComPtr& GetTextureResourceView(); 39 | eTextureSamplerType GetSamplerType() const; 40 | 41 | public: 42 | static ComPtr s_samplers[static_cast(eTextureSamplerType::COUNT)]; 43 | 44 | protected: 45 | std::filesystem::path m_filePath; 46 | ComPtr m_textureRV; 47 | eTextureSamplerType m_textureSamplerType; 48 | }; 49 | } -------------------------------------------------------------------------------- /Lab00/Game/Main.cpp: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MAIN.CPP 3 | 4 | Summary: This application serves as a test code for the project 5 | 6 | Origin: http://msdn.microsoft.com/en-us/library/windows/apps/ff729718.aspx 7 | 8 | Originally created by Microsoft Corporation under MIT License 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | 12 | #include "Common.h" 13 | 14 | #include "Game/Game.h" 15 | 16 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 17 | Function: wWinMain 18 | 19 | Summary: Entry point to the program. Initializes everything and 20 | goes into a message processing loop. Idle time is used to 21 | render the scene. 22 | 23 | Args: HINSTANCE hInstance 24 | Handle to an instance. 25 | HINSTANCE hPrevInstance 26 | Has no meaning. 27 | LPWSTR lpCmdLine 28 | Contains the command-line arguments as a Unicode 29 | string 30 | INT nCmdShow 31 | Flag that says whether the main application window 32 | will be minimized, maximized, or shown normally 33 | 34 | Returns: INT 35 | Status code. 36 | -----------------------------------------------------------------F-F*/ 37 | INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ INT nCmdShow) 38 | { 39 | library::PrintHi(); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /Lab00/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #include -------------------------------------------------------------------------------- /Lab00/Library/Game/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game/Game.h" 2 | 3 | namespace library 4 | { 5 | /*-------------------------------------------------------------------- 6 | Function definitions 7 | --------------------------------------------------------------------*/ 8 | void PrintHi() 9 | { 10 | OutputDebugString(L"hi\n"); 11 | MessageBox(nullptr, L"hi", L"Game Graphics Programming", MB_OK); 12 | } 13 | } -------------------------------------------------------------------------------- /Lab00/Library/Game/Game.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: GAME.H 3 | 4 | Summary: Game header file that contains declarations of functinos 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Functions: PrintHi 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | namespace library 17 | { 18 | /*-------------------------------------------------------------------- 19 | Forward declarations 20 | --------------------------------------------------------------------*/ 21 | 22 | /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F 23 | Function: Render 24 | 25 | Summary: Render the frame 26 | F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/ 27 | void PrintHi(); 28 | } -------------------------------------------------------------------------------- /Lab00/README.md: -------------------------------------------------------------------------------- 1 | # Lab 00: Project Setup 2 | 3 | Students registered in the Game Graphics Programming course will conduct each lab based on Direct3D 11. Each lab works are an incremental development of a basic rendering engine, thus they are not independent. For this reason, we recommend the students to stay focused to the teaching assistant (TA). Through this lab, one can setup a Visual Studio project used throughout the course 4 | 5 | [Helper slide](https://docs.google.com/presentation/d/14K1EJLWg3fW3qnwYd_aw__YbyvZlckzfHxKBKE3A6kM/edit?usp=sharing) -------------------------------------------------------------------------------- /Lab01/Game/Main.cpp: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MAIN.CPP 3 | 4 | Summary: This application demonstrates creating a Direct3D 11 device 5 | 6 | Origin: http://msdn.microsoft.com/en-us/library/windows/apps/ff729718.aspx 7 | 8 | Originally created by Microsoft Corporation under MIT License 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | 12 | #include "Common.h" 13 | 14 | #include "Game/Game.h" 15 | 16 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 17 | Function: wWinMain 18 | 19 | Summary: Entry point to the program. Initializes everything and 20 | goes into a message processing loop. Idle time is used to 21 | render the scene. 22 | 23 | Args: HINSTANCE hInstance 24 | Handle to an instance. 25 | HINSTANCE hPrevInstance 26 | Has no meaning. 27 | LPWSTR lpCmdLine 28 | Contains the command-line arguments as a Unicode 29 | string 30 | INT nCmdShow 31 | Flag that says whether the main application window 32 | will be minimized, maximized, or shown normally 33 | 34 | Returns: INT 35 | Status code. 36 | -----------------------------------------------------------------F-F*/ 37 | INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ INT nCmdShow) 38 | { 39 | /*-------------------------------------------------------------------- 40 | TODO: Unreferenced parameters (remove the comment) 41 | --------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------- 44 | TODO: Initialization (remove the comment) 45 | --------------------------------------------------------------------*/ 46 | 47 | // Main message loop 48 | MSG msg = { 0 }; 49 | 50 | /*-------------------------------------------------------------------- 51 | TODO: Main message loop (remove the comment) 52 | --------------------------------------------------------------------*/ 53 | 54 | /*-------------------------------------------------------------------- 55 | TODO: Destroy (remove the comment) 56 | --------------------------------------------------------------------*/ 57 | 58 | return static_cast(msg.wParam); 59 | } 60 | -------------------------------------------------------------------------------- /Lab01/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include "Resource.h" 24 | 25 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 26 | 27 | using namespace DirectX; -------------------------------------------------------------------------------- /Lab01/Library/Game/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game/Game.h" 2 | 3 | namespace library 4 | { 5 | /*-------------------------------------------------------------------- 6 | Global Variables 7 | --------------------------------------------------------------------*/ 8 | /*-------------------------------------------------------------------- 9 | TODO: Initialize global variables (remove the comment) 10 | --------------------------------------------------------------------*/ 11 | 12 | /*-------------------------------------------------------------------- 13 | Forward declarations 14 | --------------------------------------------------------------------*/ 15 | 16 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 17 | Function: WindowProc 18 | 19 | Summary: Defines the behavior of the window—its appearance, how 20 | it interacts with the user, and so forth 21 | 22 | Args: HWND hWnd 23 | Handle to the window 24 | UINT uMsg 25 | Message code 26 | WPARAM wParam 27 | Additional data that pertains to the message 28 | LPARAM lParam 29 | Additional data that pertains to the message 30 | 31 | Returns: LRESULT 32 | Integer value that your program returns to Windows 33 | -----------------------------------------------------------------F-F*/ 34 | LRESULT CALLBACK WindowProc(_In_ HWND hWnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam); 35 | 36 | /*-------------------------------------------------------------------- 37 | TODO: Function definitions (remove this comment) 38 | --------------------------------------------------------------------*/ 39 | } -------------------------------------------------------------------------------- /Lab01/Library/Game/Game.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: GAME.H 3 | 4 | Summary: Game header file that contains declarations of functinos 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Functions: InitWindow, InitDevice, CleanupDevice, Render 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | namespace library 17 | { 18 | /*-------------------------------------------------------------------- 19 | Forward declarations 20 | --------------------------------------------------------------------*/ 21 | 22 | /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F 23 | Function: InitWindow 24 | 25 | Summary: Registers the window class and creates a window 26 | 27 | Args: HINSTANCE hInstance 28 | Handle to the instance 29 | INT nCmdShow 30 | Is a flag that says whether the main application window 31 | will be minimized, maximized, or shown normally 32 | 33 | Returns: HRESULT 34 | Status code 35 | F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/ 36 | HRESULT InitWindow(_In_ HINSTANCE hInstance, _In_ INT nCmdShow); 37 | 38 | /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F 39 | Function: InitDevice 40 | 41 | Summary: Create Direct3D device and swap chain 42 | 43 | Returns: HRESULT 44 | Status code 45 | F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/ 46 | HRESULT InitDevice(); 47 | 48 | /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F 49 | Function: CleanupDevice 50 | 51 | Summary: Clean up the objects we've created 52 | F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/ 53 | void CleanupDevice(); 54 | 55 | /*F+F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F+++F 56 | Function: Render 57 | 58 | Summary: Render the frame 59 | F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F---F-F*/ 60 | void Render(); 61 | } -------------------------------------------------------------------------------- /Lab01/Library/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | #define IDR_MAINFRAME 128 9 | #define IDD_TUTORIAL1_DIALOG 102 10 | #define IDD_ABOUTBOX 103 11 | #define IDM_ABOUT 104 12 | #define IDM_EXIT 105 13 | #define IDI_TUTORIAL1 107 14 | #define IDI_SMALL 108 15 | #define IDC_TUTORIAL1 109 16 | #define IDC_MYICON 2 17 | #define IDC_STATIC -1 18 | // Next default values for new objects 19 | // 20 | #ifdef APSTUDIO_INVOKED 21 | #ifndef APSTUDIO_READONLY_SYMBOLS 22 | 23 | #define _APS_NO_MFC 130 24 | #define _APS_NEXT_RESOURCE_VALUE 129 25 | #define _APS_NEXT_COMMAND_VALUE 32771 26 | #define _APS_NEXT_CONTROL_VALUE 1000 27 | #define _APS_NEXT_SYMED_VALUE 110 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /Lab01/Library/Resource.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 17 | LANGUAGE 9, 1 18 | #pragma code_page(1252) 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | // 22 | // Icon 23 | // 24 | 25 | // Icon with lowest ID value placed first to ensure application icon 26 | // remains consistent on all systems. 27 | 28 | IDI_TUTORIAL1 ICON "directx.ico" 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | // 32 | // Menu 33 | // 34 | 35 | IDC_TUTORIAL1 MENU 36 | BEGIN 37 | POPUP "&File" 38 | BEGIN 39 | MENUITEM "E&xit", IDM_EXIT 40 | END 41 | POPUP "&Help" 42 | BEGIN 43 | MENUITEM "&About ...", IDM_ABOUT 44 | END 45 | END 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Accelerator 51 | // 52 | 53 | IDC_TUTORIAL1 ACCELERATORS 54 | BEGIN 55 | "?", IDM_ABOUT, ASCII, ALT 56 | "/", IDM_ABOUT, ASCII, ALT 57 | END 58 | 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Dialog 63 | // 64 | 65 | IDD_ABOUTBOX DIALOG 22, 17, 230, 75 66 | STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU 67 | CAPTION "About" 68 | FONT 8, "System" 69 | BEGIN 70 | ICON IDI_TUTORIAL1, IDC_MYICON, 14, 9, 16, 16 71 | LTEXT "Tutorial01 Version 1.0", IDC_STATIC, 49, 10, 119, 8, SS_NOPREFIX 72 | LTEXT "Copyright (c) Microsoft Corporation.", IDC_STATIC, 49, 20, 119, 8 73 | DEFPUSHBUTTON "OK", IDOK, 195, 6, 30, 11, WS_GROUP 74 | END 75 | 76 | 77 | #ifdef APSTUDIO_INVOKED 78 | ///////////////////////////////////////////////////////////////////////////// 79 | // 80 | // TEXTINCLUDE 81 | // 82 | 1 TEXTINCLUDE 83 | BEGIN 84 | "resource.h\0" 85 | END 86 | 87 | 2 TEXTINCLUDE 88 | BEGIN 89 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 90 | "#include ""windows.h""\r\n" 91 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 92 | "\0" 93 | END 94 | 95 | 3 TEXTINCLUDE 96 | BEGIN 97 | "\r\n" 98 | "\0" 99 | END 100 | 101 | #endif // APSTUDIO_INVOKED 102 | 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // String Table 106 | // 107 | 108 | STRINGTABLE 109 | BEGIN 110 | IDC_TUTORIAL1 "Tutorial01" 111 | IDS_APP_TITLE "Tutorial01" 112 | END 113 | 114 | #endif 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | 118 | 119 | #ifndef APSTUDIO_INVOKED 120 | ///////////////////////////////////////////////////////////////////////////// 121 | // 122 | // Generated from the TEXTINCLUDE 3 resource. 123 | // 124 | 125 | 126 | ///////////////////////////////////////////////////////////////////////////// 127 | #endif // not APSTUDIO_INVOKED -------------------------------------------------------------------------------- /Lab01/Library/directx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab01/Library/directx.ico -------------------------------------------------------------------------------- /Lab01/README.md: -------------------------------------------------------------------------------- 1 | # Lab 01: Direct3D 11 Basics 2 | 3 | Students registered in the Game Graphics Programming course will conduct each lab based on Direct3D 11. Each lab works are an incremental development of a basic rendering engine, thus they are not independent. For this reason, we recommend the students to stay focused to the teaching assistant (TA). Through this lab, one can develop a Direct3D 11 environment based on Windows operating system. 4 | 5 | [Helper slide](https://docs.google.com/presentation/d/1VUBXB72ItOfdCPAgiTuBsBEHLRsJBJ_ql15hEzeopdQ/edit?usp=sharing) -------------------------------------------------------------------------------- /Lab02/Game/Main.cpp: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MAIN.CPP 3 | 4 | Summary: This application demonstrates creating a Direct3D 11 5 | device in a object-oriented fashion 6 | 7 | Origin: https://docs.microsoft.com/en-us/previous-versions//ff729719(v=vs.85) 8 | 9 | Originally created by Microsoft Corporation under MIT License 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | 13 | #include "Common.h" 14 | 15 | #include 16 | 17 | #include "Game/Game.h" 18 | 19 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 20 | Function: wWinMain 21 | 22 | Summary: Entry point to the program. Initializes everything and 23 | goes into a message processing loop. Idle time is used to 24 | render the scene. 25 | 26 | Args: HINSTANCE hInstance 27 | Handle to an instance. 28 | HINSTANCE hPrevInstance 29 | Has no meaning. 30 | LPWSTR lpCmdLine 31 | Contains the command-line arguments as a Unicode 32 | string 33 | INT nCmdShow 34 | Flag that says whether the main application window 35 | will be minimized, maximized, or shown normally 36 | 37 | Returns: INT 38 | Status code. 39 | -----------------------------------------------------------------F-F*/ 40 | INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ INT nCmdShow) 41 | { 42 | UNREFERENCED_PARAMETER(hPrevInstance); 43 | UNREFERENCED_PARAMETER(lpCmdLine); 44 | 45 | std::unique_ptr game = std::make_unique(L"Game Graphics Programming Lab 02: Object Oriented Design"); 46 | 47 | if (FAILED(game->Initialize(hInstance, nCmdShow))) 48 | { 49 | return 0; 50 | } 51 | 52 | return game->Run(); 53 | } -------------------------------------------------------------------------------- /Lab02/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include "Resource.h" 27 | 28 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 29 | 30 | using namespace DirectX; 31 | using namespace Microsoft::WRL; -------------------------------------------------------------------------------- /Lab02/Library/Game/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game/Game.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: Game::Game 7 | 8 | Summary: Constructor 9 | 10 | Args: PCWSTR pszGameName 11 | Name of the game 12 | 13 | Modifies: [m_pszGameName, m_mainWindow, m_renderer]. 14 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 15 | /*-------------------------------------------------------------------- 16 | TODO: Game::Game definition (remove the comment) 17 | --------------------------------------------------------------------*/ 18 | 19 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 20 | Method: Game::Initialize 21 | 22 | Summary: Initializes the components of the game 23 | 24 | Args: HINSTANCE hInstance 25 | Handle to the instance 26 | INT nCmdShow 27 | Is a flag that says whether the main application window 28 | will be minimized, maximized, or shown normally 29 | 30 | Modifies: [m_mainWindow, m_renderer]. 31 | 32 | Returns: HRESULT 33 | Status code 34 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 35 | /*-------------------------------------------------------------------- 36 | TODO: Game::Initialize definition (remove the comment) 37 | --------------------------------------------------------------------*/ 38 | 39 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 40 | Method: Game::Run 41 | 42 | Summary: Runs the game loop 43 | 44 | Returns: INT 45 | Status code to return to the operating system 46 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 47 | /*-------------------------------------------------------------------- 48 | TODO: Game::Run definition (remove the comment) 49 | --------------------------------------------------------------------*/ 50 | 51 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 52 | Method: Game::GetGameName 53 | 54 | Summary: Returns the name of the game 55 | 56 | Returns: PCWSTR 57 | Name of the game 58 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 59 | /*-------------------------------------------------------------------- 60 | TODO: Game::GetGameName definition (remove the comment) 61 | --------------------------------------------------------------------*/ 62 | 63 | } -------------------------------------------------------------------------------- /Lab02/Library/Game/Game.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: GAME.H 3 | 4 | Summary: Game header file that contains declarations of functinos 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Game 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/Renderer.h" 17 | #include "Window/MainWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: Game 23 | 24 | Summary: Main game engine class 25 | 26 | Methods: Initialize 27 | Initializes the components of the game 28 | Run 29 | Runs the game loop 30 | GetGameName 31 | Returns the name of the game 32 | Game 33 | Constructor. 34 | ~Game 35 | Destructor. 36 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 37 | class Game final 38 | { 39 | public: 40 | Game(_In_ PCWSTR pszGameName); 41 | Game(const Game& other) = delete; 42 | Game(Game&& other) = delete; 43 | Game& operator=(const Game& other) = delete; 44 | Game& operator=(Game&& other) = delete; 45 | ~Game() = default; 46 | 47 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow); 48 | 49 | INT Run(); 50 | 51 | PCWSTR GetGameName() const; 52 | private: 53 | PCWSTR m_pszGameName; 54 | std::unique_ptr m_mainWindow; 55 | std::unique_ptr m_renderer; 56 | }; 57 | } -------------------------------------------------------------------------------- /Lab02/Library/Renderer/Renderer.cpp: -------------------------------------------------------------------------------- 1 | #include "Renderer/Renderer.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: Renderer::Renderer 7 | 8 | Summary: Constructor 9 | 10 | Modifies: [m_driverType, m_featureLevel, m_d3dDevice, m_d3dDevice1, 11 | m_immediateContext, m_immediateContext1, m_swapChain, 12 | m_swapChain1, m_renderTargetView]. 13 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 14 | /*-------------------------------------------------------------------- 15 | TODO: Renderer::Renderer definition (remove the comment) 16 | --------------------------------------------------------------------*/ 17 | 18 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 19 | Method: Renderer::Initialize 20 | 21 | Summary: Creates Direct3D device and swap chain 22 | 23 | Args: HWND hWnd 24 | Handle to the window 25 | 26 | Modifies: [m_d3dDevice, m_featureLevel, m_immediateContext, 27 | m_d3dDevice1, m_immediateContext1, m_swapChain1, 28 | m_swapChain, m_renderTargetView]. 29 | 30 | Returns: HRESULT 31 | Status code 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: Renderer::Initialize definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: Renderer::Render 39 | 40 | Summary: Render the frame 41 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 42 | /*-------------------------------------------------------------------- 43 | TODO: Renderer::Initialize definition (remove the comment) 44 | --------------------------------------------------------------------*/ 45 | } -------------------------------------------------------------------------------- /Lab02/Library/Renderer/Renderer.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: RENDERER.H 3 | 4 | Summary: Renderer header file contains declarations of Renderer 5 | class used for the lab samples of Game Graphics 6 | Programming course. 7 | 8 | Classes: Renderer 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Window/MainWindow.h" 17 | 18 | namespace library 19 | { 20 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 21 | Class: Renderer 22 | 23 | Summary: Renderer initializes Direct3D, and renders renderable 24 | data onto the screen 25 | 26 | Methods: Initialize 27 | Creates Direct3D device and swap chain 28 | Render 29 | Renders the frame 30 | Renderer 31 | Constructor. 32 | ~Renderer 33 | Destructor. 34 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 35 | class Renderer final 36 | { 37 | public: 38 | Renderer(); 39 | Renderer(const Renderer& other) = delete; 40 | Renderer(Renderer&& other) = delete; 41 | Renderer& operator=(const Renderer& other) = delete; 42 | Renderer& operator=(Renderer&& other) = delete; 43 | ~Renderer() = default; 44 | 45 | HRESULT Initialize(_In_ HWND hWnd); 46 | void Render(); 47 | 48 | private: 49 | D3D_DRIVER_TYPE m_driverType; 50 | D3D_FEATURE_LEVEL m_featureLevel; 51 | ComPtr m_d3dDevice; 52 | ComPtr m_d3dDevice1; 53 | ComPtr m_immediateContext; 54 | ComPtr m_immediateContext1; 55 | ComPtr m_swapChain; 56 | ComPtr m_swapChain1; 57 | ComPtr m_renderTargetView; 58 | }; 59 | } -------------------------------------------------------------------------------- /Lab02/Library/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | #define IDR_MAINFRAME 128 9 | #define IDD_TUTORIAL_DIALOG 102 10 | #define IDD_ABOUTBOX 103 11 | #define IDM_ABOUT 104 12 | #define IDM_EXIT 105 13 | #define IDI_TUTORIAL 107 14 | #define IDI_SMALL 108 15 | #define IDC_TUTORIAL 109 16 | #define IDC_MYICON 2 17 | #define IDC_STATIC -1 18 | // Next default values for new objects 19 | // 20 | #ifdef APSTUDIO_INVOKED 21 | #ifndef APSTUDIO_READONLY_SYMBOLS 22 | 23 | #define _APS_NO_MFC 130 24 | #define _APS_NEXT_RESOURCE_VALUE 129 25 | #define _APS_NEXT_COMMAND_VALUE 32771 26 | #define _APS_NEXT_CONTROL_VALUE 1000 27 | #define _APS_NEXT_SYMED_VALUE 110 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /Lab02/Library/Resource.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 17 | LANGUAGE 9, 1 18 | #pragma code_page(1252) 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | // 22 | // Icon 23 | // 24 | 25 | // Icon with lowest ID value placed first to ensure application icon 26 | // remains consistent on all systems. 27 | 28 | IDI_TUTORIAL ICON "directx.ico" 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | // 32 | // Menu 33 | // 34 | 35 | IDC_TUTORIAL MENU 36 | BEGIN 37 | POPUP "&File" 38 | BEGIN 39 | MENUITEM "E&xit", IDM_EXIT 40 | END 41 | POPUP "&Help" 42 | BEGIN 43 | MENUITEM "&About ...", IDM_ABOUT 44 | END 45 | END 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Accelerator 51 | // 52 | 53 | IDC_TUTORIAL ACCELERATORS 54 | BEGIN 55 | "?", IDM_ABOUT, ASCII, ALT 56 | "/", IDM_ABOUT, ASCII, ALT 57 | END 58 | 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Dialog 63 | // 64 | 65 | IDD_ABOUTBOX DIALOG 22, 17, 230, 75 66 | STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU 67 | CAPTION "About" 68 | FONT 8, "System" 69 | BEGIN 70 | ICON IDI_TUTORIAL, IDC_MYICON, 14, 9, 16, 16 71 | LTEXT "Lab02 Version 1.0", IDC_STATIC, 49, 10, 119, 8, SS_NOPREFIX 72 | LTEXT "Copyright (c) Microsoft Corporation.", IDC_STATIC, 49, 20, 119, 8 73 | DEFPUSHBUTTON "OK", IDOK, 195, 6, 30, 11, WS_GROUP 74 | END 75 | 76 | 77 | #ifdef APSTUDIO_INVOKED 78 | ///////////////////////////////////////////////////////////////////////////// 79 | // 80 | // TEXTINCLUDE 81 | // 82 | 1 TEXTINCLUDE 83 | BEGIN 84 | "resource.h\0" 85 | END 86 | 87 | 2 TEXTINCLUDE 88 | BEGIN 89 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 90 | "#include ""windows.h""\r\n" 91 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 92 | "\0" 93 | END 94 | 95 | 3 TEXTINCLUDE 96 | BEGIN 97 | "\r\n" 98 | "\0" 99 | END 100 | 101 | #endif // APSTUDIO_INVOKED 102 | 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // String Table 106 | // 107 | 108 | STRINGTABLE 109 | BEGIN 110 | IDC_TUTORIAL "Lab02" 111 | IDS_APP_TITLE "Lab02" 112 | END 113 | 114 | #endif 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | 118 | 119 | #ifndef APSTUDIO_INVOKED 120 | ///////////////////////////////////////////////////////////////////////////// 121 | // 122 | // Generated from the TEXTINCLUDE 3 resource. 123 | // 124 | 125 | 126 | ///////////////////////////////////////////////////////////////////////////// 127 | #endif // not APSTUDIO_INVOKED -------------------------------------------------------------------------------- /Lab02/Library/Window/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "Window/MainWindow.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: MainWindow::Initialize 7 | 8 | Summary: Initializes main window 9 | 10 | Args: HINSTANCE hInstance 11 | Handle to the instance 12 | INT nCmdShow 13 | Is a flag that says whether the main application window 14 | will be minimized, maximized, or shown normally 15 | PCWSTR pszWindowName 16 | The window name 17 | 18 | Returns: HRESULT 19 | Status code 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: MainWindow::Initialize definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: MainWindow::GetWindowClassName 27 | 28 | Summary: Returns the name of the window class 29 | 30 | Returns: PCWSTR 31 | Name of the window class 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: MainWindow::GetWindowClassName definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: MainWindow::HandleMessage 39 | 40 | Summary: Handles the messages 41 | 42 | Args: UINT uMessage 43 | Message code 44 | WPARAM wParam 45 | Additional data the pertains to the message 46 | LPARAM lParam 47 | Additional data the pertains to the message 48 | 49 | Returns: LRESULT 50 | Integer value that your program returns to Windows 51 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 52 | /*-------------------------------------------------------------------- 53 | TODO: MainWindow::HandleMessage definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | } 56 | -------------------------------------------------------------------------------- /Lab02/Library/Window/MainWindow.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: BASEWINDOW.H 3 | 4 | Summary: BaseWindow header file contains declarations of the 5 | base class of all windows used in the library. 6 | 7 | Classes: BaseWindow 8 | 9 | Functions: InitWindow, InitDevice 10 | 11 | © 2022 Kyung Hee University 12 | ===================================================================+*/ 13 | #pragma once 14 | 15 | #include "Common.h" 16 | 17 | #include "Window/BaseWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: MainWindow 23 | 24 | Summary: Main window to be used in game engine 25 | 26 | Methods: Initialize 27 | Initializes window 28 | GetWindowClassName 29 | Returns the name of the window class 30 | HandleMessage 31 | Handles the messages 32 | MainWindow 33 | Constructor. 34 | ~MainWindow 35 | Destructor. 36 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 37 | class MainWindow : public BaseWindow 38 | { 39 | public: 40 | MainWindow() = default; 41 | MainWindow(const MainWindow& other) = delete; 42 | MainWindow(MainWindow&& other) = delete; 43 | MainWindow& operator=(const MainWindow& other) = delete; 44 | MainWindow& operator=(MainWindow&& other) = delete; 45 | virtual ~MainWindow() = default; 46 | 47 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow, _In_ PCWSTR pszWindowName) override; 48 | PCWSTR GetWindowClassName() const override; 49 | LRESULT HandleMessage(_In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) override; 50 | }; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Lab02/Library/directx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab02/Library/directx.ico -------------------------------------------------------------------------------- /Lab02/README.md: -------------------------------------------------------------------------------- 1 | # Lab 02: Object-Oriented Design 2 | 3 | Students registered in the Game Graphics Programming course will conduct each lab based on Direct3D 11. Each lab works are an incremental development of a basic rendering engine, thus they are not independent. For this reason, we recommend the students to stay focused to the teaching assistant (TA). Through this lab, one can reorganize their basic Direct3D 11 code object-orientedly. 4 | 5 | [Helper slide](https://docs.google.com/presentation/d/1EboB4kFQw5Jl9xPvKm8meCvp8CsxIz8E1VihRsviiAY/edit?usp=sharing) -------------------------------------------------------------------------------- /Lab03/Game/Main.cpp: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MAIN.CPP 3 | 4 | Summary: This application displays a triangle using Direct3D 11 5 | 6 | Origin: https://docs.microsoft.com/en-us/previous-versions//ff729719(v=vs.85) 7 | https://docs.microsoft.com/en-us/previous-versions//ff729720(v=vs.85) 8 | 9 | Originally created by Microsoft Corporation under MIT License 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | 13 | #include "Common.h" 14 | 15 | #include 16 | 17 | #include "Game/Game.h" 18 | 19 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 20 | Function: wWinMain 21 | 22 | Summary: Entry point to the program. Initializes everything and 23 | goes into a message processing loop. Idle time is used to 24 | render the scene. 25 | 26 | Args: HINSTANCE hInstance 27 | Handle to an instance. 28 | HINSTANCE hPrevInstance 29 | Has no meaning. 30 | LPWSTR lpCmdLine 31 | Contains the command-line arguments as a Unicode 32 | string 33 | INT nCmdShow 34 | Flag that says whether the main application window 35 | will be minimized, maximized, or shown normally 36 | 37 | Returns: INT 38 | Status code. 39 | -----------------------------------------------------------------F-F*/ 40 | INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ INT nCmdShow) 41 | { 42 | #ifdef _DEBUG 43 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 44 | #endif 45 | 46 | UNREFERENCED_PARAMETER(hPrevInstance); 47 | UNREFERENCED_PARAMETER(lpCmdLine); 48 | 49 | std::unique_ptr game = std::make_unique(L"Game Graphics Programming Lab 03: Rendering a Triangle"); 50 | 51 | if (FAILED(game->Initialize(hInstance, nCmdShow))) 52 | { 53 | return 0; 54 | } 55 | 56 | return game->Run(); 57 | } -------------------------------------------------------------------------------- /Lab03/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "Resource.h" 28 | 29 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 30 | 31 | using namespace DirectX; 32 | using namespace Microsoft::WRL; -------------------------------------------------------------------------------- /Lab03/Library/Game/Game.cpp: -------------------------------------------------------------------------------- 1 | #include "Game/Game.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: Game::Game 7 | 8 | Summary: Constructor 9 | 10 | Args: PCWSTR pszGameName 11 | Name of the game 12 | 13 | Modifies: [m_pszGameName, m_mainWindow, m_renderer]. 14 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 15 | /*-------------------------------------------------------------------- 16 | TODO: Game::Game definition (remove the comment) 17 | --------------------------------------------------------------------*/ 18 | 19 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 20 | Method: Game::Initialize 21 | 22 | Summary: Initializes the components of the game 23 | 24 | Args: HINSTANCE hInstance 25 | Handle to the instance 26 | INT nCmdShow 27 | Is a flag that says whether the main application window 28 | will be minimized, maximized, or shown normally 29 | 30 | Modifies: [m_mainWindow, m_renderer]. 31 | 32 | Returns: HRESULT 33 | Status code 34 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 35 | /*-------------------------------------------------------------------- 36 | TODO: Game::Initialize definition (remove the comment) 37 | --------------------------------------------------------------------*/ 38 | 39 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 40 | Method: Game::Run 41 | 42 | Summary: Runs the game loop 43 | 44 | Returns: INT 45 | Status code to return to the operating system 46 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 47 | /*-------------------------------------------------------------------- 48 | TODO: Game::Run definition (remove the comment) 49 | --------------------------------------------------------------------*/ 50 | 51 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 52 | Method: Game::GetGameName 53 | 54 | Summary: Returns the name of the game 55 | 56 | Returns: PCWSTR 57 | Name of the game 58 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 59 | /*-------------------------------------------------------------------- 60 | TODO: Game::GetGameName definition (remove the comment) 61 | --------------------------------------------------------------------*/ 62 | 63 | } -------------------------------------------------------------------------------- /Lab03/Library/Game/Game.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: GAME.H 3 | 4 | Summary: Game header file that contains declarations of functinos 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Game 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/Renderer.h" 17 | #include "Window/MainWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: Game 23 | 24 | Summary: Main game engine class 25 | 26 | Methods: Initialize 27 | Initializes the components of the game 28 | Run 29 | Runs the game loop 30 | GetGameName 31 | Returns the name of the game 32 | Game 33 | Constructor. 34 | ~Game 35 | Destructor. 36 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 37 | class Game final 38 | { 39 | public: 40 | Game(PCWSTR pszGameName); 41 | Game(const Game& other) = delete; 42 | Game(Game&& other) = delete; 43 | Game& operator=(const Game& other) = delete; 44 | Game& operator=(Game&& other) = delete; 45 | ~Game() = default; 46 | 47 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow); 48 | 49 | INT Run(); 50 | 51 | PCWSTR GetGameName() const; 52 | private: 53 | PCWSTR m_pszGameName; 54 | std::unique_ptr m_mainWindow; 55 | std::unique_ptr m_renderer; 56 | }; 57 | } -------------------------------------------------------------------------------- /Lab03/Library/Renderer/Renderer.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: RENDERER.H 3 | 4 | Summary: Renderer header file contains declarations of Renderer 5 | class used for the lab samples of Game Graphics 6 | Programming course. 7 | 8 | Classes: Renderer 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include 17 | 18 | #include "Window/MainWindow.h" 19 | 20 | namespace library 21 | { 22 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 23 | Struct: SimpleVertex 24 | 25 | Summary: Simple vertex structure containing a single field of the 26 | type XMFLOAT3 27 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 28 | struct SimpleVertex 29 | { 30 | XMFLOAT3 Postion; 31 | }; 32 | 33 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 34 | Class: Renderer 35 | 36 | Summary: Renderer initializes Direct3D, and renders renderable 37 | data onto the screen 38 | 39 | Methods: Initialize 40 | Creates Direct3D device and swap chain 41 | Render 42 | Renders the frame 43 | Renderer 44 | Constructor. 45 | ~Renderer 46 | Destructor. 47 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 48 | class Renderer final 49 | { 50 | public: 51 | Renderer(); 52 | Renderer(const Renderer& other) = delete; 53 | Renderer(Renderer&& other) = delete; 54 | Renderer& operator=(const Renderer& other) = delete; 55 | Renderer& operator=(Renderer&& other) = delete; 56 | ~Renderer() = default; 57 | 58 | HRESULT Initialize(_In_ HWND hWnd); 59 | void Render(); 60 | 61 | private: 62 | HRESULT compileShaderFromFile(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR szShaderModel, _Outptr_ ID3DBlob** ppBlobOut); 63 | 64 | D3D_DRIVER_TYPE m_driverType; 65 | D3D_FEATURE_LEVEL m_featureLevel; 66 | ComPtr m_d3dDevice; 67 | ComPtr m_d3dDevice1; 68 | ComPtr m_immediateContext; 69 | ComPtr m_immediateContext1; 70 | ComPtr m_swapChain; 71 | ComPtr m_swapChain1; 72 | ComPtr m_renderTargetView; 73 | ComPtr m_vertexShader; 74 | ComPtr m_pixelShader; 75 | ComPtr m_vertexLayout; 76 | ComPtr m_vertexBuffer; 77 | }; 78 | } -------------------------------------------------------------------------------- /Lab03/Library/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Resource.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | #define IDR_MAINFRAME 128 9 | #define IDD_TUTORIAL_DIALOG 102 10 | #define IDD_ABOUTBOX 103 11 | #define IDM_ABOUT 104 12 | #define IDM_EXIT 105 13 | #define IDI_TUTORIAL 107 14 | #define IDI_SMALL 108 15 | #define IDC_TUTORIAL 109 16 | #define IDC_MYICON 2 17 | #define IDC_STATIC -1 18 | // Next default values for new objects 19 | // 20 | #ifdef APSTUDIO_INVOKED 21 | #ifndef APSTUDIO_READONLY_SYMBOLS 22 | 23 | #define _APS_NO_MFC 130 24 | #define _APS_NEXT_RESOURCE_VALUE 129 25 | #define _APS_NEXT_COMMAND_VALUE 32771 26 | #define _APS_NEXT_CONTROL_VALUE 1000 27 | #define _APS_NEXT_SYMED_VALUE 110 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /Lab03/Library/Resource.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #define APSTUDIO_HIDDEN_SYMBOLS 11 | #include "windows.h" 12 | #undef APSTUDIO_HIDDEN_SYMBOLS 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 17 | LANGUAGE 9, 1 18 | #pragma code_page(1252) 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | // 22 | // Icon 23 | // 24 | 25 | // Icon with lowest ID value placed first to ensure application icon 26 | // remains consistent on all systems. 27 | 28 | IDI_TUTORIAL ICON "directx.ico" 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | // 32 | // Menu 33 | // 34 | 35 | IDC_TUTORIAL MENU 36 | BEGIN 37 | POPUP "&File" 38 | BEGIN 39 | MENUITEM "E&xit", IDM_EXIT 40 | END 41 | POPUP "&Help" 42 | BEGIN 43 | MENUITEM "&About ...", IDM_ABOUT 44 | END 45 | END 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Accelerator 51 | // 52 | 53 | IDC_TUTORIAL ACCELERATORS 54 | BEGIN 55 | "?", IDM_ABOUT, ASCII, ALT 56 | "/", IDM_ABOUT, ASCII, ALT 57 | END 58 | 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Dialog 63 | // 64 | 65 | IDD_ABOUTBOX DIALOG 22, 17, 230, 75 66 | STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU 67 | CAPTION "About" 68 | FONT 8, "System" 69 | BEGIN 70 | ICON IDI_TUTORIAL, IDC_MYICON, 14, 9, 16, 16 71 | LTEXT "Lab02 Version 1.0", IDC_STATIC, 49, 10, 119, 8, SS_NOPREFIX 72 | LTEXT "Copyright (c) Microsoft Corporation.", IDC_STATIC, 49, 20, 119, 8 73 | DEFPUSHBUTTON "OK", IDOK, 195, 6, 30, 11, WS_GROUP 74 | END 75 | 76 | 77 | #ifdef APSTUDIO_INVOKED 78 | ///////////////////////////////////////////////////////////////////////////// 79 | // 80 | // TEXTINCLUDE 81 | // 82 | 1 TEXTINCLUDE 83 | BEGIN 84 | "resource.h\0" 85 | END 86 | 87 | 2 TEXTINCLUDE 88 | BEGIN 89 | "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" 90 | "#include ""windows.h""\r\n" 91 | "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" 92 | "\0" 93 | END 94 | 95 | 3 TEXTINCLUDE 96 | BEGIN 97 | "\r\n" 98 | "\0" 99 | END 100 | 101 | #endif // APSTUDIO_INVOKED 102 | 103 | ///////////////////////////////////////////////////////////////////////////// 104 | // 105 | // String Table 106 | // 107 | 108 | STRINGTABLE 109 | BEGIN 110 | IDC_TUTORIAL "Lab02" 111 | IDS_APP_TITLE "Lab02" 112 | END 113 | 114 | #endif 115 | ///////////////////////////////////////////////////////////////////////////// 116 | 117 | 118 | 119 | #ifndef APSTUDIO_INVOKED 120 | ///////////////////////////////////////////////////////////////////////////// 121 | // 122 | // Generated from the TEXTINCLUDE 3 resource. 123 | // 124 | 125 | 126 | ///////////////////////////////////////////////////////////////////////////// 127 | #endif // not APSTUDIO_INVOKED -------------------------------------------------------------------------------- /Lab03/Library/Shaders/Lab03.fxh: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: Lab03.fx 3 | // 4 | // Copyright (c) Microsoft Corporation. 5 | // Licensed under the MIT License (MIT). 6 | //-------------------------------------------------------------------------------------- 7 | 8 | //-------------------------------------------------------------------------------------- 9 | // Vertex Shader 10 | //-------------------------------------------------------------------------------------- 11 | /*-------------------------------------------------------------------- 12 | TODO: Vertex Shader function VS definition (remove the comment) 13 | --------------------------------------------------------------------*/ 14 | 15 | 16 | //-------------------------------------------------------------------------------------- 17 | // Pixel Shader 18 | //-------------------------------------------------------------------------------------- 19 | /*-------------------------------------------------------------------- 20 | TODO: Pixel Shader function PS definition (remove the comment) 21 | --------------------------------------------------------------------*/ 22 | -------------------------------------------------------------------------------- /Lab03/Library/Shaders/Lab03_PS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Lab03.fxh" 2 | -------------------------------------------------------------------------------- /Lab03/Library/Shaders/Lab03_VS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Lab03.fxh" 2 | -------------------------------------------------------------------------------- /Lab03/Library/Window/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "Window/MainWindow.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: MainWindow::Initialize 7 | 8 | Summary: Initializes main window 9 | 10 | Args: HINSTANCE hInstance 11 | Handle to the instance 12 | INT nCmdShow 13 | Is a flag that says whether the main application window 14 | will be minimized, maximized, or shown normally 15 | PCWSTR pszWindowName 16 | The window name 17 | 18 | Returns: HRESULT 19 | Status code 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: MainWindow::Initialize definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: MainWindow::GetWindowClassName 27 | 28 | Summary: Returns the name of the window class 29 | 30 | Returns: PCWSTR 31 | Name of the window class 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: MainWindow::GetWindowClassName definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: MainWindow::HandleMessage 39 | 40 | Summary: Handles the messages 41 | 42 | Args: UINT uMessage 43 | Message code 44 | WPARAM wParam 45 | Additional data the pertains to the message 46 | LPARAM lParam 47 | Additional data the pertains to the message 48 | 49 | Returns: LRESULT 50 | Integer value that your program returns to Windows 51 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 52 | /*-------------------------------------------------------------------- 53 | TODO: MainWindow::HandleMessage definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | } 56 | -------------------------------------------------------------------------------- /Lab03/Library/Window/MainWindow.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: BASEWINDOW.H 3 | 4 | Summary: BaseWindow header file contains declarations of the 5 | base class of all windows used in the library. 6 | 7 | Classes: BaseWindow 8 | 9 | Functions: InitWindow, InitDevice 10 | 11 | © 2022 Kyung Hee University 12 | ===================================================================+*/ 13 | #pragma once 14 | 15 | #include "Common.h" 16 | 17 | #include "Window/BaseWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: MainWindow 23 | 24 | Summary: Main window to be used in game engine 25 | 26 | Methods: Initialize 27 | Initializes window 28 | GetWindowClassName 29 | Returns the name of the window class 30 | HandleMessage 31 | Handles the messages 32 | MainWindow 33 | Constructor. 34 | ~MainWindow 35 | Destructor. 36 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 37 | class MainWindow : public BaseWindow 38 | { 39 | public: 40 | MainWindow() = default; 41 | MainWindow(const MainWindow& other) = delete; 42 | MainWindow(MainWindow&& other) = delete; 43 | MainWindow& operator=(const MainWindow& other) = delete; 44 | MainWindow& operator=(MainWindow&& other) = delete; 45 | virtual ~MainWindow() = default; 46 | 47 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow, _In_ PCWSTR pszWindowName) override; 48 | PCWSTR GetWindowClassName() const override; 49 | LRESULT HandleMessage(_In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) override; 50 | }; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Lab03/Library/directx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab03/Library/directx.ico -------------------------------------------------------------------------------- /Lab03/README.md: -------------------------------------------------------------------------------- 1 | # Lab 03: Rendering a Triangle 2 | 3 | Students registered in the Game Graphics Programming course will conduct each lab based on Direct3D 11. Each lab works are an incremental development of a basic rendering engine, thus they are not independent. For this reason, we recommend the students to stay focused to the teaching assistant (TA). Through this lab, one can draw a single triangle. 4 | 5 | [Helper slide](https://docs.google.com/presentation/d/1lbKjif2n_cPhu9ATCqfkKx30IzR-oUat7XlB_TDm-g0/edit?usp=sharing) -------------------------------------------------------------------------------- /Lab04/Game/Cube/BaseCube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/BaseCube.h" 2 | 3 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 4 | Method: BaseCube::Initialize 5 | 6 | Summary: Initializes a basic cube 7 | 8 | Args: ID3D11Device* pDevice 9 | The Direct3D device to create the buffers 10 | ID3D11DeviceContext* pImmediateContext 11 | The Direct3D context to set buffers 12 | 13 | Returns: HRESULT 14 | Status code 15 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 16 | /*-------------------------------------------------------------------- 17 | TODO: BaseCube::Initialize definition (remove the comment) 18 | --------------------------------------------------------------------*/ 19 | 20 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 21 | Method: BaseCube::GetNumVertices 22 | 23 | Summary: Returns the number of vertices in the cube 24 | 25 | Returns: UINT 26 | Number of vertices 27 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 28 | /*-------------------------------------------------------------------- 29 | TODO: BaseCube::GetNumVertices definition (remove the comment) 30 | --------------------------------------------------------------------*/ 31 | 32 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 33 | Method: BaseCube::GetNumIndices 34 | 35 | Summary: Returns the number of indices in the cube 36 | 37 | Returns: UINT 38 | Number of indices 39 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 40 | /*-------------------------------------------------------------------- 41 | TODO: BaseCube::GetNumIndices definition (remove the comment) 42 | --------------------------------------------------------------------*/ 43 | 44 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 45 | Method: BaseCube::getVertices 46 | 47 | Summary: Returns the pointer to the vertices data 48 | 49 | Returns: const library::SimpleVertex* 50 | Pointer to the vertices data 51 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 52 | /*-------------------------------------------------------------------- 53 | TODO: BaseCube::getVertices definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | 56 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 57 | Method: BaseCube::getIndices 58 | 59 | Summary: Returns the pointer to the indices data 60 | 61 | Returns: const WORD* 62 | Pointer to the indices data 63 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 64 | /*-------------------------------------------------------------------- 65 | TODO: BaseCube::getIndices definition (remove the comment) 66 | --------------------------------------------------------------------*/ 67 | -------------------------------------------------------------------------------- /Lab04/Game/Cube/BaseCube.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: BASECUBE.H 3 | 4 | Summary: Base cube header file contains declarations of BaseCube 5 | class used for the lab samples of Game Graphics 6 | Programming course. 7 | 8 | Classes: Cube 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/DataTypes.h" 17 | #include "Renderer/Renderable.h" 18 | 19 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 20 | Class: BaseCube 21 | 22 | Summary: Base class for renderable 3d cube object 23 | 24 | Methods: Initialize 25 | Initializes a basic cube 26 | Update 27 | Pure virtual function that updates the cube every frame 28 | GetNumVertices 29 | Returns the number of vertices in the cube 30 | GetNumIndices 31 | Returns the number of indices in the cube 32 | getVertices 33 | Returns the pointer to the vertices data 34 | getIndices 35 | Returns the pointer to the indices data 36 | BaseCube 37 | Constructor. 38 | ~BaseCube 39 | Destructor. 40 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 41 | class BaseCube : public library::Renderable 42 | { 43 | public: 44 | BaseCube() = default; 45 | BaseCube(const BaseCube& other) = delete; 46 | BaseCube(BaseCube&& other) = delete; 47 | BaseCube& operator=(const BaseCube& other) = delete; 48 | BaseCube& operator=(BaseCube&& other) = delete; 49 | ~BaseCube() = default; 50 | 51 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) override; 52 | virtual void Update(_In_ FLOAT deltaTime) = 0; 53 | 54 | UINT GetNumVertices() const override; 55 | UINT GetNumIndices() const override; 56 | protected: 57 | const library::SimpleVertex* getVertices() const override; 58 | const WORD* getIndices() const override; 59 | 60 | static constexpr const library::SimpleVertex VERTICES[] = 61 | { 62 | { .Position = DirectX::XMFLOAT3(-1.0f, 1.0f, -1.0f) }, 63 | { .Position = DirectX::XMFLOAT3(1.0f, 1.0f, -1.0f) }, 64 | { .Position = DirectX::XMFLOAT3(1.0f, 1.0f, 1.0f) }, 65 | { .Position = DirectX::XMFLOAT3(-1.0f, 1.0f, 1.0f) }, 66 | { .Position = DirectX::XMFLOAT3(-1.0f, -1.0f, -1.0f) }, 67 | { .Position = DirectX::XMFLOAT3(1.0f, -1.0f, -1.0f) }, 68 | { .Position = DirectX::XMFLOAT3(1.0f, -1.0f, 1.0f) }, 69 | { .Position = DirectX::XMFLOAT3(-1.0f, -1.0f, 1.0f) }, 70 | }; 71 | static constexpr const UINT NUM_VERTICES = 8u; 72 | static constexpr const WORD INDICES[] = 73 | { 74 | 3,1,0, 75 | 2,1,3, 76 | 77 | 0,5,4, 78 | 1,5,0, 79 | 80 | 3,4,7, 81 | 0,4,3, 82 | 83 | 1,6,5, 84 | 2,6,1, 85 | 86 | 2,7,6, 87 | 3,7,2, 88 | 89 | 6,4,5, 90 | 7,4,6, 91 | }; 92 | static constexpr const UINT NUM_INDICES = 36u; 93 | }; -------------------------------------------------------------------------------- /Lab04/Game/Main.cpp: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MAIN.CPP 3 | 4 | Summary: This application demonstrates creating a Direct3D 11 device 5 | 6 | Origin: http://msdn.microsoft.com/en-us/library/windows/apps/ff729718.aspx 7 | 8 | Originally created by Microsoft Corporation under MIT License 9 | � 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | 12 | #include "Common.h" 13 | 14 | #include 15 | 16 | /*-------------------------------------------------------------------- 17 | TODO: Include custom cubes (remove the comment) 18 | --------------------------------------------------------------------*/ 19 | #include "Game/Game.h" 20 | 21 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 22 | Function: wWinMain 23 | 24 | Summary: Entry point to the program. Initializes everything and 25 | goes into a message processing loop. Idle time is used to 26 | render the scene. 27 | 28 | Args: HINSTANCE hInstance 29 | Handle to an instance. 30 | HINSTANCE hPrevInstance 31 | Has no meaning. 32 | LPWSTR lpCmdLine 33 | Contains the command-line arguments as a Unicode 34 | string 35 | INT nCmdShow 36 | Flag that says whether the main application window 37 | will be minimized, maximized, or shown normally 38 | 39 | Returns: INT 40 | Status code. 41 | -----------------------------------------------------------------F-F*/ 42 | INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ INT nCmdShow) 43 | { 44 | 45 | #ifdef _DEBUG 46 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 47 | #endif 48 | 49 | UNREFERENCED_PARAMETER(hPrevInstance); 50 | UNREFERENCED_PARAMETER(lpCmdLine); 51 | 52 | std::unique_ptr game = std::make_unique(L"Game Graphics Programming Lab 04: 3D Spaces and Transformations"); 53 | 54 | std::shared_ptr vertexShader = std::make_shared(L"Shaders/Shaders.fxh", "VS", "vs_5_0"); 55 | if (FAILED(game->GetRenderer()->AddVertexShader(L"MainShader", vertexShader))) 56 | { 57 | return 0; 58 | } 59 | 60 | std::shared_ptr pixelShader = std::make_shared(L"Shaders/Shaders.fxh", "PS", "ps_5_0"); 61 | if (FAILED(game->GetRenderer()->AddPixelShader(L"MainShader", pixelShader))) 62 | { 63 | return 0; 64 | } 65 | 66 | /*-------------------------------------------------------------------- 67 | TODO: Add your cubes and set their shaders (remove the comment) 68 | --------------------------------------------------------------------*/ 69 | 70 | if (FAILED(game->Initialize(hInstance, nCmdShow))) 71 | { 72 | return 0; 73 | } 74 | 75 | return game->Run(); 76 | } -------------------------------------------------------------------------------- /Lab04/Game/Shaders/PS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Shaders.fxh" 2 | -------------------------------------------------------------------------------- /Lab04/Game/Shaders/Shaders.fxh: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: Shadersasd.fx 3 | // 4 | // Copyright (c) Microsoft Corporation. 5 | // Licensed under the MIT License (MIT). 6 | //-------------------------------------------------------------------------------------- 7 | 8 | //-------------------------------------------------------------------------------------- 9 | // Constant Buffer Variables 10 | //-------------------------------------------------------------------------------------- 11 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 12 | Cbuffer: ConstantBuffer 13 | 14 | Summary: Constant buffer used for space transformations 15 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 16 | /*-------------------------------------------------------------------- 17 | TODO: ConstantBuffer definition (remove the comment) 18 | --------------------------------------------------------------------*/ 19 | 20 | //-------------------------------------------------------------------------------------- 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Struct: VS_INPUT 23 | 24 | Summary: Used as the input to the vertex shader 25 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 26 | /*-------------------------------------------------------------------- 27 | TODO: VS_INPUT definition (remove the comment) 28 | --------------------------------------------------------------------*/ 29 | 30 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 31 | Struct: PS_INPUT 32 | 33 | Summary: Used as the input to the pixel shader, output of the 34 | vertex shader 35 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 36 | /*-------------------------------------------------------------------- 37 | TODO: PS_INPUT definition (remove the comment) 38 | --------------------------------------------------------------------*/ 39 | 40 | 41 | //-------------------------------------------------------------------------------------- 42 | // Vertex Shader 43 | //-------------------------------------------------------------------------------------- 44 | /*-------------------------------------------------------------------- 45 | TODO: Vertex Shader function VS definition (remove the comment) 46 | --------------------------------------------------------------------*/ 47 | 48 | 49 | //-------------------------------------------------------------------------------------- 50 | // Pixel Shader 51 | //-------------------------------------------------------------------------------------- 52 | /*-------------------------------------------------------------------- 53 | TODO: Pixel Shader function PS definition (remove the comment) 54 | --------------------------------------------------------------------*/ -------------------------------------------------------------------------------- /Lab04/Game/Shaders/VS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Shaders.fxh" 2 | -------------------------------------------------------------------------------- /Lab04/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define _CRTDBG_MAP_ALLOC 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "Resource.h" 46 | 47 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 48 | 49 | using namespace Microsoft::WRL; 50 | using namespace DirectX; -------------------------------------------------------------------------------- /Lab04/Library/Game/Game.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: GAME.H 3 | 4 | Summary: Game header file contains declarations of functions 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Game 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Renderer/Renderer.h" 17 | #include "Window/MainWindow.h" 18 | 19 | namespace library 20 | { 21 | 22 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 23 | Class: Game 24 | 25 | Summary: Main game engine class 26 | 27 | Methods: Initialize 28 | Initializes the components of the game 29 | Run 30 | Runs the game loop 31 | GetGameName 32 | Returns the name of the game 33 | GetWindow 34 | Returns the reference to the unique pointer to the 35 | main window 36 | GetRenderer 37 | Returns the reference to the unique pointer to the 38 | renderer 39 | Game 40 | Constructor. 41 | ~Game 42 | Destructor. 43 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 44 | class Game final 45 | { 46 | public: 47 | Game(_In_ PCWSTR pszGameName); 48 | Game(const Game& other) = delete; 49 | Game(Game&& other) = delete; 50 | Game& operator=(const Game& other) = delete; 51 | Game& operator=(Game&& other) = delete; 52 | ~Game() = default; 53 | 54 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow); 55 | INT Run(); 56 | 57 | PCWSTR GetGameName() const; 58 | std::unique_ptr& GetWindow(); 59 | std::unique_ptr& GetRenderer(); 60 | private: 61 | PCWSTR m_pszGameName; 62 | std::unique_ptr m_mainWindow; 63 | std::unique_ptr m_renderer; 64 | }; 65 | } -------------------------------------------------------------------------------- /Lab04/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | namespace library 6 | { 7 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 8 | Struct: SimpleVertex 9 | 10 | Summary: Simple vertex structure containing a single field of the 11 | type XMFLOAT3 12 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 13 | struct SimpleVertex 14 | { 15 | XMFLOAT3 Position; 16 | }; 17 | 18 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 19 | Struct: ConstantBuffer 20 | 21 | Summary: Simple constant buffer structure containing world, view, 22 | projection matrices 23 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 24 | struct ConstantBuffer 25 | { 26 | XMMATRIX World; 27 | XMMATRIX View; 28 | XMMATRIX Projection; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /Lab04/Library/Shader/PixelShader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader/PixelShader.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: PixelShader::PixelShader 7 | 8 | Summary: Constructor 9 | 10 | Args: PCWSTR pszFileName 11 | Name of the file that contains the shader code 12 | PCSTR pszEntryPoint 13 | Name of the shader entry point functino where shader 14 | execution begins 15 | PCSTR pszShaderModel 16 | Specifies the shader target or set of shader features 17 | to compile against 18 | 19 | Modifies: [m_pixelShader]. 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: PixelShader::PixelShader definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: PixelShader::Initialize 27 | 28 | Summary: Initializes the pixel shader 29 | 30 | Args: ID3D11Device* pDevice 31 | The Direct3D device to create the pixel shader 32 | 33 | Returns: HRESULT 34 | Status code 35 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 36 | /*-------------------------------------------------------------------- 37 | TODO: PixelShader::Initialize definition (remove the comment) 38 | --------------------------------------------------------------------*/ 39 | 40 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 41 | Method: PixelShader::GetPixelShader 42 | 43 | Summary: Returns the pixel shader 44 | 45 | Returns: ComPtr& 46 | Pixel shader. Could be a nullptr 47 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 48 | /*-------------------------------------------------------------------- 49 | TODO: PixelShader::GetPixelShader definition (remove the comment) 50 | --------------------------------------------------------------------*/ 51 | } 52 | -------------------------------------------------------------------------------- /Lab04/Library/Shader/PixelShader.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: PIXELSHADER.H 3 | 4 | Summary: PixelShader header file contains declarations of 5 | PixelShader class used for the lab samples of Game 6 | Graphics Programming course. 7 | 8 | Classes: PixelShader 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Shader/Shader.h" 17 | 18 | namespace library 19 | { 20 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 21 | Class: PixelShader 22 | 23 | Summary: Pixel shader 24 | 25 | Methods: Initialize 26 | Initializes and compiles the pixel shader 27 | GetPixelShader 28 | Returns the reference to the D3D11 pixel shader 29 | Game 30 | Constructor. 31 | ~Game 32 | Destructor. 33 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 34 | class PixelShader : public Shader 35 | { 36 | public: 37 | PixelShader() = delete; 38 | PixelShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel); 39 | PixelShader(const PixelShader& other) = delete; 40 | PixelShader(PixelShader&& other) = delete; 41 | PixelShader& operator=(const PixelShader& other) = delete; 42 | PixelShader& operator=(PixelShader&& other) = delete; 43 | virtual ~PixelShader() = default; 44 | 45 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice) override; 46 | 47 | ComPtr& GetPixelShader(); 48 | 49 | protected: 50 | ComPtr m_pixelShader; 51 | }; 52 | } -------------------------------------------------------------------------------- /Lab04/Library/Shader/Shader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: Shader::Shader 7 | 8 | Summary: Constructor 9 | 10 | Args: PCWSTR pszFileName 11 | Name of the file that contains the shader code 12 | PCSTR pszEntryPoint 13 | Name of the shader entry point functino where shader 14 | execution begins 15 | PCSTR pszShaderModel 16 | Specifies the shader target or set of shader features 17 | to compile against 18 | 19 | Modifies: [m_pszFileName, m_pszEntryPoint, m_pszShaderModel]. 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: Shader::Shader definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: Shader::GetFileName 27 | 28 | Summary: Returns the shader file name 29 | 30 | Returns: PCWSTR 31 | Shader file name 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: Shader::GetFileName definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: Shader::compile 39 | 40 | Summary: Compiles the given shader file 41 | 42 | Args: ID3DBlob** ppOutBlob 43 | Receives a pointer to the ID3DBlob interface that you 44 | can use to access the compiled code 45 | 46 | Returns: HRESULT 47 | Status code 48 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 49 | /*-------------------------------------------------------------------- 50 | TODO: Shader::compile definition (remove the comment) 51 | --------------------------------------------------------------------*/ 52 | } 53 | -------------------------------------------------------------------------------- /Lab04/Library/Shader/Shader.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: SHADER.H 3 | 4 | Summary: Shader header file contains declarations of Shader 5 | class used for the lab samples of Game Graphics 6 | Programming course. 7 | 8 | Classes: Shader 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | namespace library 17 | { 18 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 19 | Class: PixelShader 20 | 21 | Summary: Pixel shader 22 | 23 | Methods: Initialize 24 | Pure virtual function that initializes the shader 25 | GetFileName 26 | Returns the name of the shader file to be compiled 27 | compile 28 | Compiles the given shader file 29 | Game 30 | Constructor. 31 | ~Game 32 | Destructor. 33 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 34 | class Shader 35 | { 36 | public: 37 | Shader() = delete; 38 | Shader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel); 39 | Shader(const Shader& other) = delete; 40 | Shader(Shader&& other) = delete; 41 | Shader& operator=(const Shader& other) = delete; 42 | Shader& operator=(Shader&& other) = delete; 43 | virtual ~Shader() = default; 44 | 45 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice) = 0; 46 | PCWSTR GetFileName() const; 47 | 48 | protected: 49 | HRESULT compile(_Outptr_ ID3DBlob** ppOutBlob); 50 | 51 | PCWSTR m_pszFileName; 52 | PCSTR m_pszEntryPoint; 53 | PCSTR m_pszShaderModel; 54 | }; 55 | } -------------------------------------------------------------------------------- /Lab04/Library/Shader/VertexShader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader/VertexShader.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: VertexShader::VertexShader 7 | 8 | Summary: Constructor 9 | 10 | Args: PCWSTR pszFileName 11 | Name of the file that contains the shader code 12 | PCSTR pszEntryPoint 13 | Name of the shader entry point functino where shader 14 | execution begins 15 | PCSTR pszShaderModel 16 | Specifies the shader target or set of shader features 17 | to compile against 18 | 19 | Modifies: [m_vertexShader]. 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: VertexShader::VertexShader definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: VertexShader::Initialize 27 | 28 | Summary: Initializes the vertex shader and the input layout 29 | 30 | Args: ID3D11Device* pDevice 31 | The Direct3D device to create the vertex shader 32 | 33 | Returns: HRESULT 34 | Status code 35 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 36 | /*-------------------------------------------------------------------- 37 | TODO: VertexShader::Initialize definition (remove the comment) 38 | --------------------------------------------------------------------*/ 39 | 40 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 41 | Method: VertexShader::GetVertexShader 42 | 43 | Summary: Returns the vertex shader 44 | 45 | Returns: ComPtr& 46 | Vertex shader. Could be a nullptr 47 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 48 | /*-------------------------------------------------------------------- 49 | TODO: VertexShader::GetVertexShader definition (remove the comment) 50 | --------------------------------------------------------------------*/ 51 | 52 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 53 | Method: VertexShader::GetVertexLayout 54 | 55 | Summary: Returns the vertex input layout 56 | 57 | Returns: ComPtr& 58 | Vertex input layout 59 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 60 | /*-------------------------------------------------------------------- 61 | TODO: VertexShader::GetVertexLayout definition (remove the comment) 62 | --------------------------------------------------------------------*/ 63 | } 64 | -------------------------------------------------------------------------------- /Lab04/Library/Shader/VertexShader.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: VERTEXSHADER.H 3 | 4 | Summary: VertexShader header file contains declarations of 5 | VertexShader class used for the lab samples of Game 6 | Graphics Programming course. 7 | 8 | Classes: VertexShader 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Shader/Shader.h" 17 | 18 | namespace library 19 | { 20 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 21 | Class: VertexShader 22 | 23 | Summary: Vertex shader 24 | 25 | Methods: Initialize 26 | Initializes the vertex shader and the input layout 27 | GetVertexShader 28 | Returns the vertex shader 29 | GetVertexLayout 30 | Returns the vertex input layout 31 | Game 32 | Constructor. 33 | ~Game 34 | Destructor. 35 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 36 | class VertexShader : public Shader 37 | { 38 | public: 39 | VertexShader() = delete; 40 | VertexShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel); 41 | VertexShader(const VertexShader& other) = delete; 42 | VertexShader(VertexShader&& other) = delete; 43 | VertexShader& operator=(const VertexShader& other) = delete; 44 | VertexShader& operator=(VertexShader&& other) = delete; 45 | virtual ~VertexShader() = default; 46 | 47 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice) override; 48 | 49 | ComPtr& GetVertexShader(); 50 | ComPtr& GetVertexLayout(); 51 | 52 | protected: 53 | ComPtr m_vertexShader; 54 | ComPtr m_vertexLayout; 55 | }; 56 | } -------------------------------------------------------------------------------- /Lab04/Library/Window/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "Window/MainWindow.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: MainWindow::Initialize 7 | 8 | Summary: Initializes main window 9 | 10 | Args: HINSTANCE hInstance 11 | Handle to the instance 12 | INT nCmdShow 13 | Is a flag that says whether the main application window 14 | will be minimized, maximized, or shown normally 15 | PCWSTR pszWindowName 16 | The window name 17 | 18 | Returns: HRESULT 19 | Status code 20 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 21 | /*-------------------------------------------------------------------- 22 | TODO: MainWindow::Initialize definition (remove the comment) 23 | --------------------------------------------------------------------*/ 24 | 25 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 26 | Method: MainWindow::GetWindowClassName 27 | 28 | Summary: Returns the name of the window class 29 | 30 | Returns: PCWSTR 31 | Name of the window class 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: MainWindow::GetWindowClassName definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: MainWindow::HandleMessage 39 | 40 | Summary: Handles the messages 41 | 42 | Args: UINT uMessage 43 | Message code 44 | WPARAM wParam 45 | Additional data the pertains to the message 46 | LPARAM lParam 47 | Additional data the pertains to the message 48 | 49 | Returns: LRESULT 50 | Integer value that your program returns to Windows 51 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 52 | /*-------------------------------------------------------------------- 53 | TODO: MainWindow::HandleMessage definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | } 56 | -------------------------------------------------------------------------------- /Lab04/Library/Window/MainWindow.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: BASEWINDOW.H 3 | 4 | Summary: BaseWindow header file contains declarations of the 5 | base class of all windows used in the library. 6 | 7 | Classes: BaseWindow 8 | 9 | Functions: InitWindow, InitDevice 10 | 11 | © 2022 Kyung Hee University 12 | ===================================================================+*/ 13 | #pragma once 14 | 15 | #include "Common.h" 16 | 17 | #include "Window/BaseWindow.h" 18 | 19 | namespace library 20 | { 21 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 22 | Class: MainWindow 23 | 24 | Summary: Main window to be used in game engine 25 | 26 | Methods: Initialize 27 | Initializes window 28 | GetWindowClassName 29 | Returns the name of the window class 30 | HandleMessage 31 | Handles the messages 32 | MainWindow 33 | Constructor. 34 | ~MainWindow 35 | Destructor. 36 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 37 | class MainWindow : public BaseWindow 38 | { 39 | public: 40 | MainWindow() = default; 41 | MainWindow(const MainWindow& other) = delete; 42 | MainWindow(MainWindow&& other) = delete; 43 | MainWindow& operator=(const MainWindow& other) = delete; 44 | MainWindow& operator=(MainWindow&& other) = delete; 45 | virtual ~MainWindow() = default; 46 | 47 | HRESULT Initialize(_In_ HINSTANCE hInstance, _In_ INT nCmdShow, _In_ PCWSTR pszWindowName) override; 48 | PCWSTR GetWindowClassName() const override; 49 | LRESULT HandleMessage(_In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) override; 50 | }; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /Lab05/Game/Cube/BaseCube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/BaseCube.h" 2 | 3 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 4 | Method: BaseCube::BaseCube 5 | 6 | Summary: Constructor 7 | 8 | Args: const std::filesystem::path& textureFilePath 9 | Path to the texture to use 10 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 11 | /*-------------------------------------------------------------------- 12 | TODO: BaseCube::BaseCube definition (remove the comment) 13 | --------------------------------------------------------------------*/ 14 | 15 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 16 | Method: BaseCube::Initialize 17 | 18 | Summary: Initializes a basic cube 19 | 20 | Args: ID3D11Device* pDevice 21 | The Direct3D device to create the buffers 22 | ID3D11DeviceContext* pImmediateContext 23 | The Direct3D context to set buffers 24 | 25 | Returns: HRESULT 26 | Status code 27 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 28 | /*-------------------------------------------------------------------- 29 | TODO: BaseCube::Initialize definition (remove the comment) 30 | --------------------------------------------------------------------*/ 31 | 32 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 33 | Method: BaseCube::GetNumVertices 34 | 35 | Summary: Returns the number of vertices in the cube 36 | 37 | Returns: UINT 38 | Number of vertices 39 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 40 | /*-------------------------------------------------------------------- 41 | TODO: BaseCube::GetNumVertices definition (remove the comment) 42 | --------------------------------------------------------------------*/ 43 | 44 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 45 | Method: BaseCube::GetNumIndices 46 | 47 | Summary: Returns the number of indices in the cube 48 | 49 | Returns: UINT 50 | Number of indices 51 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 52 | /*-------------------------------------------------------------------- 53 | TODO: BaseCube::GetNumIndices definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | 56 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 57 | Method: BaseCube::getVertices 58 | 59 | Summary: Returns the pointer to the vertices data 60 | 61 | Returns: const library::SimpleVertex* 62 | Pointer to the vertices data 63 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 64 | /*-------------------------------------------------------------------- 65 | TODO: BaseCube::getVertices definition (remove the comment) 66 | --------------------------------------------------------------------*/ 67 | 68 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 69 | Method: BaseCube::getIndices 70 | 71 | Summary: Returns the pointer to the indices data 72 | 73 | Returns: const WORD* 74 | Pointer to the indices data 75 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 76 | /*-------------------------------------------------------------------- 77 | TODO: BaseCube::getIndices definition (remove the comment) 78 | --------------------------------------------------------------------*/ 79 | -------------------------------------------------------------------------------- /Lab05/Game/Cube/Cube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/Cube.h" 2 | 3 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 4 | Method: Cube::Cube 5 | 6 | Summary: Constructor 7 | 8 | Args: const std::filesystem::path& textureFilePath 9 | Path to the texture to use 10 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 11 | /*-------------------------------------------------------------------- 12 | TODO: Cube::Cube definition (remove the comment) 13 | --------------------------------------------------------------------*/ 14 | 15 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 16 | Method: Cube::Update 17 | 18 | Summary: Updates the cube every frame 19 | 20 | Args: FLOAT deltaTime 21 | Elapsed time 22 | 23 | Modifies: [m_world]. 24 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 25 | void Cube::Update(_In_ FLOAT deltaTime) 26 | { 27 | static FLOAT s_totalTime = 0.0f; 28 | s_totalTime += deltaTime; 29 | 30 | m_world = XMMatrixTranslation(0.0f, XMScalarSin(s_totalTime), 0.0f) * XMMatrixRotationY(s_totalTime); 31 | } -------------------------------------------------------------------------------- /Lab05/Game/Cube/Cube.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: CUBE1.H 3 | 4 | Summary: Cube header file contains declarations of Cube class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Cube 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Cube/BaseCube.h" 17 | 18 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 19 | Class: Cube 20 | 21 | Summary: A renderable 3d cube object 22 | 23 | Methods: Update 24 | Overriden function that updates the cube every frame 25 | Cube 26 | Constructor. 27 | ~Cube 28 | Destructor. 29 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 30 | class Cube : public BaseCube 31 | { 32 | public: 33 | Cube(const std::filesystem::path& textureFilePath); 34 | Cube(const Cube& other) = delete; 35 | Cube(Cube&& other) = delete; 36 | Cube& operator=(const Cube& other) = delete; 37 | Cube& operator=(Cube&& other) = delete; 38 | ~Cube() = default; 39 | 40 | virtual void Update(_In_ FLOAT deltaTime) override; 41 | }; -------------------------------------------------------------------------------- /Lab05/Game/Main.cpp: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MAIN.CPP 3 | 4 | Summary: This application demonstrates creating a Direct3D 11 device 5 | 6 | Origin: http://msdn.microsoft.com/en-us/library/windows/apps/ff729718.aspx 7 | 8 | Originally created by Microsoft Corporation under MIT License 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | 12 | #include "Common.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include "Cube/Cube.h" 20 | #include "Game/Game.h" 21 | 22 | /*F+F+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 23 | Function: wWinMain 24 | 25 | Summary: Entry point to the program. Initializes everything and 26 | goes into a message processing loop. Idle time is used to 27 | render the scene. 28 | 29 | Args: HINSTANCE hInstance 30 | Handle to an instance. 31 | HINSTANCE hPrevInstance 32 | Has no meaning. 33 | LPWSTR lpCmdLine 34 | Contains the command-line arguments as a Unicode 35 | string 36 | INT nCmdShow 37 | Flag that says whether the main application window 38 | will be minimized, maximized, or shown normally 39 | 40 | Returns: INT 41 | Status code. 42 | -----------------------------------------------------------------F-F*/ 43 | INT WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ INT nCmdShow) 44 | { 45 | #ifdef _DEBUG 46 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 47 | #endif 48 | UNREFERENCED_PARAMETER(hPrevInstance); 49 | UNREFERENCED_PARAMETER(lpCmdLine); 50 | 51 | std::unique_ptr game = std::make_unique(L"Game Graphics Programming Lab 05: Texture Mapping and Constant Buffers"); 52 | 53 | std::shared_ptr vertexShader = std::make_shared(L"Shaders/Shaders.fxh", "VS", "vs_5_0"); 54 | if (FAILED(game->GetRenderer()->AddVertexShader(L"MainShader", vertexShader))) 55 | { 56 | return 0; 57 | } 58 | 59 | std::shared_ptr pixelShader = std::make_shared(L"Shaders/Shaders.fxh", "PS", "ps_5_0"); 60 | if (FAILED(game->GetRenderer()->AddPixelShader(L"MainShader", pixelShader))) 61 | { 62 | return 0; 63 | } 64 | 65 | std::shared_ptr cube = std::make_shared("seafloor.dds"); 66 | if (FAILED(game->GetRenderer()->AddRenderable(L"Cube", cube))) 67 | { 68 | return 0; 69 | } 70 | 71 | if (FAILED(game->GetRenderer()->SetVertexShaderOfRenderable(L"Cube", L"MainShader"))) 72 | { 73 | return 0; 74 | } 75 | 76 | if (FAILED(game->GetRenderer()->SetPixelShaderOfRenderable(L"Cube", L"MainShader"))) 77 | { 78 | return 0; 79 | } 80 | 81 | if (FAILED(game->Initialize(hInstance, nCmdShow))) 82 | { 83 | return 0; 84 | } 85 | 86 | return game->Run(); 87 | } -------------------------------------------------------------------------------- /Lab05/Game/Shaders/PS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Shaders.fxh" 2 | -------------------------------------------------------------------------------- /Lab05/Game/Shaders/VS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Shaders.fxh" 2 | -------------------------------------------------------------------------------- /Lab05/Game/seafloor.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab05/Game/seafloor.dds -------------------------------------------------------------------------------- /Lab05/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | #pragma comment(lib, "dxguid.lib") 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #define _CRTDBG_MAP_ALLOC 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "Resource.h" 47 | 48 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 49 | 50 | using namespace Microsoft::WRL; 51 | using namespace DirectX; 52 | 53 | namespace library 54 | { 55 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 56 | Class: DirectionsInput 57 | 58 | Summary: Data structure that stores keyboard movement data 59 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 60 | struct DirectionsInput 61 | { 62 | BOOL bFront; 63 | BOOL bLeft; 64 | BOOL bBack; 65 | BOOL bRight; 66 | BOOL bUp; 67 | BOOL bDown; 68 | }; 69 | 70 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 71 | Class: MouseRelativeMovement 72 | 73 | Summary: Data structure that stores mouse relative movement data 74 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 75 | struct MouseRelativeMovement 76 | { 77 | LONG X; 78 | LONG Y; 79 | }; 80 | } -------------------------------------------------------------------------------- /Lab05/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace library 4 | { 5 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 6 | Struct: SimpleVertex 7 | 8 | Summary: Simple vertex structure containing a single field of the 9 | type XMFLOAT3 10 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 11 | struct SimpleVertex 12 | { 13 | XMFLOAT3 Position; 14 | XMFLOAT2 TexCoord; 15 | }; 16 | 17 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 18 | Struct: CBChangeOnCameraMovement 19 | 20 | Summary: Constant buffer containing view matrix 21 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 22 | struct CBChangeOnCameraMovement 23 | { 24 | XMMATRIX View; 25 | }; 26 | 27 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 28 | Struct: CBChangeOnResize 29 | 30 | Summary: Constant buffer containing projection matrix 31 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 32 | struct CBChangeOnResize 33 | { 34 | XMMATRIX Projection; 35 | }; 36 | 37 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 38 | Struct: CBChangesEveryFrame 39 | 40 | Summary: Constant buffer containing world matrix 41 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 42 | struct CBChangesEveryFrame 43 | { 44 | XMMATRIX World; 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /Lab06/Game/Cube/BaseCube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/BaseCube.h" 2 | 3 | BaseCube::BaseCube(_In_ const std::filesystem::path& textureFilePath) 4 | : Renderable(textureFilePath) 5 | { 6 | } 7 | 8 | BaseCube::BaseCube(_In_ const XMFLOAT4& outputColor) 9 | : Renderable(outputColor) 10 | { 11 | } 12 | 13 | HRESULT BaseCube::Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) 14 | { 15 | return initialize(pDevice, pImmediateContext); 16 | } 17 | 18 | UINT BaseCube::GetNumVertices() const 19 | { 20 | return NUM_VERTICES; 21 | } 22 | 23 | UINT BaseCube::GetNumIndices() const 24 | { 25 | return NUM_INDICES; 26 | } 27 | 28 | const library::SimpleVertex* BaseCube::getVertices() const 29 | { 30 | return VERTICES; 31 | } 32 | 33 | 34 | const WORD* BaseCube::getIndices() const 35 | { 36 | return INDICES; 37 | } -------------------------------------------------------------------------------- /Lab06/Game/Cube/Cube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/Cube.h" 2 | 3 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 4 | Method: Cube::Cube 5 | 6 | Summary: Constructor 7 | 8 | Args: const std::filesystem::path& textureFilePath 9 | Path to the texture to use 10 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 11 | Cube::Cube(_In_ const std::filesystem::path& textureFilePath) 12 | : BaseCube(textureFilePath) 13 | { 14 | } 15 | 16 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 17 | Method: Cube::Cube 18 | 19 | Summary: Constructor 20 | 21 | Args: const XMFLOAT4& outputColor 22 | Default color of the cube 23 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 24 | Cube::Cube(_In_ const XMFLOAT4& outputColor) 25 | : BaseCube(outputColor) 26 | { 27 | } 28 | 29 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 30 | Method: Cube::Update 31 | 32 | Summary: Updates the cube every frame 33 | 34 | Args: FLOAT deltaTime 35 | Elapsed time 36 | 37 | Modifies: [m_world]. 38 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 39 | void Cube::Update(_In_ FLOAT deltaTime) 40 | { 41 | // Does nothing 42 | } -------------------------------------------------------------------------------- /Lab06/Game/Cube/Cube.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: CUBE1.H 3 | 4 | Summary: Cube header file contains declarations of Cube class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Cube 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Cube/BaseCube.h" 17 | 18 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 19 | Class: Cube 20 | 21 | Summary: A renderable 3d cube object 22 | 23 | Methods: Update 24 | Overriden function that updates the cube every frame 25 | Cube 26 | Constructor. 27 | ~Cube 28 | Destructor. 29 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 30 | class Cube : public BaseCube 31 | { 32 | public: 33 | Cube(_In_ const std::filesystem::path& textureFilePath); 34 | Cube(_In_ const XMFLOAT4& outputColor); 35 | Cube(const Cube& other) = delete; 36 | Cube(Cube&& other) = delete; 37 | Cube& operator=(const Cube& other) = delete; 38 | Cube& operator=(Cube&& other) = delete; 39 | ~Cube() = default; 40 | 41 | virtual void Update(_In_ FLOAT deltaTime) override; 42 | }; -------------------------------------------------------------------------------- /Lab06/Game/Cube/RotatingCube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/RotatingCube.h" 2 | 3 | RotatingCube::RotatingCube(const std::filesystem::path& textureFilePath) 4 | : BaseCube(textureFilePath) 5 | { 6 | } 7 | 8 | RotatingCube::RotatingCube(const XMFLOAT4& outputColor) 9 | : BaseCube(outputColor) 10 | { 11 | } 12 | 13 | void RotatingCube::Update(_In_ FLOAT deltaTime) 14 | { 15 | // Rotate cube around the origin 16 | static FLOAT t = 0.0f; 17 | t += deltaTime; 18 | 19 | XMMATRIX mSpin = XMMatrixRotationZ(-t); 20 | XMMATRIX mOrbit = XMMatrixRotationY(-t * 2.0f); 21 | XMMATRIX mTranslate = XMMatrixTranslation(0.0f, 0.0f, -5.0f); 22 | XMMATRIX mScale = XMMatrixScaling(0.3f, 0.3f, 0.3f); 23 | 24 | m_world = mScale * mSpin * mTranslate * mOrbit; 25 | } -------------------------------------------------------------------------------- /Lab06/Game/Cube/RotatingCube.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: ROTATINGCUBE.H 3 | 4 | Summary: RotatingCube header file contains declarations of 5 | RotatingCube class used for the lab samples of Game 6 | Graphics Programming course. 7 | 8 | Classes: RotatingCube 9 | 10 | © 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Cube/BaseCube.h" 17 | 18 | class RotatingCube : public BaseCube 19 | { 20 | public: 21 | RotatingCube(const std::filesystem::path& textureFilePath); 22 | RotatingCube(const XMFLOAT4& outputColor); 23 | RotatingCube(const RotatingCube& other) = delete; 24 | RotatingCube(RotatingCube&& other) = delete; 25 | RotatingCube& operator=(const RotatingCube& other) = delete; 26 | RotatingCube& operator=(RotatingCube&& other) = delete; 27 | ~RotatingCube() = default; 28 | 29 | virtual void Update(_In_ FLOAT deltaTime) override; 30 | }; -------------------------------------------------------------------------------- /Lab06/Game/Light/RotatingPointLight.cpp: -------------------------------------------------------------------------------- 1 | #include "Light/RotatingPointLight.h" 2 | 3 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 4 | Method: RotatingPointLight::RotatingPointLight 5 | 6 | Summary: Constructor 7 | 8 | Args: const XMFLOAT4& position 9 | Position of the light 10 | const XMFLOAT4& color 11 | Position of the color 12 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 13 | /*-------------------------------------------------------------------- 14 | TODO: RotatingPointLight::RotatingPointLight definition (remove the comment) 15 | --------------------------------------------------------------------*/ 16 | 17 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 18 | Method: RotatingPointLight::Update 19 | 20 | Summary: Rotates the light every frame 21 | 22 | Args: FLOAT deltaTime 23 | Elapsed time 24 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 25 | void RotatingPointLight::Update(_In_ FLOAT deltaTime) 26 | { 27 | XMMATRIX rotate = XMMatrixRotationY(-2.0f * deltaTime); 28 | XMVECTOR position = XMLoadFloat4(&m_position); 29 | position = XMVector3Transform(position, rotate); 30 | XMStoreFloat4(&m_position, position); 31 | } 32 | -------------------------------------------------------------------------------- /Lab06/Game/Light/RotatingPointLight.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: ROTATINGPOINTLIGHT.H 3 | 4 | Summary: RotatingPointLight header file contains 5 | declarations of the rotating point light. 6 | 7 | Classes: RotatingPointLight 8 | 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | #include "Light/PointLight.h" 16 | 17 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 18 | Class: RotatingPointLight 19 | 20 | Summary: Point light that rotates around the y axis 21 | 22 | Methods: Update 23 | Rotates every frame by y-axis 24 | RotatingPointLight 25 | Constructor. 26 | ~RotatingPointLight 27 | Destructor. 28 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 29 | class RotatingPointLight final : public library::PointLight 30 | { 31 | public: 32 | RotatingPointLight() = delete; 33 | RotatingPointLight(_In_ const XMFLOAT4& position, _In_ const XMFLOAT4& color); 34 | RotatingPointLight(const RotatingPointLight& other) = default; 35 | RotatingPointLight(RotatingPointLight&& other) = default; 36 | RotatingPointLight& operator=(const RotatingPointLight & other) = default; 37 | RotatingPointLight& operator=(RotatingPointLight && other) = default; 38 | virtual ~RotatingPointLight() = default; 39 | 40 | virtual void Update(_In_ FLOAT deltaTime) override; 41 | }; -------------------------------------------------------------------------------- /Lab06/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | #pragma comment(lib, "dxguid.lib") 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #define _CRTDBG_MAP_ALLOC 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "Resource.h" 47 | 48 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 49 | 50 | #ifndef NUM_LIGHTS 51 | #define NUM_LIGHTS (2) 52 | #endif 53 | 54 | using namespace Microsoft::WRL; 55 | using namespace DirectX; 56 | 57 | namespace library 58 | { 59 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 60 | Struct: DirectionsInput 61 | 62 | Summary: Data structure that stores keyboard movement data 63 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 64 | struct DirectionsInput 65 | { 66 | BOOL bFront; 67 | BOOL bLeft; 68 | BOOL bBack; 69 | BOOL bRight; 70 | BOOL bUp; 71 | BOOL bDown; 72 | }; 73 | 74 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 75 | Struct: MouseRelativeMovement 76 | 77 | Summary: Data structure that stores mouse relative movement data 78 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 79 | struct MouseRelativeMovement 80 | { 81 | LONG X; 82 | LONG Y; 83 | }; 84 | } -------------------------------------------------------------------------------- /Lab06/Library/Light/PointLight.cpp: -------------------------------------------------------------------------------- 1 | #include "Light/PointLight.h" 2 | 3 | #include "Renderer/DataTypes.h" 4 | 5 | namespace library 6 | { 7 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 8 | Method: PointLight::PointLight 9 | 10 | Summary: Constructor 11 | 12 | Args: const XMFLOAT4& position 13 | Position of the light 14 | const XMFLOAT4& color 15 | Position of the color 16 | 17 | Modifies: [m_position, m_color]. 18 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 19 | /*-------------------------------------------------------------------- 20 | TODO: PointLight::PointLight definition (remove the comment) 21 | --------------------------------------------------------------------*/ 22 | 23 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 24 | Method: PointLight::GetPosition 25 | 26 | Summary: Returns the position of the light 27 | 28 | Returns: const XMFLOAT4& 29 | Position of the light 30 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 31 | /*-------------------------------------------------------------------- 32 | TODO: PointLight::GetPosition definition (remove the comment) 33 | --------------------------------------------------------------------*/ 34 | 35 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 36 | Method: PointLight::GetColor 37 | 38 | Summary: Returns the color of the light 39 | 40 | Returns: const XMFLOAT4& 41 | Color of the light 42 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 43 | /*-------------------------------------------------------------------- 44 | TODO: PointLight::GetColor definition (remove the comment) 45 | --------------------------------------------------------------------*/ 46 | 47 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 48 | Method: PointLight::Update 49 | 50 | Summary: Updates the light every frame 51 | 52 | Args: FLOAT deltaTime 53 | Elapsed time 54 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 55 | void PointLight::Update(_In_ FLOAT deltaTime) 56 | { 57 | UNREFERENCED_PARAMETER(deltaTime); 58 | } 59 | } -------------------------------------------------------------------------------- /Lab06/Library/Light/PointLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | #include "Shader/PixelShader.h" 6 | 7 | namespace library 8 | { 9 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 10 | Class: PointLight 11 | 12 | Summary: Point light that emits a light from a single point to 13 | every direction 14 | 15 | Methods: GetPosition 16 | Returns the position of the light 17 | GetColor 18 | Returns the color of the light 19 | Update 20 | Updates the light 21 | PointLight 22 | Constructor. 23 | ~PointLight 24 | Destructor. 25 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 26 | class PointLight 27 | { 28 | public: 29 | PointLight() = delete; 30 | PointLight(_In_ const XMFLOAT4& position, _In_ const XMFLOAT4& color); 31 | PointLight(const PointLight& other) = default; 32 | PointLight(PointLight&& other) = default; 33 | PointLight& operator=(const PointLight& other) = default; 34 | PointLight& operator=(PointLight&& other) = default; 35 | virtual ~PointLight() = default; 36 | 37 | const XMFLOAT4& GetPosition() const; 38 | const XMFLOAT4& GetColor() const; 39 | 40 | virtual void Update(_In_ FLOAT deltaTime); 41 | protected: 42 | XMFLOAT4 m_position; 43 | XMFLOAT4 m_color; 44 | }; 45 | } -------------------------------------------------------------------------------- /Lab06/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | namespace library 6 | { 7 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 8 | Struct: SimpleVertex 9 | 10 | Summary: Simple vertex structure containing a single field of the 11 | type XMFLOAT3 12 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 13 | struct SimpleVertex 14 | { 15 | XMFLOAT3 Position; 16 | XMFLOAT2 TexCoord; 17 | XMFLOAT3 Normal; 18 | }; 19 | 20 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 21 | Struct: CBChangeOnCameraMovement 22 | 23 | Summary: Constant buffer containing view matrix 24 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 25 | struct CBChangeOnCameraMovement 26 | { 27 | XMMATRIX View; 28 | XMFLOAT4 CameraPosition; 29 | }; 30 | 31 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 32 | Struct: CBChangeOnResize 33 | 34 | Summary: Constant buffer containing projection matrix 35 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 36 | struct CBChangeOnResize 37 | { 38 | XMMATRIX Projection; 39 | }; 40 | 41 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 42 | Struct: CBChangesEveryFrame 43 | 44 | Summary: Constant buffer containing world matrix 45 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 46 | struct CBChangesEveryFrame 47 | { 48 | XMMATRIX World; 49 | XMFLOAT4 OutputColor; 50 | }; 51 | 52 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 53 | Struct: CBLights 54 | 55 | Summary: Constant buffer containing lights' information 56 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 57 | struct CBLights 58 | { 59 | XMFLOAT4 LightPositions[NUM_LIGHTS]; 60 | XMFLOAT4 LightColors[NUM_LIGHTS]; 61 | }; 62 | } -------------------------------------------------------------------------------- /Lab07/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | #pragma comment(lib, "dxguid.lib") 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #define _CRTDBG_MAP_ALLOC 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "Resource.h" 47 | 48 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 49 | 50 | using namespace Microsoft::WRL; 51 | using namespace DirectX; 52 | 53 | namespace library 54 | { 55 | #define ASSIMP_LOAD_FLAGS (aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices | aiProcess_ConvertToLeftHanded) 56 | 57 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 58 | Class: DirectionsInput 59 | 60 | Summary: Data structure that stores keyboard movement data 61 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 62 | struct DirectionsInput 63 | { 64 | BOOL bFront; 65 | BOOL bLeft; 66 | BOOL bBack; 67 | BOOL bRight; 68 | BOOL bUp; 69 | BOOL bDown; 70 | }; 71 | 72 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 73 | Class: MouseRelativeMovement 74 | 75 | Summary: Data structure that stores mouse relative movement data 76 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 77 | struct MouseRelativeMovement 78 | { 79 | LONG X; 80 | LONG Y; 81 | }; 82 | } -------------------------------------------------------------------------------- /Lab07/Library/Texture/Material.cpp: -------------------------------------------------------------------------------- 1 | #include "Texture/Material.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: Material::Material 7 | 8 | Summary: Constructor 9 | 10 | Modifies: [pDiffuse, pSpecular]. 11 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 12 | /*-------------------------------------------------------------------- 13 | TODO: Material::Material definition (remove the comment) 14 | --------------------------------------------------------------------*/ 15 | } -------------------------------------------------------------------------------- /Lab07/Library/Texture/Material.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MATERIAL.H 3 | 4 | Summary: Material header file contains declaration of class 5 | Material used to abstract multiple texture data. 6 | 7 | Classes: Material 8 | 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | #include "Texture/Texture.h" 16 | 17 | namespace library 18 | { 19 | class Material 20 | { 21 | public: 22 | Material(); 23 | Material(const Material& other) = default; 24 | Material(Material&& other) = default; 25 | Material& operator=(const Material& other) = default; 26 | Material& operator=(Material&& other) = default; 27 | virtual ~Material() = default; 28 | 29 | public: 30 | std::shared_ptr pDiffuse; 31 | std::shared_ptr pSpecular; 32 | }; 33 | } -------------------------------------------------------------------------------- /Lab07/Library/Texture/Texture.cpp: -------------------------------------------------------------------------------- 1 | #include "Texture.h" 2 | 3 | #include "Texture/WICTextureLoader.h" 4 | 5 | namespace library 6 | { 7 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 8 | Method: Texture::Texture 9 | 10 | Summary: Constructor 11 | 12 | Args: const std::filesystem::path& textureFilePath 13 | Path to the texture to use 14 | 15 | Modifies: [m_filePath, m_textureRV, m_samplerLinear]. 16 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 17 | /*-------------------------------------------------------------------- 18 | TODO: Texture::Texture definition (remove the comment) 19 | --------------------------------------------------------------------*/ 20 | 21 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 22 | Method: Texture::Initialize 23 | 24 | Summary: Initializes the texture 25 | 26 | Args: ID3D11Device* pDevice 27 | The Direct3D device to create the buffers 28 | ID3D11DeviceContext* pImmediateContext 29 | The Direct3D context to set buffers 30 | 31 | Modifies: [m_textureRV, m_samplerLinear]. 32 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 33 | /*-------------------------------------------------------------------- 34 | TODO: Texture::Initialize definition (remove the comment) 35 | --------------------------------------------------------------------*/ 36 | 37 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 38 | Method: Texture::GetTextureResourceView 39 | 40 | Summary: Constructor 41 | 42 | Returns: ComPtr& 43 | Shader resource view 44 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 45 | ComPtr& Texture::GetTextureResourceView() 46 | { 47 | return m_textureRV; 48 | } 49 | 50 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 51 | Method: Texture::GetSamplerState 52 | 53 | Summary: Constructor 54 | 55 | Returns: ComPtr& 56 | Sampler state 57 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 58 | ComPtr& Texture::GetSamplerState() 59 | { 60 | return m_samplerLinear; 61 | } 62 | } -------------------------------------------------------------------------------- /Lab07/Library/Texture/Texture.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: TEXTURE.H 3 | 4 | Summary: Texture header file contains declaration of class 5 | Texture used to abstract texture data. 6 | 7 | Classes: Texture 8 | 9 | © 2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | namespace library 16 | { 17 | class Texture 18 | { 19 | public: 20 | Texture() = delete; 21 | Texture(_In_ const std::filesystem::path& filePath); 22 | Texture(const Texture& other) = delete; 23 | Texture(Texture&& other) = delete; 24 | Texture& operator=(const Texture& other) = delete; 25 | Texture& operator=(Texture&& other) = delete; 26 | virtual ~Texture() = default; 27 | 28 | // Should be called once to load the texture 29 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext); 30 | 31 | ComPtr& GetTextureResourceView(); 32 | ComPtr& GetSamplerState(); 33 | 34 | private: 35 | std::filesystem::path m_filePath; 36 | ComPtr m_textureRV; 37 | ComPtr m_samplerLinear; 38 | }; 39 | } -------------------------------------------------------------------------------- /Lab07/Library/Texture/WICTextureLoader.h: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: WICTextureLoader.h 3 | // 4 | // Function for loading a WIC image and creating a Direct3D 11 runtime texture for it 5 | // (auto-generating mipmaps if possible) 6 | // 7 | // Note: Assumes application has already called CoInitializeEx 8 | // 9 | // Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for 10 | // auto-gen mipmap support. 11 | // 12 | // Note these functions are useful for images created as simple 2D textures. For 13 | // more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. 14 | // For a full-featured DDS file reader, writer, and texture processing pipeline see 15 | // the 'Texconv' sample and the 'DirectXTex' library. 16 | // 17 | // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 18 | // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 19 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 20 | // PARTICULAR PURPOSE. 21 | // 22 | // Copyright (c) Microsoft Corporation. All rights reserved. 23 | // 24 | // https://go.microsoft.com/fwlink/?LinkId=248926 25 | // https://go.microsoft.com/fwlink/?LinkId=248929 26 | //-------------------------------------------------------------------------------------- 27 | 28 | #ifdef _MSC_VER 29 | #pragma once 30 | #endif 31 | 32 | #include "Common.h" 33 | 34 | #pragma warning(push) 35 | #pragma warning(disable : 4005) 36 | #include 37 | #pragma warning(pop) 38 | 39 | HRESULT CreateWICTextureFromMemory( 40 | _In_ ID3D11Device* d3dDevice, 41 | _In_opt_ ID3D11DeviceContext* d3dContext, 42 | _In_bytecount_(wicDataSize) const uint8_t* wicData, 43 | _In_ size_t wicDataSize, 44 | _Out_opt_ ID3D11Resource** texture, 45 | _Out_opt_ ID3D11ShaderResourceView** textureView, 46 | _In_ size_t maxsize = 0 47 | ); 48 | 49 | HRESULT CreateWICTextureFromFile( 50 | _In_ ID3D11Device* d3dDevice, 51 | _In_opt_ ID3D11DeviceContext* d3dContext, 52 | _In_z_ const wchar_t* szFileName, 53 | _Out_opt_ ID3D11Resource** texture, 54 | _Out_opt_ ID3D11ShaderResourceView** textureView, 55 | _In_ size_t maxsize = 0 56 | ); -------------------------------------------------------------------------------- /Lab08/Game/Content/BobLampClean/guard1_body.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab08/Game/Content/BobLampClean/guard1_body.jpg -------------------------------------------------------------------------------- /Lab08/Game/Content/BobLampClean/guard1_face.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab08/Game/Content/BobLampClean/guard1_face.jpg -------------------------------------------------------------------------------- /Lab08/Game/Content/BobLampClean/guard1_helmet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab08/Game/Content/BobLampClean/guard1_helmet.jpg -------------------------------------------------------------------------------- /Lab08/Game/Content/BobLampClean/iron_grill.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab08/Game/Content/BobLampClean/iron_grill.jpg -------------------------------------------------------------------------------- /Lab08/Game/Content/BobLampClean/round_grill.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab08/Game/Content/BobLampClean/round_grill.jpg -------------------------------------------------------------------------------- /Lab08/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | namespace library 6 | { 7 | #define NUM_LIGHTS (2) 8 | #define MAX_NUM_BONES (256) 9 | #define MAX_NUM_BONES_PER_VERTEX (16) 10 | 11 | struct SimpleVertex 12 | { 13 | XMFLOAT3 Position; 14 | XMFLOAT2 TexCoord; 15 | XMFLOAT3 Normal; 16 | }; 17 | 18 | struct InstanceData 19 | { 20 | XMMATRIX Transformation; 21 | }; 22 | 23 | struct AnimationData 24 | { 25 | XMUINT4 aBoneIndices; 26 | XMFLOAT4 aBoneWeights; 27 | }; 28 | 29 | struct CBChangeOnCameraMovement 30 | { 31 | XMMATRIX View; 32 | XMFLOAT4 CameraPosition; 33 | }; 34 | 35 | struct CBChangeOnResize 36 | { 37 | XMMATRIX Projection; 38 | }; 39 | 40 | struct CBChangesEveryFrame 41 | { 42 | XMMATRIX World; 43 | XMFLOAT4 OutputColor; 44 | }; 45 | 46 | struct CBSkinning 47 | { 48 | XMMATRIX BoneTransforms[MAX_NUM_BONES]; 49 | }; 50 | 51 | struct CBLights 52 | { 53 | XMFLOAT4 LightPositions[NUM_LIGHTS]; 54 | XMFLOAT4 LightColors[NUM_LIGHTS]; 55 | }; 56 | 57 | } -------------------------------------------------------------------------------- /Lab08/Library/Shader/SkinningVertexShader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader/SkinningVertexShader.h" 2 | 3 | namespace library 4 | { 5 | SkinningVertexShader::SkinningVertexShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel) 6 | : VertexShader(pszFileName, pszEntryPoint, pszShaderModel) 7 | { 8 | } 9 | 10 | HRESULT SkinningVertexShader::Initialize(_In_ ID3D11Device* pDevice) 11 | { 12 | ComPtr vsBlob; 13 | HRESULT hr = compile(vsBlob.GetAddressOf()); 14 | if (FAILED(hr)) 15 | { 16 | WCHAR szMessage[256]; 17 | swprintf_s( 18 | szMessage, 19 | L"The FX file %s cannot be compiled. Please run this executable from the directory that contains the FX file.", 20 | m_pszFileName 21 | ); 22 | MessageBox( 23 | nullptr, 24 | szMessage, 25 | L"Error", 26 | MB_OK 27 | ); 28 | return hr; 29 | } 30 | 31 | hr = pDevice->CreateVertexShader(vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), nullptr, m_vertexShader.GetAddressOf()); 32 | if (FAILED(hr)) 33 | { 34 | return hr; 35 | } 36 | 37 | // Define the input layout 38 | D3D11_INPUT_ELEMENT_DESC aLayouts[] = 39 | { 40 | { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, 41 | { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, 42 | { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }, 43 | 44 | { "BONEINDICES", 0, DXGI_FORMAT_R32G32B32A32_UINT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, 45 | { "BONEWEIGHTS", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 } 46 | }; 47 | UINT uNumElements = ARRAYSIZE(aLayouts); 48 | 49 | // Create the input layout 50 | hr = pDevice->CreateInputLayout(aLayouts, uNumElements, vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), m_vertexLayout.GetAddressOf()); 51 | 52 | return hr; 53 | } 54 | } -------------------------------------------------------------------------------- /Lab08/Library/Shader/SkinningVertexShader.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: SKINNINGVERTEXSHADER.H 3 | 4 | Summary: SkinningVertexShader header file contains declarations of 5 | SkinningVertexShader class used for the lab samples of Game 6 | Graphics Programming course. 7 | 8 | Classes: SkinningVertexShader 9 | 10 | 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Shader/VertexShader.h" 17 | 18 | namespace library 19 | { 20 | class SkinningVertexShader : public VertexShader 21 | { 22 | public: 23 | SkinningVertexShader() = delete; 24 | SkinningVertexShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel); 25 | SkinningVertexShader(const SkinningVertexShader& other) = delete; 26 | SkinningVertexShader(SkinningVertexShader&& other) = delete; 27 | SkinningVertexShader& operator=(const SkinningVertexShader& other) = delete; 28 | SkinningVertexShader& operator=(SkinningVertexShader&& other) = delete; 29 | virtual ~SkinningVertexShader() = default; 30 | 31 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice) override; 32 | }; 33 | } -------------------------------------------------------------------------------- /Lab09/Game/Content/Common/InvalidTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/Common/InvalidTexture.png -------------------------------------------------------------------------------- /Lab09/Game/Content/Cube/diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/Cube/diffuse.png -------------------------------------------------------------------------------- /Lab09/Game/Content/Cube/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/Cube/normal.png -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Slightly adapted version (by Joey de Vries) of Cyborg model. 2 | 3 | From: 3dregenerator 4 | Downloaded at: http://tf3dm.com/3d-model/cyborg-78.html 5 | 6 | For Personal Use Only. -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/cyborg.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/cyborg/cyborg.blend -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/cyborg.blend1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/cyborg/cyborg.blend1 -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/cyborg.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'cyborg.blend' 2 | # Material Count: 1 3 | 4 | newmtl Cyborg 5 | Ns 92.156863 6 | Ka 0.000000 0.000000 0.000000 7 | Kd 0.512000 0.512000 0.512000 8 | Ks 0.000000 0.000000 0.000000 9 | Ni 1.000000 10 | d 1.000000 11 | illum 2 12 | map_Kd cyborg_diffuse.png 13 | map_Bump cyborg_normal.png 14 | map_Ks cyborg_specular.png 15 | -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/cyborg_diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/cyborg/cyborg_diffuse.png -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/cyborg_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/cyborg/cyborg_normal.png -------------------------------------------------------------------------------- /Lab09/Game/Content/cyborg/cyborg_specular.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab09/Game/Content/cyborg/cyborg_specular.png -------------------------------------------------------------------------------- /Lab09/Game/Shaders/PhongShaders.fxh: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: PhongShaders.fxh 3 | // 4 | // Copyright (c) Microsoft Corporation. 5 | // Licensed under the MIT License (MIT). 6 | //-------------------------------------------------------------------------------------- 7 | 8 | #define NUM_LIGHTS (2) 9 | 10 | //-------------------------------------------------------------------------------------- 11 | // Global Variables 12 | //-------------------------------------------------------------------------------------- 13 | /*-------------------------------------------------------------------- 14 | TODO: Declare texture array and sampler state array for diffuse texture and normal texture (remove the comment) 15 | --------------------------------------------------------------------*/ 16 | 17 | //-------------------------------------------------------------------------------------- 18 | // Constant Buffer Variables 19 | //-------------------------------------------------------------------------------------- 20 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 21 | Cbuffer: cbChangesEveryFrame 22 | 23 | Summary: Constant buffer used for world transformation 24 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 25 | /*-------------------------------------------------------------------- 26 | TODO: cbChangesEveryFrame definition (remove the comment) 27 | 28 | 29 | //-------------------------------------------------------------------------------------- 30 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 31 | Struct: VS_PHONG_INPUT 32 | 33 | Summary: Used as the input to the vertex shader 34 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 35 | /*-------------------------------------------------------------------- 36 | TODO: VS_PHONG_INPUT definition (remove the comment) 37 | --------------------------------------------------------------------*/ 38 | 39 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 40 | Struct: PS_PHONG_INPUT 41 | 42 | Summary: Used as the input to the pixel shader, output of the 43 | vertex shader 44 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 45 | /*-------------------------------------------------------------------- 46 | TODO: PS_PHONG_INPUT definition (remove the comment) 47 | --------------------------------------------------------------------*/ 48 | 49 | //-------------------------------------------------------------------------------------- 50 | // Vertex Shader 51 | //-------------------------------------------------------------------------------------- 52 | /*-------------------------------------------------------------------- 53 | TODO: Vertex Shader function VSPhong definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | 56 | 57 | //-------------------------------------------------------------------------------------- 58 | // Pixel Shader 59 | //-------------------------------------------------------------------------------------- 60 | /*-------------------------------------------------------------------- 61 | TODO: Pixel Shader function PSPhong definition (remove the comment) 62 | --------------------------------------------------------------------*/ -------------------------------------------------------------------------------- /Lab09/Game/Shaders/VoxelShaders.fxh: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: VoxelShaders.fxh 3 | // 4 | // Copyright (c) Kyung Hee University. 5 | //-------------------------------------------------------------------------------------- 6 | 7 | #define NUM_LIGHTS (2) 8 | 9 | //-------------------------------------------------------------------------------------- 10 | // Global Variables 11 | //-------------------------------------------------------------------------------------- 12 | /*-------------------------------------------------------------------- 13 | TODO: Declare texture array and sampler state array for diffuse texture and normal texture (remove the comment) 14 | --------------------------------------------------------------------*/ 15 | 16 | //-------------------------------------------------------------------------------------- 17 | // Constant Buffer Variables 18 | //-------------------------------------------------------------------------------------- 19 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 20 | Cbuffer: cbChangesEveryFrame 21 | 22 | Summary: Constant buffer used for world transformation 23 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 24 | /*-------------------------------------------------------------------- 25 | TODO: cbChangesEveryFrame definition (remove the comment) 26 | 27 | //-------------------------------------------------------------------------------------- 28 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 29 | Struct: VS_INPUT 30 | 31 | Summary: Used as the input to the vertex shader, 32 | instance data included 33 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 34 | /*-------------------------------------------------------------------- 35 | TODO: VS_INPUT definition (remove the comment) 36 | --------------------------------------------------------------------*/ 37 | 38 | /*C+C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C+++C 39 | Struct: PS_INPUT 40 | 41 | Summary: Used as the input to the pixel shader, output of the 42 | vertex shader 43 | C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C---C-C*/ 44 | /*-------------------------------------------------------------------- 45 | TODO: PS_INPUT definition (remove the comment) 46 | --------------------------------------------------------------------*/ 47 | 48 | 49 | //-------------------------------------------------------------------------------------- 50 | // Vertex Shader 51 | //-------------------------------------------------------------------------------------- 52 | /*-------------------------------------------------------------------- 53 | TODO: Vertex Shader function VSVoxel definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | 56 | 57 | //-------------------------------------------------------------------------------------- 58 | // Pixel Shader 59 | //-------------------------------------------------------------------------------------- 60 | /*-------------------------------------------------------------------- 61 | TODO: Pixel Shader function PSVoxel definition (remove the comment) 62 | --------------------------------------------------------------------*/ -------------------------------------------------------------------------------- /Lab09/Library/Common.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: COMMON.H 3 | 4 | Summary: Common header file that contains common header files and 5 | macros used for the Library project of Game Graphics 6 | Programming course. 7 | 8 | Functions: 9 | 10 | � 2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #ifndef UNICODE 15 | #define UNICODE 16 | #endif // ! UNICODE 17 | 18 | #ifndef WIN32_LEAN_AND_MEAN 19 | #define WIN32_LEAN_AND_MEAN 20 | #endif // ! WIN32_LEAN_AND_MEAN 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #pragma comment(lib, "d3d11.lib") 27 | #pragma comment(lib, "d3dcompiler.lib") 28 | #pragma comment(lib, "dxguid.lib") 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | #define _CRTDBG_MAP_ALLOC 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | #include "Resource.h" 47 | 48 | constexpr LPCWSTR PSZ_COURSE_TITLE = L"Game Graphics Programming"; 49 | 50 | using namespace Microsoft::WRL; 51 | using namespace DirectX; 52 | 53 | #define ASSIMP_LOAD_FLAGS (aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_JoinIdenticalVertices | aiProcess_ConvertToLeftHanded | aiProcess_CalcTangentSpace) 54 | 55 | namespace library 56 | { 57 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 58 | Struct: DirectionsInput 59 | 60 | Summary: Data structure that stores keyboard movement data 61 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 62 | struct DirectionsInput 63 | { 64 | BOOL bFront; 65 | BOOL bLeft; 66 | BOOL bBack; 67 | BOOL bRight; 68 | BOOL bUp; 69 | BOOL bDown; 70 | }; 71 | 72 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 73 | Struct: MouseRelativeMovement 74 | 75 | Summary: Data structure that stores mouse relative movement data 76 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 77 | struct MouseRelativeMovement 78 | { 79 | LONG X; 80 | LONG Y; 81 | }; 82 | 83 | /*E+E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E+++E 84 | Enum: eBlockType 85 | 86 | Summary: Enumeration of block types 87 | E---E---E---E---E---E---E---E---E---E---E---E---E---E---E---E---E-E*/ 88 | enum class eBlockType : CHAR 89 | { 90 | GRASSLAND = 21, 91 | SNOW, 92 | OCEAN, 93 | SAND, 94 | SCORCHED, 95 | BARE, 96 | TUNDRA, 97 | TEMPERATE_DESERT, 98 | SHRUBLAND, 99 | TAIGA, 100 | TEMPERATE_DECIDUOUS_FOREST, 101 | TEMPERATE_RAIN_FOREST, 102 | SUBTROPICAL_DESERT, 103 | TROPICAL_SEASONAL_FOREST, 104 | TROPICAL_RAIN_FOREST, 105 | COUNT, 106 | }; 107 | } -------------------------------------------------------------------------------- /Lab09/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | namespace library 6 | { 7 | #define NUM_LIGHTS (2) 8 | #define MAX_NUM_BONES (256) 9 | #define MAX_NUM_BONES_PER_VERTEX (16) 10 | 11 | 12 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 13 | Struct: NormalData 14 | 15 | Summary: NormalData structure containing tangent space vetors 16 | of the vertex 17 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 18 | struct NormalData 19 | { 20 | XMFLOAT3 Tangent; 21 | XMFLOAT3 Bitangent; 22 | }; 23 | 24 | /*S+S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S+++S 25 | Struct: CBChangesEveryFrame 26 | 27 | Summary: Constant buffer containing world matrix 28 | S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S---S-S*/ 29 | struct CBChangesEveryFrame 30 | { 31 | XMMATRIX World; 32 | XMFLOAT4 OutputColor; 33 | BOOL HasNormalMap; 34 | }; 35 | 36 | } -------------------------------------------------------------------------------- /Lab09/Library/Scene/Voxel.cpp: -------------------------------------------------------------------------------- 1 | #include "Scene/Voxel.h" 2 | 3 | #include "Texture/Material.h" 4 | 5 | namespace library 6 | { 7 | 8 | HRESULT Voxel::Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) 9 | { 10 | BasicMeshEntry basicMeshEntry; 11 | basicMeshEntry.uNumIndices = NUM_INDICES; 12 | 13 | m_aMeshes.push_back(basicMeshEntry); 14 | 15 | HRESULT hr = initialize(pDevice, pImmediateContext); 16 | if (FAILED(hr)) 17 | { 18 | return hr; 19 | } 20 | 21 | hr = initializeInstance(pDevice); 22 | if (FAILED(hr)) 23 | { 24 | return hr; 25 | } 26 | 27 | if (HasTexture() > 0) 28 | { 29 | hr = SetMaterialOfMesh(0, 0); 30 | if (FAILED(hr)) 31 | { 32 | return hr; 33 | } 34 | } 35 | 36 | return S_OK; 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /Lab09/Library/Texture/Material.cpp: -------------------------------------------------------------------------------- 1 | #include "Material.h" 2 | 3 | namespace library 4 | { 5 | Material::Material(_In_ std::wstring szName) 6 | : m_padding{ '\0', } 7 | , pDiffuse() 8 | , pSpecularExponent() 9 | , pNormal() 10 | , m_szName(szName) 11 | { 12 | } 13 | 14 | HRESULT Material::Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) 15 | { 16 | HRESULT hr = S_OK; 17 | 18 | if (pDiffuse) 19 | { 20 | hr = pDiffuse->Initialize(pDevice, pImmediateContext); 21 | if (FAILED(hr)) 22 | { 23 | return hr; 24 | } 25 | } 26 | 27 | if (pSpecularExponent) 28 | { 29 | hr = pSpecularExponent->Initialize(pDevice, pImmediateContext); 30 | if (FAILED(hr)) 31 | { 32 | return hr; 33 | } 34 | } 35 | 36 | if (pNormal) 37 | { 38 | hr = pNormal->Initialize(pDevice, pImmediateContext); 39 | if (FAILED(hr)) 40 | { 41 | return hr; 42 | } 43 | } 44 | 45 | return hr; 46 | } 47 | 48 | std::wstring Material::GetName() const 49 | { 50 | return m_szName; 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /Lab09/Library/Texture/Material.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: MATERIAL.H 3 | 4 | Summary: Material header file contains declaration of class 5 | Material used to abstract multiple texture data. 6 | 7 | Classes: Material 8 | 9 | ?2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | #include "Texture/Texture.h" 16 | 17 | namespace library 18 | { 19 | class Material 20 | { 21 | public: 22 | Material() = delete; 23 | Material(_In_ std::wstring szName); 24 | Material(const Material& other) = default; 25 | Material(Material&& other) = default; 26 | Material& operator=(const Material& other) = default; 27 | Material& operator=(Material&& other) = default; 28 | virtual ~Material() = default; 29 | 30 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext); 31 | 32 | std::wstring GetName() const; 33 | 34 | private: 35 | BYTE m_padding[4]; 36 | std::wstring m_szName; 37 | 38 | public: 39 | std::shared_ptr pDiffuse; 40 | std::shared_ptr pSpecularExponent; 41 | std::shared_ptr pNormal; 42 | }; 43 | } -------------------------------------------------------------------------------- /Lab10/Game/Content/plane.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IIIXRCourses/GameGraphicsProgrammingStarterPack/ebf64a69bfde400d08d4801224b4cff52d650b75/Lab10/Game/Content/plane.jpg -------------------------------------------------------------------------------- /Lab10/Game/Cube/Cube.cpp: -------------------------------------------------------------------------------- 1 | #include "Cube/Cube.h" 2 | 3 | 4 | HRESULT Cube::Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) 5 | { 6 | BasicMeshEntry basicMeshEntry; 7 | basicMeshEntry.uNumIndices = NUM_INDICES; 8 | 9 | m_aMeshes.push_back(basicMeshEntry); 10 | 11 | if (HasTexture()) 12 | { 13 | SetMaterialOfMesh(0, 0); 14 | } 15 | 16 | return initialize(pDevice, pImmediateContext); 17 | } 18 | -------------------------------------------------------------------------------- /Lab10/Game/Cube/Cube.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: CUBE1.H 3 | 4 | Summary: Cube header file contains declarations of Cube class 5 | used for the lab samples of Game Graphics Programming 6 | course. 7 | 8 | Classes: Cube 9 | 10 | ?2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Cube/BaseCube.h" 17 | 18 | class Cube : public BaseCube 19 | { 20 | public: 21 | Cube(_In_ const XMFLOAT4& outputColor); 22 | Cube(const Cube& other) = delete; 23 | Cube(Cube&& other) = delete; 24 | Cube& operator=(const Cube& other) = delete; 25 | Cube& operator=(Cube&& other) = delete; 26 | ~Cube() = default; 27 | 28 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext) override; 29 | virtual void Update(_In_ FLOAT deltaTime) override; 30 | }; 31 | 32 | -------------------------------------------------------------------------------- /Lab10/Game/Light/RotatingPointLight.cpp: -------------------------------------------------------------------------------- 1 | #include "Light/RotatingPointLight.h" 2 | 3 | 4 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 5 | Method: RotatingPointLight::Update 6 | 7 | Summary: Update every frame 8 | 9 | Args: FLOAT deltaTime 10 | 11 | Modifies: [m_position, m_eye, m_eye, m_at, 12 | m_view]. 13 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 14 | /*-------------------------------------------------------------------- 15 | TODO: RotatingPointLight::Update definition (remove the comment) 16 | --------------------------------------------------------------------*/ -------------------------------------------------------------------------------- /Lab10/Game/Shaders/PhongShaders.fxh: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: PhongShaders.fx 3 | // 4 | // Copyright (c) Microsoft Corporation. 5 | // Licensed under the MIT License (MIT). 6 | //-------------------------------------------------------------------------------------- 7 | 8 | //-------------------------------------------------------------------------------------- 9 | // Constant Buffer Variables 10 | //-------------------------------------------------------------------------------------- 11 | #define NUM_LIGHTS (1) 12 | #define NEAR_PLANE (0.01f) 13 | #define FAR_PLANE (1000.0f) 14 | 15 | Texture2D shadowMapTexture : register(t2); 16 | SamplerState shadowMapSampler : register(s2); 17 | 18 | cbuffer cbLights : register(b3) 19 | { 20 | float4 LightPositions[NUM_LIGHTS]; 21 | float4 LightColors[NUM_LIGHTS]; 22 | matrix LightViews[NUM_LIGHTS]; 23 | matrix LightProjections[NUM_LIGHTS]; 24 | }; 25 | 26 | struct PS_PHONG_INPUT 27 | { 28 | float4 Position : SV_POSITION; 29 | float2 TexCoord : TEXCOORD0; 30 | float3 Normal : NORMAL; 31 | float3 WorldPosition : WORLDPOS; 32 | float3 Tangent : TANGENT; 33 | float3 Bitangent : BITANGENT; 34 | float4 LightViewPosition : TEXCOORD1; 35 | }; 36 | 37 | //-------------------------------------------------------------------------------------- 38 | // Vertex Shader 39 | //-------------------------------------------------------------------------------------- 40 | PS_PHONG_INPUT VSPhong(VS_INPUT input) 41 | { 42 | /*-------------------------------------------------------------------- 43 | TODO: Vertex shader code (remove the comment) 44 | --------------------------------------------------------------------*/ 45 | } 46 | 47 | float LinearizeDepth(float depth) 48 | { 49 | float z = depth * 2.0 - 1.0; 50 | return ((2.0 * NEAR_PLANE * FAR_PLANE) / (FAR_PLANE + NEAR_PLANE - z * (FAR_PLANE - NEAR_PLANE))) / FAR_PLANE; 51 | } 52 | 53 | //-------------------------------------------------------------------------------------- 54 | // Pixel Shader 55 | //-------------------------------------------------------------------------------------- 56 | float4 PSPhong(PS_PHONG_INPUT input) : SV_Target 57 | { 58 | /*-------------------------------------------------------------------- 59 | TODO: Pixel shader code (remove the comment) 60 | --------------------------------------------------------------------*/ 61 | } -------------------------------------------------------------------------------- /Lab10/Game/Shaders/ShadowShaders.fxh: -------------------------------------------------------------------------------- 1 | //-------------------------------------------------------------------------------------- 2 | // File: ShadowShaders.fx 3 | // 4 | // Copyright (c) Microsoft Corporation. 5 | // Licensed under the MIT License (MIT). 6 | //-------------------------------------------------------------------------------------- 7 | 8 | //-------------------------------------------------------------------------------------- 9 | // Constant Buffer Variables 10 | //-------------------------------------------------------------------------------------- 11 | cbuffer cbShadowMatrix : register(b0) 12 | { 13 | matrix World; 14 | matrix View; 15 | matrix Projection; 16 | bool isVoxel; 17 | } 18 | 19 | struct VS_SHADOW_INPUT 20 | { 21 | float4 Position : POSITION; 22 | row_major matrix mTransform : INSTANCE_TRANSFORM; 23 | }; 24 | 25 | 26 | struct PS_SHADOW_INPUT 27 | { 28 | float4 Position : SV_POSITION; 29 | float4 DepthPosition : TEXCOORD0; 30 | }; 31 | 32 | 33 | //-------------------------------------------------------------------------------------- 34 | // Vertex Shader 35 | //-------------------------------------------------------------------------------------- 36 | PS_SHADOW_INPUT VSShadow(VS_SHADOW_INPUT input) 37 | { 38 | /*-------------------------------------------------------------------- 39 | TODO: Vertex shader code (remove the comment) 40 | --------------------------------------------------------------------*/ 41 | }; 42 | 43 | 44 | //-------------------------------------------------------------------------------------- 45 | // Pixel Shader 46 | //-------------------------------------------------------------------------------------- 47 | float4 PSShadow(PS_SHADOW_INPUT input) : SV_Target 48 | { 49 | /*-------------------------------------------------------------------- 50 | TODO: Pixel shader code (remove the comment) 51 | --------------------------------------------------------------------*/ 52 | }; -------------------------------------------------------------------------------- /Lab10/Library/Light/PointLight.cpp: -------------------------------------------------------------------------------- 1 | #include "Light/PointLight.h" 2 | 3 | #include "Renderer/DataTypes.h" 4 | 5 | namespace library 6 | { 7 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 8 | Method: PointLight::PointLight 9 | 10 | Summary: Constructor 11 | 12 | Modifies: [m_position, m_color, m_eye, m_at, 13 | m_up, m_view, m_projection]. 14 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 15 | /*-------------------------------------------------------------------- 16 | TODO: PointLight::PointLight definition (remove the comment) 17 | --------------------------------------------------------------------*/ 18 | 19 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 20 | Method: PointLight::GetViewMatrix 21 | 22 | Summary: Return the view matrix 23 | 24 | Returns: XMMATRIX 25 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 26 | /*-------------------------------------------------------------------- 27 | TODO: PointLight::GetViewMatrix definition (remove the comment) 28 | --------------------------------------------------------------------*/ 29 | 30 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 31 | Method: PointLight::GetProjectionMatrix 32 | 33 | Summary: Return the projection matrix 34 | 35 | Returns: XMMATRIX 36 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 37 | /*-------------------------------------------------------------------- 38 | TODO: PointLight::GetProjectionMatrix definition (remove the comment) 39 | --------------------------------------------------------------------*/ 40 | 41 | 42 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 43 | Method: PointLight::Initialize 44 | 45 | Summary: Initialize the projection matrix 46 | 47 | Args: UINT uWidth 48 | UINT uHeight 49 | 50 | Modifies: [m_projection] 51 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 52 | /*-------------------------------------------------------------------- 53 | TODO: PointLight::Initialize definition (remove the comment) 54 | --------------------------------------------------------------------*/ 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Lab10/Library/Light/PointLight.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: POINTLIGHT.H 3 | 4 | Summary: Light header file contains declarations of the 5 | point light. 6 | 7 | Classes: PointLight 8 | 9 | ?2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | #include "Shader/PixelShader.h" 16 | 17 | namespace library 18 | { 19 | class PointLight 20 | { 21 | public: 22 | PointLight() = delete; 23 | PointLight(_In_ const XMFLOAT4& position, _In_ const XMFLOAT4& color); 24 | PointLight(const PointLight& other) = default; 25 | PointLight(PointLight&& other) = default; 26 | PointLight& operator=(const PointLight& other) = default; 27 | PointLight& operator=(PointLight&& other) = default; 28 | virtual ~PointLight() = default; 29 | 30 | const XMFLOAT4& GetPosition() const; 31 | const XMFLOAT4& GetColor() const; 32 | const XMMATRIX& GetViewMatrix() const; 33 | const XMMATRIX& GetProjectionMatrix() const; 34 | 35 | virtual void Initialize(_In_ UINT uWidth, _In_ UINT uHeight); 36 | virtual void Update(_In_ FLOAT deltaTime); 37 | protected: 38 | XMFLOAT4 m_position; 39 | XMFLOAT4 m_color; 40 | XMVECTOR m_eye; 41 | XMVECTOR m_at; 42 | XMVECTOR m_up; 43 | XMMATRIX m_view; 44 | XMMATRIX m_projection; 45 | 46 | static constexpr const XMVECTORF32 DEFAULT_UP = { 0.0f, 1.0f, 0.0f, 0.0f }; 47 | }; 48 | } -------------------------------------------------------------------------------- /Lab10/Library/Renderer/DataTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Common.h" 4 | 5 | namespace library 6 | { 7 | #define NUM_LIGHTS (1) 8 | #define MAX_NUM_BONES (256) 9 | #define MAX_NUM_BONES_PER_VERTEX (16) 10 | 11 | struct SimpleVertex 12 | { 13 | XMFLOAT3 Position; 14 | XMFLOAT2 TexCoord; 15 | XMFLOAT3 Normal; 16 | }; 17 | 18 | struct InstanceData 19 | { 20 | XMMATRIX Transformation; 21 | }; 22 | 23 | struct AnimationData 24 | { 25 | XMUINT4 aBoneIndices; 26 | XMFLOAT4 aBoneWeights; 27 | }; 28 | 29 | struct NormalData 30 | { 31 | XMFLOAT3 Tangent; 32 | XMFLOAT3 Bitangent; 33 | }; 34 | 35 | struct CBChangeOnCameraMovement 36 | { 37 | XMMATRIX View; 38 | XMFLOAT4 CameraPosition; 39 | }; 40 | 41 | struct CBChangeOnResize 42 | { 43 | XMMATRIX Projection; 44 | }; 45 | 46 | struct CBChangesEveryFrame 47 | { 48 | XMMATRIX World; 49 | XMFLOAT4 OutputColor; 50 | }; 51 | 52 | struct CBSkinning 53 | { 54 | XMMATRIX BoneTransforms[MAX_NUM_BONES]; 55 | }; 56 | 57 | struct CBLights 58 | { 59 | XMFLOAT4 LightPositions[NUM_LIGHTS]; 60 | XMFLOAT4 LightColors[NUM_LIGHTS]; 61 | XMMATRIX LightViews[NUM_LIGHTS]; 62 | XMMATRIX LightProjections[NUM_LIGHTS]; 63 | }; 64 | 65 | struct CBShadowMatrix 66 | { 67 | XMMATRIX World; 68 | XMMATRIX View; 69 | XMMATRIX Projection; 70 | BOOL IsVoxel; 71 | }; 72 | } -------------------------------------------------------------------------------- /Lab10/Library/Shader/ShadowVertexShader.cpp: -------------------------------------------------------------------------------- 1 | #include "Shader/ShadowVertexShader.h" 2 | 3 | namespace library 4 | { 5 | ShadowVertexShader::ShadowVertexShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel) 6 | : VertexShader(pszFileName, pszEntryPoint, pszShaderModel) 7 | { 8 | } 9 | 10 | HRESULT ShadowVertexShader::Initialize(_In_ ID3D11Device* pDevice) 11 | { 12 | ComPtr vsBlob; 13 | HRESULT hr = compile(vsBlob.GetAddressOf()); 14 | if (FAILED(hr)) 15 | { 16 | WCHAR szMessage[256]; 17 | swprintf_s( 18 | szMessage, 19 | L"The FX file %s cannot be compiled. Please run this executable from the directory that contains the FX file.", 20 | m_pszFileName 21 | ); 22 | MessageBox( 23 | nullptr, 24 | szMessage, 25 | L"Error", 26 | MB_OK 27 | ); 28 | return hr; 29 | } 30 | 31 | hr = pDevice->CreateVertexShader(vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), nullptr, m_vertexShader.GetAddressOf()); 32 | if (FAILED(hr)) 33 | { 34 | return hr; 35 | } 36 | 37 | // Define the input layout 38 | D3D11_INPUT_ELEMENT_DESC aLayouts[] = 39 | { 40 | { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, 41 | { "INSTANCE_TRANSFORM", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, 42 | { "INSTANCE_TRANSFORM", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, 43 | { "INSTANCE_TRANSFORM", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, 44 | { "INSTANCE_TRANSFORM", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1 }, 45 | }; 46 | UINT uNumElements = ARRAYSIZE(aLayouts); 47 | 48 | // Create the input layout 49 | hr = pDevice->CreateInputLayout(aLayouts, uNumElements, vsBlob->GetBufferPointer(), vsBlob->GetBufferSize(), m_vertexLayout.GetAddressOf()); 50 | if (FAILED(hr)) 51 | { 52 | return hr; 53 | } 54 | 55 | return hr; 56 | } 57 | } -------------------------------------------------------------------------------- /Lab10/Library/Shader/ShadowVertexShader.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: SHADOWVERTEXSHADER.H 3 | 4 | Summary: ShadowVertexShader header file contains declarations of 5 | ShadowVertexShader class used for the lab samples of Game 6 | Graphics Programming course. 7 | 8 | Classes: ShadowVertexShader 9 | 10 | ?2022 Kyung Hee University 11 | ===================================================================+*/ 12 | #pragma once 13 | 14 | #include "Common.h" 15 | 16 | #include "Shader/VertexShader.h" 17 | 18 | namespace library 19 | { 20 | class ShadowVertexShader : public VertexShader 21 | { 22 | public: 23 | ShadowVertexShader() = delete; 24 | ShadowVertexShader(_In_ PCWSTR pszFileName, _In_ PCSTR pszEntryPoint, _In_ PCSTR pszShaderModel); 25 | ShadowVertexShader(const ShadowVertexShader& other) = delete; 26 | ShadowVertexShader(ShadowVertexShader&& other) = delete; 27 | ShadowVertexShader& operator=(const ShadowVertexShader& other) = delete; 28 | ShadowVertexShader& operator=(ShadowVertexShader&& other) = delete; 29 | virtual ~ShadowVertexShader() = default; 30 | 31 | virtual HRESULT Initialize(_In_ ID3D11Device* pDevice) override; 32 | }; 33 | } -------------------------------------------------------------------------------- /Lab10/Library/Texture/RenderTexture.cpp: -------------------------------------------------------------------------------- 1 | #include "RenderTexture.h" 2 | 3 | namespace library 4 | { 5 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 6 | Method: RenderTexture::RenderTexture 7 | 8 | Summary: Constructor 9 | 10 | Modifies: [m_uWidth, m_uHeight, m_texture2D, m_renderTargetView, 11 | m_shaderResourceView, m_samplerClamp]. 12 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 13 | /*-------------------------------------------------------------------- 14 | TODO: RenderTexture::RenderTexture definition (remove the comment) 15 | --------------------------------------------------------------------*/ 16 | 17 | 18 | /*M+M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M+++M 19 | Method: RenderTexture::Initialize 20 | 21 | Summary: Initialize 22 | 23 | Args: ID3D11Device* pDevice 24 | ID3D11DeviceContext* pImmediateContext 25 | 26 | Modifies: [m_texture2D, m_renderTargetView, m_shaderResourceView, 27 | m_samplerClamp]. 28 | 29 | Returns: HRESULT 30 | Status code 31 | M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M---M-M*/ 32 | /*-------------------------------------------------------------------- 33 | TODO: RenderTexture::Initialize definition (remove the comment) 34 | --------------------------------------------------------------------*/ 35 | 36 | 37 | ComPtr& RenderTexture::GetTexture2D() 38 | { 39 | return m_texture2D; 40 | } 41 | 42 | ComPtr& RenderTexture::GetRenderTargetView() 43 | { 44 | return m_renderTargetView; 45 | } 46 | 47 | ComPtr& RenderTexture::GetShaderResourceView() 48 | { 49 | return m_shaderResourceView; 50 | } 51 | 52 | ComPtr& RenderTexture::GetSamplerState() 53 | { 54 | return m_samplerClamp; 55 | } 56 | 57 | } -------------------------------------------------------------------------------- /Lab10/Library/Texture/RenderTexture.h: -------------------------------------------------------------------------------- 1 | /*+=================================================================== 2 | File: RENDERTEXTURE.H 3 | 4 | Summary: RenderTexture header file contains declaration of class 5 | RenderTexture used to create a Render-To-Texture 6 | 7 | Classes: RenderTexture 8 | 9 | ?2022 Kyung Hee University 10 | ===================================================================+*/ 11 | #pragma once 12 | 13 | #include "Common.h" 14 | 15 | namespace library 16 | { 17 | class RenderTexture 18 | { 19 | public: 20 | RenderTexture() = delete; 21 | RenderTexture(_In_ UINT uWidth, _In_ UINT uHeight); 22 | RenderTexture(const RenderTexture& other) = delete; 23 | RenderTexture(RenderTexture&& other) = delete; 24 | RenderTexture& operator=(const RenderTexture& other) = delete; 25 | RenderTexture& operator=(RenderTexture&& other) = delete; 26 | ~RenderTexture() = default; 27 | 28 | HRESULT Initialize(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pImmediateContext); 29 | 30 | ComPtr& GetTexture2D(); 31 | ComPtr& GetRenderTargetView(); 32 | ComPtr& GetShaderResourceView(); 33 | ComPtr& GetSamplerState(); 34 | 35 | private: 36 | UINT m_uWidth; 37 | UINT m_uHeight; 38 | 39 | ComPtr m_texture2D; 40 | ComPtr m_renderTargetView; 41 | ComPtr m_shaderResourceView; 42 | ComPtr m_samplerClamp; 43 | }; 44 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GameGraphicsProgrammingStarterPack 2 | Starter Pack for all the labs, assignments of Game Graphics Programming SWCON311 source 3 | --------------------------------------------------------------------------------