Added centerWindow() function.

This commit is contained in:
2026-01-28 22:58:29 +01:00
parent d23619ad9e
commit 091a8dbbcc
2 changed files with 18 additions and 0 deletions

View File

@@ -63,6 +63,12 @@ namespace DREAM {
m_windowY = y; m_windowY = y;
} }
void Window::centerWindow() {
int x = (GetMonitorWidth(getMonitorIndex()) / 2) - (getWindowWidth() / 2);
int y = (GetMonitorHeight(getMonitorIndex()) / 2) - (getWindowHeight() / 2);
setPosition(x, y);
}
int Window::getWidth() { int Window::getWidth() {
return GetScreenWidth(); return GetScreenWidth();
} }
@@ -87,6 +93,14 @@ namespace DREAM {
return m_resizable; return m_resizable;
} }
int Window::getWindowWidth() {
return GetScreenWidth();
}
int Window::getWindowHeight() {
return GetScreenHeight();
}
int Window::getMonitorIndex() { int Window::getMonitorIndex() {
return GetCurrentMonitor(); return GetCurrentMonitor();
} }

View File

@@ -24,6 +24,7 @@ namespace DREAM {
void setTitle(const std::string& title); void setTitle(const std::string& title);
void setPosition(int x, int y); void setPosition(int x, int y);
void centerWindow();
int getWidth(); int getWidth();
int getHeight(); int getHeight();
@@ -33,6 +34,9 @@ namespace DREAM {
bool isVSyncEnabled(); bool isVSyncEnabled();
bool isResizable(); bool isResizable();
int getWindowWidth();
int getWindowHeight();
int getMonitorIndex(); int getMonitorIndex();
int getMonitorRefreshRate(); int getMonitorRefreshRate();
int getMonitorWidth(); int getMonitorWidth();