forked from vixorien/D3D11Starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.h
111 lines (91 loc) · 2.89 KB
/
Game.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include "DXCore.h"
#include <DirectXMath.h>
#include <wrl/client.h> // Used for ComPtr - a smart pointer for COM objects
#include <memory>
#include <vector>
#include "Mesh.h"
#include "Transform.h"
#include "Renderable.h"
#include "Camera.h"
#include "SimpleShader.h"
#include "Material.h"
#include "Light.h"
#include "WICTextureLoader.h"
#include "Sky.h"
// Not including the ImGui headers here because they are in DXCore.h,
// which this includes and inherits from <3.
class Game
: public DXCore
{
public:
Game(HINSTANCE hInstance);
~Game();
// Overridden setup and game loop methods, which
// will be called automatically
void Init();
void OnResize();
void Update(float deltaTime, float totalTime);
void Draw(float deltaTime, float totalTime);
private:
// Initialization helper methods - feel free to customize, combine, remove, etc.
void LoadShaders();
void LoadTexturesAndCreateMaterials();
void CreateGeometry();
void CreateRenderables();
void SetupTransforms();
void CreateShadowMapResources();
void InitLighting();
// Other helper methods
void RenderShadowMap();
// ImGui helper methods
ImGuiIO PrepImGui(float deltaTime);
void UpdateImGui(ImGuiIO frameIO);
// Note the usage of ComPtr below
// - This is a smart pointer for objects that abide by the
// Component Object Model, which DirectX objects do
// - More info here: https://github.com/Microsoft/DirectXTK/wiki/ComPtr
// Buffers to hold actual geometry data
Microsoft::WRL::ComPtr<ID3D11Buffer> vertexBuffer;
Microsoft::WRL::ComPtr<ID3D11Buffer> indexBuffer;
// SimpleShader constructs
std::shared_ptr<SimpleVertexShader> vs;
std::shared_ptr<SimplePixelShader> ps;
std::shared_ptr<SimplePixelShader> fps;
std::shared_ptr<SimpleVertexShader> skyVS;
std::shared_ptr<SimplePixelShader> skyPS;
// Camera (The)
std::shared_ptr<Camera> camera;
// Sky (The)
std::shared_ptr<Sky> sky;
// Meshes
std::vector<std::shared_ptr<Mesh>> meshes;
// Materials
std::vector<std::shared_ptr<Material>> materials;
std::shared_ptr<Material> mat1;
std::shared_ptr<Material> mat2;
//std::shared_ptr<Material> mat3;
//std::shared_ptr<Material> mat4;
// Renderables
std::vector<std::shared_ptr<Renderable>> renderables;
// Transforms
// - This is uniquely a vector of plain pointers, because renderables return pointers to their transforms
std::vector<Transform*> transforms;
// Lighting
DirectX::XMFLOAT3 ambientLight;
Light dir1;
Light dir2;
Light dir3;
Light pl1;
Light pl2;
// Shadows
int shadowMapResolution;
float shadowProjectionSize;
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> shadowDSV;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> shadowSRV;
Microsoft::WRL::ComPtr<ID3D11SamplerState> shadowSampler;
Microsoft::WRL::ComPtr<ID3D11RasterizerState> shadowRasterizer;
DirectX::XMFLOAT4X4 shadowViewMatrix;
DirectX::XMFLOAT4X4 shadowProjectionMatrix;
std::shared_ptr<SimpleVertexShader> shadowVS;
};