test window module

This commit is contained in:
2025-03-16 23:17:00 -05:00
parent 453e9f2aee
commit 0e6fcc9546
4 changed files with 26 additions and 6 deletions

View File

@@ -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();
}

View File

@@ -9,7 +9,9 @@ class Window {
Window();
~Window();
bool close();
bool shouldClose();
void doFrame();
private:
GLFWwindow* w;

View File

@@ -8,4 +8,9 @@ WindowModule::~WindowModule() {}
void WindowModule::run() {
if(window.shouldClose()) {
app.stopModule(self);
}
window.doFrame();
}

View File

@@ -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;
};