Working on Window

This commit is contained in:
2026-01-28 22:28:17 +01:00
parent b072bba651
commit 2d02041ef5
3 changed files with 110 additions and 9 deletions

View File

@@ -38,6 +38,7 @@ project(DREAM2026
set(DREAM2026_SOURCES set(DREAM2026_SOURCES
cmake.toml cmake.toml
"src/Engine/Engine.cpp" "src/Engine/Engine.cpp"
"src/Engine/Window/Window.cpp"
"src/Game/src/Game.cpp" "src/Game/src/Game.cpp"
"src/main.cpp" "src/main.cpp"
) )

View File

@@ -1,3 +1,103 @@
#include "Window.hpp"
#include "raylib.h"
namespace DREAM { namespace DREAM {
// TODO: Implement Window functions // TODO: Implement Window functions
// TODO: Replace anonymous namespace with struct when config
// exists.
namespace {
int m_width = 1280;
int m_height = 720;
int m_windowX;
int m_windowY;
std::string m_title;
bool m_fullscreen = false;
bool m_vsync = false;
bool m_resizable = false;
}
// void Window::init(WindowConfig &config) {
// }
void Window::setWidth(int width) {
SetWindowSize(width, m_height);
m_width = width;
}
void Window::setHeight(int height) {
SetWindowSize(m_height, height);
m_height = height;
}
void Window::setSize(int width, int height) {
SetWindowSize(width, height);
m_width = width;
m_height = height;
}
// void Window::setFullscreen(bool enabled) {
// if (enabled) {
// IsWindowFullscreen();
// }
// }
void Window::toggleFullscreen() {
ToggleFullscreen();
}
void Window::setTitle(const std::string &title) {
SetWindowTitle(title.c_str());
m_title = title;
}
void Window::setPosition(int x, int y) {
SetWindowPosition(x, y);
m_windowX = x;
m_windowY = y;
}
int Window::getWidth() {
return GetScreenWidth();
}
int Window::getHeight() {
return GetScreenHeight();
}
// float Window::getAspectRatio() {
// return GetScreen
// }
bool Window::isFullscreen() {
return IsWindowFullscreen();
}
bool Window::isVSyncEnabled() {
return m_vsync;
}
bool Window::isResizable() {
return m_resizable;
}
int Window::getMonitorIndex() {
return GetCurrentMonitor();
}
int Window::getMonitorRefreshRate() {
return GetMonitorRefreshRate(getMonitorIndex());
}
int Window::getMonitorWidth() {
return GetMonitorWidth(getMonitorIndex());
}
int Window::getMonitorHeight() {
return GetMonitorHeight(getMonitorIndex());
}
} }

View File

@@ -3,17 +3,17 @@
#include <string> #include <string>
namespace DREAM { namespace DREAM {
struct WindowConfig { // struct WindowConfig {
int m_width { 1280 }; // int m_width { 1280 };
int m_height { 720 }; // int m_height { 720 };
bool m_Fullscreen { false }; // bool m_Fullscreen { false };
bool m_vsync { false }; // bool m_vsync { false };
bool m_resizable { false } ; // bool m_resizable { false } ;
}; // };
namespace Window { namespace Window {
void init(WindowConfig& config); // void init(WindowConfig& config);
void setWidth(int width); void setWidth(int width);
void setHeight(int height); void setHeight(int height);
@@ -27,7 +27,7 @@ namespace DREAM {
int getWidth(); int getWidth();
int getHeight(); int getHeight();
float getAspectRatio(); // float getAspectRatio();
bool isFullscreen(); bool isFullscreen();
bool isVSyncEnabled(); bool isVSyncEnabled();