-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathAppClass.h
313 lines (266 loc) · 6.76 KB
/
AppClass.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/*----------------------------------------------
Programmer: Alberto Bobadilla (labigm@rit.edu)
Date: 2021/02
Update: 2021/02
----------------------------------------------*/
#ifndef __APPLICATIONCLASS_H_
#define __APPLICATIONCLASS_H_
#include "BTX\BTX.h"
#include "SFML\Window.hpp"
#include "SFML\Graphics.hpp"
#include "SFML\OpenGL.hpp"
#include "imgui\ImGuiObject.h"
using namespace BTX;
#include "MyMesh.h"
#include "MyCamera.h"
class Application
{
MyMesh* m_pMesh1 = nullptr; //Primitive to display
MyMesh* m_pMesh2 = nullptr; //Primitive to display
MyMesh* m_pMesh3 = nullptr; //Primitive to display
uint m_uProjection = 1; //The projection used for each mesh
MyCamera* m_pCamera = nullptr; //camera we will use in this application
private:
String m_sProgrammer = "Alberto Bobadilla - labigm@rit.edu";
static ImGuiObject gui; //GUI object
uint m_uRenderCallCount = 0; //count of render calls per frame
vector3 m_v3Mouse = vector3(); //position of the mouse in the window
bool m_bFPC = false;// First Person Camera flag
bool m_bArcBall = false;// Arcball flag
quaternion m_qArcBall; //ArcBall quaternion
vector4 m_v4ClearColor; //Color of the scene
bool m_bRunning = false; //Is app running?
sf::Window* m_pWindow = nullptr; //SFML window
BTX::SystemSingleton* m_pSystem = nullptr; //Singleton of the system
BTX::ModelManager* m_pModelMngr = nullptr; //Mesh Manager
BTX::CameraManager* m_pCameraMngr = nullptr; //Singleton for the camera manager
BTX::EntityManager* m_pEntityMngr = nullptr; //Singleton for the Entities
bool m_bFocused = true; //is the window focused?
float m_fMovementSpeed = 0.1f; //how fast the camera will move
bool m_bModifier = false; //is shift pressed?
public:
#pragma region Constructor / Run / Destructor
/*
USAGE: Constructor
ARGUMENTS: ---
OUTPUT: ---
*/
Application();
/*
USAGE: Initializes the window and rendering context
ARGUMENTS:
- String a_sApplicationName -> Name of the window if blank will use project Name
- int size -> formated size, relate to BTX_RESOLUTIONS
- bool a_bFullscreen = false -> is the window fullscreen?
- bool a_bBorderless = false -> is the window borderless?
OUTPUT: ---
*/
void Init(String a_sApplicationName = "", int a_uSize = eBTX_RESOLUTIONS::RES_C_1280x720_16x9_HD,
bool a_bFullscreen = false, bool a_bBorderless = false);
/*
USAGE: Initializes the window and rendering context
ARGUMENTS:
- String a_sApplicationName = "" -> Name of the window if blank will use project Name
- uint a_nWidth -> Window Width
- uint a_nHeight -> Window Height
- bool a_bFullscreen -> is the window fullscreen?
- bool a_bBorderless -> is the window borderless?
OUTPUT: ---
*/
void Init(String a_sApplicationName, uint a_uWidth, uint a_uHeight, bool a_bFullscreen, bool a_bBorderless);
/*
USAGE: Runs the main loop of this class DO NOT OVERRIDE
ARGUMENTS: ---
OUTPUT: ---
*/
void Run(void);
/*
USAGE: Destructor
ARGUMENTS: ---
OUTPUT: ---
*/
~Application(void);
#pragma endregion
private:
#pragma region Initialization / Release
/*
USAGE: Initialize the window
ARGUMENTS: String a_sWindowName = "GLFW" -> Window name
OUTPUT: ---
*/
void InitWindow(String a_sWindowName = "Application");
/*
USAGE: Initializes user specific variables, this is executed right after InitWindow,
the purpose of this member function is to initialize member variables specific for this project.
ARGUMENTS: ---
OUTPUT: ---
*/
void InitVariables(void);
/*
USAGE: Reads the configuration of the application to a file
ARGUMENTS: ---
OUTPUT: ---
*/
void ReadConfig(void);
/*
USAGE: Writes the configuration of the application to a file
ARGUMENTS: ---
OUTPUT: ---
*/
void WriteConfig(void);
/*
USAGE: Releases the application
ARGUMENTS: ---
OUTPUT: ---
*/
void Release(void);
#pragma endregion
#pragma region Main Loop
/*
USAGE: Updates the scene
ARGUMENTS: ---
OUTPUT: ---
*/
void Update(void);
/*
USAGE: Displays the scene
ARGUMENTS: ---
OUTPUT: ---
*/
void Display(void);
/*
USAGE: Clears the OpenGL screen by the specified color
ARGUMENTS: vector4 a_v4ClearColor = vector4(-1.0f) -> Color to clear the screen with
OUTPUT: ---
*/
void ClearScreen(vector4 a_v4ClearColor = vector4(-1.0f));
#pragma endregion
#pragma region Application Controls
/*
USAGE: Manage constant keyboard state
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessKeyboard(void);
/*
USAGE: Manage constant keyboard state
ARGUMENTS: ---
OUTPUT: ---
*/
void ArcBall(float a_fSensitivity = 0.1f);
/*
USAGE: Manages the rotation of the camera a_fSpeed is a factor of change
ARGUMENTS: float a_fSpeed = 0.005f
OUTPUT: ---
*/
void CameraRotation(float a_fSpeed = 0.005f);
#pragma endregion
#pragma region Process Events
/*
USAGE: Resizes the window
ARGUMENTS: ---
OUTPUT: ---
*/
void Reshape(void);
/*
USAGE: Manage the response of key presses
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessKeyPressed(sf::Event a_event);
/*
USAGE: Manage the response of key releases
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessKeyReleased(sf::Event a_event);
/*
USAGE: Manage the response of mouse movement
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessMouseMovement(sf::Event a_event);
/*
USAGE: Manage the response of mouse key presses
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessMousePressed(sf::Event a_event);
/*
USAGE: Manage the response of mouse key release
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessMouseReleased(sf::Event a_event);
/*
USAGE: Manage the response of mouse scrolling
ARGUMENTS: ---
OUTPUT: ---
*/
void ProcessMouseScroll(sf::Event a_event);
#pragma endregion
#pragma region GUI
/*
USAGE: Initialize gui
ARGUMENTS: ---
OUTPUT: ---
*/
void InitIMGUI(void);
/*
USAGE: Draw gui elements
ARGUMENTS: ---
OUTPUT: ---
*/
void DrawGUI(void);
/*
USAGE: //release gui
ARGUMENTS: ---
OUTPUT: ---
*/
void ShutdownGUI(void);
/*
USAGE: Render gui lists
ARGUMENTS: ---
OUTPUT: ---
*/
static void RenderDrawLists(ImDrawData* draw_data);
/*
USAGE: Creates fonts for gui
ARGUMENTS: ---
OUTPUT: ---
*/
bool CreateFontsTexture(void);
/*
USAGE: Create OpenGL resources for gui
ARGUMENTS: ---
OUTPUT: ---
*/
bool CreateDeviceObjects(void);
/*
USAGE: creates a new frame for gui
ARGUMENTS: ---
OUTPUT: ---
*/
void NewFrame(void);
#pragma endregion
#pragma region The Rule of Three
/*
USAGE: copy constructor, private so it does not let object copy
ARGUMENTS: GLFWApp const& input -> object to copy (well in this case not)
OUTPUT: ---
*/
Application(Application const& input);
/*
USAGE: copy assignment, private so it does not let object copy
ARGUMENTS: GLFWApp const& input -> object to copy (well in this case not)
OUTPUT: ---
*/
Application& operator=(Application const& input);
#pragma endregion
};
#endif //__APPLICATIONCLASS_H_
/*
USAGE:
ARGUMENTS: ---
OUTPUT: ---
*/