From 023eff9304e7b4fd139811e2cd4120d7d9707f5a Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 7 Aug 2023 19:45:51 -0400 Subject: framebuffer resize callback --- src/window.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/window.cpp') diff --git a/src/window.cpp b/src/window.cpp index 8aaed26..2ab34c6 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -447,12 +447,21 @@ void DestroySwapchain() { swapchainImageViews = reinterpret_cast(0xCAFEBABE); } +void FramebufferResizeCallback(GLFWwindow *window, int width, int height) { + if (extent.width == width && extent.height != height) { + return; + } + DestroySwapchain(); + CreateSwapchain(); +} + void CreateWindow(PKEWindowProperties *wp) { if (vkInstance != nullptr) return; glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); window = glfwCreateWindow(wp->width, wp->height, "Pikul", nullptr, nullptr); InitVulkan(); + glfwSetFramebufferSizeCallback(window, FramebufferResizeCallback); CreateSwapchain(); } -- cgit v1.2.3