polymorphic windows
This commit is contained in:
@@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user