This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 226
/
Menus.h
183 lines (151 loc) · 3.98 KB
/
Menus.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
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
182
183
//--------------------------------------------------------------------------------------
// D3D12RaytracingAO.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#include "ATGColors.h"
#include "Effects.h"
#include "PrimitiveBatch.h"
#include "SpriteFont.h"
#include "VertexTypes.h"
namespace MenuCSUDesc
{
enum CSUDesc
{
SRVSmallFont,
CSUCount
};
}
namespace MenuLightingModel
{
enum LightingModel
{
AO,
SSAO,
LightingModelCount
};
}
class Option
{
public:
Option(DOUBLE pStart, DOUBLE pMin, DOUBLE pMax, DOUBLE pInc, bool pIsint = false) :
m_start(pStart), m_current(pStart), m_min(pMin), m_max(pMax), m_inc(pInc), m_isInt(pIsint)
{
}
bool Increment()
{
auto tmp = m_current;
m_current += m_inc;
m_current = std::max(m_current, m_min);
m_current = std::min(m_current, m_max);
return tmp != m_current;
}
bool Decrement()
{
auto tmp = m_current;
m_current -= m_inc;
m_current = std::max(m_current, m_min);
m_current = std::min(m_current, m_max);
return tmp != m_current;
}
DirectX::XMVECTORF32 SlectionColor()
{
if (IsLowerLimit())
{
return ATG::Colors::Orange;
}
else if (IsUpperLimit())
{
return ATG::Colors::Green;
}
return ATG::Colors::White;
}
bool IsLowerLimit()
{
return m_current == m_min;
}
bool IsUpperLimit()
{
return m_current == m_max;
}
bool IsInt()
{
return m_isInt;
}
void Reset()
{
m_current = m_start;
}
DOUBLE Value()
{
return m_current;
}
private:
DOUBLE m_start;
DOUBLE m_current;
DOUBLE m_min;
DOUBLE m_max;
DOUBLE m_inc;
bool m_isInt;
};
class Menus
{
public:
void Setup(
std::shared_ptr<DX::DeviceResources> pDeviceResources);
void Draw(uint32_t fps, bool halfLine = false);
void OnSizeChanged();
bool ProcessKeys(DirectX::Keyboard::KeyboardStateTracker& keyboard);
// AO.
Option m_aoDistance = Option(10.f, .1f, 10000.f, .1f);
Option m_aoFalloff = Option(0.f, -10.f, 10.f, .1f);
Option m_aoNumSamples = Option(12.f, 1.f, 15.f, 1.f, true);
Option m_aoSampleType = Option(0.f, 0.f, 1.f, 1.f, true);
// SSAO.
Option m_ssaoNoiseFilterTolerance = Option(-3.f, -8.f, .0f, .1f);
Option m_ssaoBlurTolerance = Option(-5.f, -8.f, -1.f, .1f);
Option m_ssaoUpsampleTolerance = Option(-7.f, -12.f, -1.f, .1f);
Option m_ssaoNormalMultiply = Option(1.f, .0f, 5.f, .125f);
// Misc.
unsigned int m_lightingModel = 0;
private:
void CreateDescriptorHeaps();
void DrawMainMenu(bool center);
void DrawCenterLine();
void DrawSplitLabels();
void DrawLabel();
void DrawFrameRate(uint32_t fps);
std::shared_ptr<DX::DeviceResources> m_deviceResources;
// Font resources.
std::unique_ptr<DirectX::SpriteBatch> m_batch;
std::unique_ptr<DirectX::SpriteFont> m_smallFont;
// Primitives.
const unsigned int m_lineThickness = 20;
const unsigned int m_border = 20;
std::unique_ptr<DirectX::PrimitiveBatch<DirectX::VertexPosition>> m_primitiveBatch;
std::unique_ptr<DirectX::BasicEffect> m_basicEffect;
// Heaps.
std::unique_ptr<DirectX::DescriptorHeap> m_csuDescriptors;
// AO.
std::wstring m_aoSampleNames[2] = {
L"Uniform",
L"Cosine"
};
Option* m_optionList[9] = {
&m_aoDistance,
&m_aoFalloff,
&m_aoNumSamples,
&m_aoSampleType,
&m_ssaoNoiseFilterTolerance,
&m_ssaoBlurTolerance,
&m_ssaoUpsampleTolerance,
&m_ssaoNormalMultiply
};
// Logic.
unsigned int selection = 0;
float delta = .0f;
bool m_showFPS = true;
bool m_showHelp = false;
};