-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
101 lines (81 loc) · 2.24 KB
/
Copy pathmain.cpp
File metadata and controls
101 lines (81 loc) · 2.24 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
#include "Window.h"
#include "Renderer.h"
#include "ScreenManager.h"
#include "GameTime.h"
#include "InputKeyboard.h"
#include "InputMouse.h"
#include <GLFW/glfw3.h>
Window gWindow;
ScreenManager gScreenManager;
GameTime gTime;
int main()
{
constexpr int WindowWidth = 640;
constexpr int WindowHeight = 360;
// =========================
// WINDOW
// =========================
if (!gWindow.init(WindowWidth, WindowHeight, "CHESS ENGINE", false))
return -1;
{
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowPos(
gWindow.getNative(),
(mode->width - WindowWidth) / 2,
(mode->height - WindowHeight) / 2
);
}
// =========================
// RENDERER
// =========================
if (!Renderer::init())
{
gWindow.shutdown();
return -1;
}
// =========================
// INPUT
// =========================
InputKeyboard::init(gWindow.getNative());
InputMouse::init(gWindow.getNative());
// =========================
// TIME
// =========================
gTime.init(gWindow.getTime());
// =========================
// SCREENS
// =========================
gScreenManager.init();
gScreenManager.setScreen(ScreenType::Splash);
// =========================
// MAIN LOOP
// =========================
while (!gWindow.shouldClose())
{
// 1. eventos OS
gWindow.pollEvents();
// 2. input update (orden crítico)
InputKeyboard::update();
InputMouse::update();
// 3. timing
gTime.update(gWindow.getTime());
// 4. ESC
if (InputKeyboard::isKeyPressed(GLFW_KEY_ESCAPE))
gWindow.setShouldClose(true);
// 5. render setup
Renderer::setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Renderer::beginFrame();
// 6. update + render
gScreenManager.update(gTime);
gScreenManager.render();
// 7. swap
gWindow.swapBuffers();
}
// =========================
// CLEANUP
// =========================
Renderer::shutdown();
gWindow.shutdown();
return 0;
}