forked from Code-Gains/DX11-Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3DRenderingApplication.hpp
109 lines (89 loc) · 3.01 KB
/
3DRenderingApplication.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
#pragma once
#include <d3d11_2.h>
#include <memory>
#include <DirectXMath.h>
#include <imgui.h>
#include <imgui_impl_glfw.h>
#include "imgui_impl_win32.h"
#include <imgui_impl_dx11.h>
#include "Definitions.hpp"
#include "Application.hpp"
#include "ShaderCollection.hpp"
#include "Cube.hpp"
#include "Sphere.hpp"
#include "Cylinder.hpp"
#include "WindowsXpPipesSimulation.hpp"
#include "Scene.hpp"
#include "PhongMaterial.hpp"
#include "3DRenderingApplication.hpp"
#include "ShaderCollection.hpp"
struct PerFrameConstantBuffer
{
DirectX::XMFLOAT4X4 viewProjectionMatrix;
};
struct PerObjectConstantBuffer
{
DirectX::XMFLOAT4X4 modelMatrix;
DirectX::XMFLOAT4X4 normalMatrix;
};
struct CameraConstantBuffer
{
DirectX::XMFLOAT3 cameraPosition;
float padding;
};
struct MaterialConstantBuffer: PhongMaterial
{};
struct LightConstantBuffer
{
DirectX::XMFLOAT4 Position;
DirectX::XMFLOAT4 Ambient;
DirectX::XMFLOAT4 Diffuse;
DirectX::XMFLOAT4 Specular;
};
class Rendering3DApplication final : public Application
{
public:
Rendering3DApplication(const std::string& title);
~Rendering3DApplication() override;
protected:
bool Initialize() override;
bool Load() override;
void OnResize(
int32_t width,
int32_t height) override;
void Update() override;
void Render() override;
private:
void CreateRasterState();
void CreateDepthStencilView();
void CreateDepthState();
void CreateConstantBuffers();
bool CreateSwapchainResources();
void DestroySwapchainResources();
WRL::ComPtr<ID3D11Device> _device = nullptr;
WRL::ComPtr<ID3D11DeviceContext> _deviceContext = nullptr;
WRL::ComPtr<IDXGIFactory2> _dxgiFactory = nullptr;
WRL::ComPtr<IDXGISwapChain1> _swapChain = nullptr;
WRL::ComPtr<ID3D11RenderTargetView> _renderTarget = nullptr;
WRL::ComPtr<ID3D11DepthStencilView> _depthTarget = nullptr;
WRL::ComPtr<ID3D11RasterizerState> _rasterState = nullptr;
WRL::ComPtr<ID3D11DepthStencilState> _depthState = nullptr;
WRL::ComPtr<ID3D11Buffer> _cubeVertices = nullptr;
WRL::ComPtr<ID3D11Buffer> _cubeIndices = nullptr;
WRL::ComPtr<ID3D11Debug> _debug = nullptr;
WRL::ComPtr<ID3D11SamplerState> _linearSamplerState = nullptr;
WRL::ComPtr<ID3D11ShaderResourceView> _textureSrv = nullptr;
WRL::ComPtr<ID3D11ShaderResourceView> _fallbackTextureSrv = nullptr;
WRL::ComPtr<ID3D11Buffer> _perFrameConstantBuffer = nullptr;
WRL::ComPtr<ID3D11Buffer> _cameraConstantBuffer = nullptr;
WRL::ComPtr<ID3D11Buffer> _lightConstantBuffer = nullptr;
WRL::ComPtr<ID3D11Buffer> _materialConstantBuffer = nullptr;
WRL::ComPtr<ID3D11Buffer> _perObjectConstantBuffer = nullptr;
ShaderCollection _shaderCollection;
PerFrameConstantBuffer _perFrameConstantBufferData{};
CameraConstantBuffer _cameraConstantBufferData{};
LightConstantBuffer _lightConstantBufferData{};
MaterialConstantBuffer _materialConstantBufferData{};
PerObjectConstantBuffer _perObjectConstantBufferData{};
Scene _scene;
};