summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-08-07 19:45:51 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-08-07 19:45:51 -0400
commit023eff9304e7b4fd139811e2cd4120d7d9707f5a (patch)
tree11711c8a5da3d0c06a6704ca9f4e0469a68704cf /src
parent80b984cc672fda24d9cefc378cac68153473e21b (diff)
framebuffer resize callback
Diffstat (limited to 'src')
-rw-r--r--src/window.cpp9
1 files changed, 9 insertions, 0 deletions
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<VkImageView *>(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();
}