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;
}
void Window::centerWindow() {
int x = (GetMonitorWidth(getMonitorIndex()) / 2) - (getWindowWidth() / 2);
int y = (GetMonitorHeight(getMonitorIndex()) / 2) - (getWindowHeight() / 2);
setPosition(x, y);
}
int Window::getWidth() {
return GetScreenWidth();
}
@@ -87,6 +93,14 @@ namespace DREAM {
return m_resizable;
}
int Window::getWindowWidth() {
return GetScreenWidth();
}
int Window::getWindowHeight() {
return GetScreenHeight();
}
int Window::getMonitorIndex() {
return GetCurrentMonitor();
}

View File

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