Fixed sample app crashing when window is minimized
diff --git a/src/VulkanSample.cpp b/src/VulkanSample.cpp index d1ed500..3edd48e 100644 --- a/src/VulkanSample.cpp +++ b/src/VulkanSample.cpp
@@ -2420,8 +2420,22 @@ #endif } +static bool IsWindowMinimizedOrZeroSized() +{ + if((g_hWnd == NULL) || IsIconic(g_hWnd)) + return true; + + RECT clientRect = {}; + GetClientRect(g_hWnd, &clientRect); + return clientRect.right <= clientRect.left + || clientRect.bottom <= clientRect.top; +} + static void RecreateSwapChain() { + if(IsWindowMinimizedOrZeroSized()) + return; + vkDeviceWaitIdle(g_hDevice); DestroySwapchain(false); CreateSwapchain(); @@ -2738,10 +2752,10 @@ TranslateMessage(&msg); DispatchMessage(&msg); } + else if(IsWindowMinimizedOrZeroSized()) + Sleep(25); else - { DrawFrame(); - } } return (int)msg.wParam;;