From e1b0ea16142beb29d2fbfdf4f02524eb117aee6d Mon Sep 17 00:00:00 2001 From: onelin Date: Thu, 18 Dec 2025 21:52:13 +0100 Subject: Add instance to window_init And make a mess in the meantime:( --- src/platform_glfw.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/platform_glfw.c') diff --git a/src/platform_glfw.c b/src/platform_glfw.c index 33614ff..ea743b5 100644 --- a/src/platform_glfw.c +++ b/src/platform_glfw.c @@ -11,6 +11,7 @@ #include +#include #include static void window_resize_callback(GLFWwindow *restrict window, int width, int height); @@ -20,7 +21,7 @@ static void render_init_opengl(Window *restrict w, const u32 flags); void window_size_glfw(GLFWwindow *restrict w, ivec2 *restrict dst); -Window* window_init_glfw(const char *restrict windowtitle, ivec2 windowsize, const u32 flags) { +Window* window_init_glfw(Instance *restrict instance, const char *restrict windowtitle, ivec2 windowsize, const u32 flags) { Window* ret = NULL; GLFWwindow* window = NULL; @@ -104,7 +105,7 @@ Window* window_init_glfw(const char *restrict windowtitle, ivec2 windowsize, con } // TODO: set this to `ret` once all the garbage is moved to `struct Window` - glfwSetWindowUserPointer(window, (void*)ret); + glfwSetWindowUserPointer(window, (void*)instance); render_init_opengl(ret, flags); @@ -147,7 +148,8 @@ void window_poll_glfw(void) { // Helper function implementations static void window_resize_callback(GLFWwindow* window, int width, int height) { (void)width; (void)height; - Window* w = glfwGetWindowUserPointer(window); + Instance* i = glfwGetWindowUserPointer(window); + Window* w = i->window; glfwSwapBuffers(window); if (w != NULL) { const GladGLContext* gl = w->context; @@ -157,7 +159,8 @@ static void window_resize_callback(GLFWwindow* window, int width, int height) { } static void framebuffer_resize_callback(GLFWwindow* window, int width, int height) { - Window* w = glfwGetWindowUserPointer(window); + Instance* i = glfwGetWindowUserPointer(window); + Window* w = i->window; if (w != NULL) { const GladGLContext* gl = w->context; //TODO: Move the camera to window->renderer @@ -166,7 +169,7 @@ static void framebuffer_resize_callback(GLFWwindow* window, int width, int heigh w->windowsize[0] = width; w->windowsize[1] = height; - window_reset_cameras(w, w->render_targets); + window_reset_cameras(w, i->mem->data, w->render_targets); //r_reset_camera(c); } DEBUG("FRAMEBUFFER RESIZE <%d,%d>\n", width, height); -- cgit v1.3