diff --git a/src/ptk.c b/src/ptk.c index f924e02..ccfef7d 100644 --- a/src/ptk.c +++ b/src/ptk.c @@ -107,16 +107,16 @@ bool ptk_init(const size_t width, const size_t height, const char *title, const glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - g_window = glfwCreateWindow(width, height, title, NULL, NULL); + GLFWwindow *window = glfwCreateWindow(width, height, title, NULL, NULL); - if (g_window == NULL) { + if (window == NULL) { PTK_ERR("failed creating GLFW window"); return false; } - glfwSetFramebufferSizeCallback(g_window, vk_framebuffer_resized); - glfwSetKeyCallback(g_window, key_callback); - glfwSetMouseButtonCallback(g_window, mouse_button_callback); + glfwSetFramebufferSizeCallback(window, vk_framebuffer_resized); + glfwSetKeyCallback(window, key_callback); + glfwSetMouseButtonCallback(window, mouse_button_callback); vk_init_vertices(); @@ -128,9 +128,9 @@ bool ptk_init(const size_t width, const size_t height, const char *title, const // this fixes an issue where components would get drawn squished // and their hitboxes wouldn't match up with them visually int actual_width = 0, actual_height = 0; - glfwGetFramebufferSize(g_window, &actual_width, &actual_height); + glfwGetFramebufferSize(window, &actual_width, &actual_height); - if (!vk_init(g_window, actual_width, actual_height, title, application_version)) { + if (!vk_init(window, actual_width, actual_height, title, application_version)) { PTK_ERR("failed initializing vulkan"); return false; } @@ -190,7 +190,7 @@ PtkHandle ptk_clickable(PtkHandle hitbox, const MouseButtonCallback on_press) { int ptk_run(PtkHandle root) { vk_init_components(root); - while (!glfwWindowShouldClose(g_window)) { + while (!vk_is_done()) { glfwPollEvents(); if (!vk_draw_frame()) { break; diff --git a/src/ptk_vk/init.c b/src/ptk_vk/init.c index 482fc1f..b178a9d 100644 --- a/src/ptk_vk/init.c +++ b/src/ptk_vk/init.c @@ -342,6 +342,10 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const return true; } +bool vk_is_done(void) { + return glfwWindowShouldClose(g_window); +} + void vk_cleanup(void) { vk_cleanup_swapchain(g_dev); diff --git a/src/ptk_vk/init.h b/src/ptk_vk/init.h index 6c9d015..3aa2001 100644 --- a/src/ptk_vk/init.h +++ b/src/ptk_vk/init.h @@ -34,6 +34,8 @@ extern VkRenderPass g_render_pass; bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const char *title, const PtkVersion version); +bool vk_is_done(void); + bool vk_transfer_vertex_data(void); bool vk_record_command_buffer(const VkCommandBuffer command_buffer, const uint32_t image_index);