-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGame.h
89 lines (68 loc) · 2.07 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
//
// Game.h
//
#pragma once
#include "DeviceResources.h"
#include "StepTimer.h"
// A basic game implementation that creates a D3D12 device and
// provides a game loop.
class Game final : public DX::IDeviceNotify
{
public:
Game() noexcept(false);
~Game();
Game(Game&&) = default;
Game& operator= (Game&&) = default;
Game(Game const&) = delete;
Game& operator= (Game const&) = delete;
// Initialization and management
void Initialize(HWND window, int width, int height);
// Basic game loop
void Tick();
// IDeviceNotify
void OnDeviceLost() override;
void OnDeviceRestored() override;
// Messages
void OnActivated();
void OnDeactivated();
void OnSuspending();
void OnResuming();
void OnWindowMoved();
void OnWindowSizeChanged(int width, int height);
// Properties
void GetDefaultSize( int& width, int& height ) const noexcept;
private:
void Update(DX::StepTimer const& timer);
void Render();
void Clear();
void CreateDeviceDependentResources();
void CreateWindowSizeDependentResources();
// Device resources.
std::unique_ptr<DX::DeviceResources> m_deviceResources;
// Rendering loop timer.
DX::StepTimer m_timer;
std::unique_ptr<DirectX::GraphicsMemory> m_graphicsMemory;
DirectX::SimpleMath::Matrix m_world;
DirectX::SimpleMath::Matrix m_view;
DirectX::SimpleMath::Matrix m_proj;
std::unique_ptr<DirectX::CommonStates> m_states;
std::unique_ptr<DirectX::GeometricPrimitive> m_shape;
std::unique_ptr<DirectX::DescriptorHeap> m_resourceDescriptors;
Microsoft::WRL::ComPtr<ID3D12Resource> m_texture;
Microsoft::WRL::ComPtr<ID3D12Resource> m_cubemap;
Microsoft::WRL::ComPtr<ID3D12Resource> m_normalTexture;
#if 0
std::unique_ptr<DirectX::EnvironmentMapEffect> m_effect;
#elif 0
std::unique_ptr<DirectX::NormalMapEffect> m_effect;
#else
std::unique_ptr<DirectX::DebugEffect> m_effect;
#endif
enum Descriptors : size_t
{
Wood,
EnvMap,
NormalMap,
Count
};
};