This commit is contained in:
2026-02-08 00:32:46 -06:00
parent b97957ec53
commit bad4bd70bc
9 changed files with 42 additions and 445 deletions

View File

@@ -1,3 +1,5 @@
#if WINDOW == 1
#ifndef WINDOW_GLFW
#define WINDOW_GLFW
@@ -11,17 +13,13 @@
namespace Archimedes {
template <class WindowImpl, class RendererImpl>
requires allowed_windows<WindowImpl, RendererImpl>
&& allowed_renderers<RendererImpl>
class Window;
template <class R>
class WindowGLFW {
public:
WindowGLFW(Window<WindowGLFW<R>, R>* p, const std::function<void(Event*)>& sendEvent) {
WindowGLFW(Window* p, const std::function<void(Event*)>& sendEvent) {
/*if(glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) {
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
@@ -57,19 +55,19 @@ namespace Archimedes {
glfwSetWindowUserPointer(w, &data);
glfwSetWindowSizeCallback(w, [](GLFWwindow* window, int w, int h){
WindowData<WindowGLFW<R>, R>& d = *(WindowData<WindowGLFW<R>, R>*) glfwGetWindowUserPointer(window);
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new ResizeWindowEvent(w, h));
});
glfwSetWindowCloseCallback(w, [](GLFWwindow* window){
WindowData<WindowGLFW<R>, R>& d = *(WindowData<WindowGLFW<R>, R>*) glfwGetWindowUserPointer(window);
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new CloseWindowEvent(d.window));
});
glfwSetKeyCallback(w, [](GLFWwindow* window, int key, int scancode, int action, int mods){
WindowData<WindowGLFW<R>, R>& d = *(WindowData<WindowGLFW<R>, R>*) glfwGetWindowUserPointer(window);
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
switch(action) {
case GLFW_PRESS:
@@ -85,7 +83,7 @@ namespace Archimedes {
});
glfwSetMouseButtonCallback(w, [](GLFWwindow* window, int button, int action, int mods){
WindowData<WindowGLFW<R>, R>& d = *(WindowData<WindowGLFW<R>, R>*) glfwGetWindowUserPointer(window);
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
switch(action) {
case GLFW_PRESS:
@@ -98,13 +96,13 @@ namespace Archimedes {
});
glfwSetScrollCallback(w, [](GLFWwindow* window, double dx, double dy){
WindowData<WindowGLFW<R>, R>& d = *(WindowData<WindowGLFW<R>, R>*) glfwGetWindowUserPointer(window);
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new ScrollWindowEvent(dx, dy));
});
glfwSetCursorPosCallback(w, [](GLFWwindow* window, double dx, double dy){
WindowData<WindowGLFW<R>, R>& d = *(WindowData<WindowGLFW<R>, R>*) glfwGetWindowUserPointer(window);
WindowData& d = *(WindowData*) glfwGetWindowUserPointer(window);
d.sendEvent(new MouseMovedWindowEvent(dx, dy));
});
@@ -131,13 +129,17 @@ namespace Archimedes {
GLFWwindow* getWindow() { return w; }
WindowData<WindowGLFW<R>, R> data;
WindowData data;
private:
GLFWwindow* w;
};
typedef WindowGLFW WindowImpl;
}
#endif
#endif