From fa26784e01addad667d11827e61b2d23c6bdcfac Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Thu, 14 Mar 2024 13:19:28 +0900 Subject: [PATCH] Handle window minimization Implemented as mentioned in the "Swap chain recreation" page in the tutorial. --- src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.rs b/src/main.rs index ee05a66..1da8aa5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1529,6 +1529,19 @@ impl VulkanApp { } fn recreate_swap_chain(&mut self) -> Result<(), String> { + let mut width: i32 = 0; + let mut height: i32 = 0; + while width == 0 || height == 0 { + unsafe { + ffi::glfwGetFramebufferSize( + self.window, + std::ptr::addr_of_mut!(width), + std::ptr::addr_of_mut!(height), + ); + ffi::glfwWaitEvents(); + } + } + unsafe { ffi::vkDeviceWaitIdle(self.device); }