forked from microsoft/Xbox-GDK-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleGame.h
More file actions
128 lines (95 loc) · 3.6 KB
/
Copy pathSampleGame.h
File metadata and controls
128 lines (95 loc) · 3.6 KB
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
//--------------------------------------------------------------------------------------
// SampleGame.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#include "Helpers\XTaskQueueHandleWrapper.h"
#include "DeviceResources.h"
#include "GameLogic\GameSaveManager.h"
#include "Common\InputState.h"
#include "GameLogic\ScreenManager.h"
#include "GameLogic\StateManager.h"
#include "StepTimer.h"
namespace GameSaveSample
{
// PIX event colors
const UINT EVT_COLOR_UPDATE = PIX_COLOR_INDEX( 1 );
const UINT EVT_COLOR_CLEAR = PIX_COLOR_INDEX( 2 );
const UINT EVT_COLOR_RENDER = PIX_COLOR_INDEX( 3 );
const UINT EVT_COLOR_PRESENT = PIX_COLOR_INDEX( 4 );
// A basic sample implementation that creates a D3D12 device and
// provides a render loop.
class SampleGame
{
public:
SampleGame() noexcept( false );
~SampleGame();
// Initialization and management
void Initialize( HWND window );
// Basic render loop
void Tick();
// Messages
void OnSuspending();
void OnResuming();
private:
void Update( DX::StepTimer const& timer );
void Render();
void Clear();
void CreateDeviceDependentResources();
void CreateWindowSizeDependentResources();
// Device resources.
std::shared_ptr<DX::DeviceResources> m_deviceResources;
// Rendering loop timer.
uint64_t m_frame;
DX::StepTimer m_timer;
// Input Manager
DirectX::InputState m_inputManager;
// Screen Manager (updates and renders all game screens)
ScreenManager m_screenManager;
// State Manager
StateManager m_stateManager;
// Gamepad and Gamepad Index
IGameInputDevice* m_gamepadDevice;
int m_gamepadIndex;
// DirectXTK objects.
std::unique_ptr<DirectX::GraphicsMemory> m_graphicsMemory;
// An async task queue for the sample which will post tasks and completions on the thread pool.
ATG::TaskQueueHandle m_asyncQueue;
// Game Save Manager
GameSaveManager m_gameSaveManager;
public:
// Properties
constexpr void GetDefaultSize( int& width, int& height ) const;
// Unwrapped task - initializes the game save system for the current user. (A task wrapper calls this from
// StateManager::InitializeGameSaveSystem).
HRESULT InitializeGameSaveSystemTask();
int GetCurrentGamepadIndex() {
return m_gamepadIndex;
}
// Returns current gamepad paired to current user. NOTE: This is NOT refcounted - we don't own the reference.
IGameInputDevice* GetCurrentGamepad() {
return m_gamepadDevice;
}
// Returns true if a gamepad was found for Current User, or false if a gamepad could not be found for the Current User
bool UpdateCurrentGamepad();
// Sets current gamepad and gamepad index
void SetCurrentGamepad( _In_ IGameInputDevice* gamepad );
void SetCurrentGamepad( _In_ IGameInputDevice* gamepad, int index );
StateManager& GetStateManager() noexcept
{
return m_stateManager;
}
GameSaveManager& GetGameSaveManager() {
return m_gameSaveManager;
}
ATG::TaskQueueHandle& GetGeneralThreadPoolTaskQueue() {
return m_asyncQueue;
}
DirectX::InputState& GetInputManager() {
return m_inputManager;
}
};
}
extern GameSaveSample::SampleGame* g_Game;