Working on Window
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,17 +3,17 @@
|
||||
#include <string>
|
||||
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user