polymorphic windows

This commit is contained in:
2026-02-08 11:57:18 -06:00
parent bad4bd70bc
commit f277dee1f7
4 changed files with 76 additions and 77 deletions

View File

@@ -4,8 +4,6 @@
#include "WindowEvents.h"
#include "utils/Renderer/Renderer.h"
#include "WindowGLFW/WindowGLFW.h"
#include "WindowSDL3/WindowSDL3.h"
namespace Archimedes {
@@ -13,34 +11,44 @@ namespace Archimedes {
public:
Window(const std::function<void(Event*)>& sendEventFn) : window(this, sendEventFn) {}
Window(const std::function<void(Event*)>& sendEventFn) : eventFn(sendEventFn) {}
~Window() {}
virtual ~Window() = 0;
bool shouldClose() { return window.shouldClose(); }
void getSize(int& w, int& h) {
window.getSize(w, h);
}
void doFrame() {
renderer->render();
window.doFrame();
swapBuffers();
pollEvents();
window.pollEvents();
}
virtual bool shouldClose() = 0;
virtual void swapBuffers() = 0;
virtual void pollEvents() = 0;
virtual void getSize(int& w, int& h) {
w = this->w;
h = this->h;
}
Renderer* getRenderer() { return renderer; }
void setRenderer(Renderer* r) { renderer = r; }
WindowImpl& getWindowImpl() { return window; }
virtual Window* getWindowImpl() = 0;
protected:
int w, h;
private:
Renderer* renderer;
WindowImpl window;
std::function<void(Event*)> eventFn;
};
}