From 0e6fcc95468449af9e5028028ac3221ee3cd48c6 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sun, 16 Mar 2025 23:17:00 -0500 Subject: [PATCH] test window module --- .../Window/src/WindowImpl/GLFW/windowGLFW.cpp | 19 ++++++++++++++++--- .../Window/src/WindowImpl/GLFW/windowGLFW.h | 4 +++- modules/Window/src/WindowModule.cpp | 5 +++++ modules/Window/src/WindowModule.h | 4 ++-- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/Window/src/WindowImpl/GLFW/windowGLFW.cpp b/modules/Window/src/WindowImpl/GLFW/windowGLFW.cpp index 78de6d2..5efc823 100644 --- a/modules/Window/src/WindowImpl/GLFW/windowGLFW.cpp +++ b/modules/Window/src/WindowImpl/GLFW/windowGLFW.cpp @@ -8,12 +8,25 @@ Window::Window() { std::abort(); } w = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL); + + if(!w) { + glfwTerminate(); + std::abort(); + } + + glfwMakeContextCurrent(w); } -bool Window::close() { +bool Window::shouldClose() { return glfwShouldClose(w); } -Window::~Window() { - +void Window::doFrame() { + glClear(GL_COLOR_BUFFER_BIT); + glfwSwapBuffers(w); + glfwPollEvents(); +} + +Window::~Window() { + glfwTerminate(); } diff --git a/modules/Window/src/WindowImpl/GLFW/windowGLFW.h b/modules/Window/src/WindowImpl/GLFW/windowGLFW.h index 60fccef..a3991d8 100644 --- a/modules/Window/src/WindowImpl/GLFW/windowGLFW.h +++ b/modules/Window/src/WindowImpl/GLFW/windowGLFW.h @@ -9,7 +9,9 @@ class Window { Window(); ~Window(); - bool close(); + bool shouldClose(); + + void doFrame(); private: GLFWwindow* w; diff --git a/modules/Window/src/WindowModule.cpp b/modules/Window/src/WindowModule.cpp index 8fa9dff..242b00b 100644 --- a/modules/Window/src/WindowModule.cpp +++ b/modules/Window/src/WindowModule.cpp @@ -8,4 +8,9 @@ WindowModule::~WindowModule() {} void WindowModule::run() { + if(window.shouldClose()) { + app.stopModule(self); + } + + window.doFrame(); } diff --git a/modules/Window/src/WindowModule.h b/modules/Window/src/WindowModule.h index 3fb2b41..f2a81c4 100644 --- a/modules/Window/src/WindowModule.h +++ b/modules/Window/src/WindowModule.h @@ -1,5 +1,5 @@ #include "Archimedes.h" -#include "WindowImpl/WindowImpl.h" +#include "WindowImpl/GLFW/windowGLFW.h" #include "Renderer/Renderer.h" class WindowModule : public Module { @@ -13,7 +13,7 @@ class WindowModule : public Module { private: - WindowImpl window; + Window window; Renderer renderer; };