folders
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#if WINDOW == 2
|
||||
|
||||
#ifndef WINDOW_SDL3
|
||||
#define WINDOW_SDL3
|
||||
|
||||
@@ -15,15 +17,11 @@
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
template <class WindowImpl, class RendererImpl>
|
||||
requires allowed_windows<WindowImpl, RendererImpl>
|
||||
&& allowed_renderers<RendererImpl>
|
||||
class Window;
|
||||
|
||||
template <class W, class R>
|
||||
static bool EventCallback(void* ptr, SDL_Event* e) {
|
||||
|
||||
WindowData<W, R>& data = *(WindowData<W, R>*) ptr;
|
||||
WindowData& data = *(WindowData*) ptr;
|
||||
|
||||
switch(e->type) {
|
||||
|
||||
@@ -68,12 +66,11 @@ namespace Archimedes {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class R>
|
||||
class WindowSDL3 {
|
||||
|
||||
public:
|
||||
|
||||
WindowSDL3(Window<WindowSDL3<R>, R>* p, const std::function<void(Event*)>& sendEvent) {
|
||||
WindowSDL3(Window* p, const std::function<void(Event*)>& sendEvent) {
|
||||
|
||||
data.window = p;
|
||||
data.sendEvent = sendEvent;
|
||||
@@ -157,7 +154,7 @@ namespace Archimedes {
|
||||
#if RENDERER == 1
|
||||
SDL_GLContext getContext() { return gl_context; }
|
||||
#endif
|
||||
WindowData<WindowSDL3<R>, R> data;
|
||||
WindowData data;
|
||||
|
||||
private:
|
||||
SDL_Window* w;
|
||||
@@ -168,6 +165,9 @@ namespace Archimedes {
|
||||
|
||||
};
|
||||
|
||||
typedef WindowSDL3 WindowImpl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user