Repository navigation
Expand file tree
/
Copy pathWindowManager.h
More file actions
95 lines (83 loc) · 2.51 KB
/
Copy pathWindowManager.h
File metadata and controls
95 lines (83 loc) · 2.51 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
#pragma once
#include <iostream>
#include <raylib.h>
class WindowManager {
public:
WindowManager()
{
// Window Initialization
InitWindow(100, 100, "Pong first try");
SetTargetFPS(60);
// Current Display
int currentMonitorIdx {GetCurrentMonitor()};
m_currentMonitorIdx = currentMonitorIdx;
int displayWidth {GetMonitorWidth(currentMonitorIdx)};
m_displayWidth = displayWidth;
int displayHeight {GetMonitorHeight(currentMonitorIdx)};
m_displayHeight = displayHeight;
// GameWindow
int gameWindowWidth {displayWidth - 200};
m_gameWindowWidth = gameWindowWidth;
int gameWindowHeight {displayHeight - 200};
m_gameWindowHeight = gameWindowHeight;
SetWindowSize(gameWindowWidth, gameWindowHeight);
SetWindowPosition(
(displayWidth - gameWindowWidth) / 2,
(displayHeight - gameWindowHeight) / 2
);
};
// Display
int getCurrentMonitorIdx() const
{
return m_currentMonitorIdx;
}
int getDisplayWidth() const
{
return m_displayWidth;
}
int getDisplayHeight() const
{
return m_displayHeight;
}
Vector2 getDisplayCenter() const
{
return {
static_cast<float>(m_displayWidth) / 2.0f,
static_cast<float>(m_displayHeight) / 2.0f
};
};
// GameWindow
int getGameWindowWidth() const
{
return m_gameWindowWidth;
};
int getGameWindowHeight() const
{
return m_gameWindowHeight;
};
Vector2 getGameWindowCenter() const
{
return {
static_cast<float>(m_gameWindowWidth) / 2.0f,
static_cast<float>(m_gameWindowHeight) / 2.0f
};
};
void printWindowDetails()
{
std::cout << "m_currentMonitorIdx " << m_currentMonitorIdx << std::endl;
std::cout << "m_displayWidth " << m_displayWidth << std::endl;
std::cout << "m_displayHeight " << m_displayHeight << std::endl;
std::cout << "m_gameWindowWidth " << m_gameWindowWidth << std::endl;
std::cout << "m_gameWindowHeight " << m_gameWindowHeight << std::endl;
std::cout << "getGameWindowCeterXY(): " << getGameWindowCenter().x
<< '/' << getGameWindowCenter().y << std::endl;
}
private:
// Display
int m_currentMonitorIdx {};
int m_displayWidth {};
int m_displayHeight {};
// GameWindow
int m_gameWindowWidth {};
int m_gameWindowHeight {};
};