From 2d02041ef531b121fbc34b49eb388a1ae34fe444 Mon Sep 17 00:00:00 2001 From: heaven Date: Wed, 28 Jan 2026 22:28:17 +0100 Subject: [PATCH] Working on Window --- CMakeLists.txt | 1 + src/Engine/Window/Window.cpp | 100 +++++++++++++++++++++++++++++++++++ src/Engine/Window/Window.hpp | 18 +++---- 3 files changed, 110 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cab59ce..e4cd04a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,7 @@ project(DREAM2026 set(DREAM2026_SOURCES cmake.toml "src/Engine/Engine.cpp" + "src/Engine/Window/Window.cpp" "src/Game/src/Game.cpp" "src/main.cpp" ) diff --git a/src/Engine/Window/Window.cpp b/src/Engine/Window/Window.cpp index 4eebb3a..6555cbc 100644 --- a/src/Engine/Window/Window.cpp +++ b/src/Engine/Window/Window.cpp @@ -1,3 +1,103 @@ +#include "Window.hpp" +#include "raylib.h" + namespace DREAM { // 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()); + } } diff --git a/src/Engine/Window/Window.hpp b/src/Engine/Window/Window.hpp index 6b3ef78..18d07e0 100644 --- a/src/Engine/Window/Window.hpp +++ b/src/Engine/Window/Window.hpp @@ -3,17 +3,17 @@ #include namespace DREAM { - struct WindowConfig { - int m_width { 1280 }; - int m_height { 720 }; + // struct WindowConfig { + // int m_width { 1280 }; + // int m_height { 720 }; - bool m_Fullscreen { false }; - bool m_vsync { false }; - bool m_resizable { false } ; - }; + // bool m_Fullscreen { false }; + // bool m_vsync { false }; + // bool m_resizable { false } ; + // }; namespace Window { - void init(WindowConfig& config); + // void init(WindowConfig& config); void setWidth(int width); void setHeight(int height); @@ -27,7 +27,7 @@ namespace DREAM { int getWidth(); int getHeight(); - float getAspectRatio(); + // float getAspectRatio(); bool isFullscreen(); bool isVSyncEnabled();