diff --git a/src/ptk.c b/src/ptk.c index ff4b498..368199f 100644 --- a/src/ptk.c +++ b/src/ptk.c @@ -18,12 +18,6 @@ #include #include -static void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) { - double x, y; - glfwGetCursorPos(window, &x, &y); - vk_handle_mouse_button_input((PtkPos){ .x = x, .y = y }, button, action, mods); -} - PTK_OPTION_DEFINE(PtkLogLevel); PTK_OPTION(PtkLogLevel) get_log_level(void) { @@ -98,11 +92,6 @@ bool ptk_init(const size_t width, const size_t height, const char *title, const return false; } - glfwSetFramebufferSizeCallback(window, vk_framebuffer_resized); - glfwSetMouseButtonCallback(window, mouse_button_callback); - - vk_init_vertices(); - // on tiling desktops (most standalone X11 WMs / Wayland compositors) // the size of the window won't necessarily be what the user set due to tiling // so we do this ugly workaround where we fetch the size again diff --git a/src/ptk_vk/init.c b/src/ptk_vk/init.c index c6d4a8f..9051aad 100644 --- a/src/ptk_vk/init.c +++ b/src/ptk_vk/init.c @@ -174,11 +174,22 @@ bool vk_update_uniform_buffer(const size_t current_frame) { return true; } +static void mouse_button_callback(GLFWwindow *window, int button, int action, int mods) { + double x, y; + glfwGetCursorPos(window, &x, &y); + vk_handle_mouse_button_input((PtkPos){ .x = x, .y = y }, button, action, mods); +} + bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const char *title, const PtkVersion version) { m_window = window; m_uniform_buffer_object.initial_window_size.w = width; m_uniform_buffer_object.initial_window_size.h = height; + vk_init_vertices(); + + glfwSetFramebufferSizeCallback(window, vk_framebuffer_resized); + glfwSetMouseButtonCallback(window, mouse_button_callback); + PTK_OPTION(VkInstance) instance_opt = vk_instance_create(title, version, m_validation_layers); if (!instance_opt.exists) {