-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphicsClass.hpp
181 lines (134 loc) · 4.29 KB
/
GraphicsClass.hpp
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#ifndef GRAPHICSCLASS_HPP
#define GRAPHICSCLASS_HPP
#include "Direct3D.hpp"
#include "Camera.hpp"
#include "ObjectHandlerClass.hpp"
#include "ConstantBufferClass.hpp"
#include "LightHandlerClass.hpp"
#include "DeferredBuffersClass.hpp"
#include "DeferredShaderClass.hpp"
#include "LightShaderClass.hpp"
#include "ShadowMapClass.hpp"
#include "ParticlesClass.hpp"
#include "QuadTreeClass.hpp"
class GraphicsClass {
private:
Direct3DContext D3D;
DeferredBuffersClass DeferredBuffers;
DeferredShaderClass DeferredShader;
LightShaderClass LightShader;
ShadowMapClass ShadowMap;
ParticleSystem Particles;
Camera MainCamera;
LightHandlerClass LightManager;
ConstantBufferClass ConstantBufferManager;
QuadTreeClass QuadTree;
// PRIVATE FUNCTIONS
/* ------------- COMMENTS -------------
First pass of deferred rendering.
Renders the scene to different G-Buffers:
- Color.
- Normal.
- WorldPos.
- Depth.
*/
void RenderSceneToTextures(
ObjectClass* ObjectArray,
ID3D11Buffer* **VertexBufferArray,
ID3D11ShaderResourceView* *TextureResourceView
);
void RenderHeightMap(
ID3D11DeviceContext* *DeviceContext,
ID3D11Buffer* VertexBuffer,
float FaceCount,
ID3D11ShaderResourceView* *ShaderResourceView
);
/* ------------- COMMENTS -------------
Samples the input from the G-Buffers which RenderSceneToTexture renders to
onto a fullscreen quad which is rendered to the BackBufferRTV.
*/
void SecondRenderPass(ID3D11ShaderResourceView* *GBufferShaderResourceViews);
/* ------------- COMMENTS -------------
Unbinds rendertargets so that they can be set as shaderResources
*/
void UnbindAllRenderTargets();
/* ------------- COMMENTS -------------
Unbinds shaderresources so that they can be set as renderTargets.
*/
void UnbindAllPSShaderResourceViews(int ShaderResourceView_Count);
/* ------------- COMMENTS -------------
Sets renderTargets.
Sets viewport.
*/
void SetDeferredRenderingContext();
public:
GraphicsClass();
~GraphicsClass();
void ReleaseAll();
Direct3DContext *GetD3D();
ID3D11Device* *GetDevice();
ID3D11DeviceContext* *GetDeviceContext();
IDXGISwapChain* *GetSwapChain();
ID3D11RenderTargetView* *GetDeferredBackBufferRTV();
Camera *GetCamera();
MatrixBufferStored *GetFormattedCBMatrix();
ID3D11Buffer* *GetConstantBuffer();
CB_Lights_Stored *GetLightHandlerStruct();
ID3D11Buffer* *GetLightHandlerBuffer();
ID3D11Texture2D* GetColorIDTexture();
/* ------------- COMMENTS -------------
Currently initializes everything but LIGHTSHADER.
*/
void Initialize(HWND wndHandle);
/* ------------- COMMENTS -------------
Creates the ShadowDepthMap, storing all the values onto
a texture 2D 'canvas'.
*/
void RenderShadowMapTexture(
ObjectClass* ObjectArray,
ID3D11Buffer* **VertexBufferArray
);
void RenderParticleSystem(
ID3D11DeviceContext* *DeviceContext,
float dt
);
void CreateQuadTree(ObjectClass *AllObjects);
/* ------------- COMMENTS -------------
Renders all objects that has been set, with deferred rendering.
Also renders the height map.
*/
void DeferredRenderAllObjects(
ObjectClass* ObjectArray,
ID3D11Buffer* **VertexBufferArray,
ID3D11ShaderResourceView* *TextureResourceViews,
ID3D11Buffer* *HeightMapVertexBuffer,
float FaceCount,
ID3D11ShaderResourceView* *HeightMapResourceView
);
/* ------------- COMMENTS -------------
Sets LightShader's internal RenderTargetView as the BackBufferRTV, so that
data rendered to it will be displayed by the application window.
I
Also sets the same BackBufferRTV and LightShader's DepthStencilView as
render targets to the output-merger stage so that Clear() can be called at the
start of rendercalls without a need for 'if-cases'.
*/
void SetMainBackBufferRTV();
/* ------------- COMMENTS -------------
*/
int QuadTreeCornerDive(DirectX::XMVECTOR Corner);
/* ------------- COMMENTS -------------
Checks which leafnodes the frustum relies in through plane/plane-intersections.
Checks which objectClones in these leafnodes who rely in the frustum with p/p-intersection.
Only render the objects which can be "seen" by the frustum.
I
[OBS: NEEDS QUAD TREE TO BE CREATED IN ADVANCE]
*/
void FrustumCull();
void SwitchCamera(
bool HoverCamActivationStatus,
TCHAR CharacterMessage,
POINT MouseCoordinates
);
};
#endif