mirror of
https://github.com/opus-tango/IntroductionToVulkan.git
synced 2026-03-20 12:05:20 +00:00
Modified rendering framework to support surface size of 0 width and 0 height (this can occur on Windows when window gets minimized). In such situation, swapchain is not created and rendering function is not called. Instead, rendering loop waits for 1/10 of a second.
This commit is contained in:
@@ -430,6 +430,8 @@ namespace ApiWithoutSecrets {
|
||||
}
|
||||
|
||||
bool Tutorial02::CreateSwapChain() {
|
||||
CanRender = false;
|
||||
|
||||
if( Vulkan.Device != VK_NULL_HANDLE ) {
|
||||
vkDeviceWaitIdle( Vulkan.Device );
|
||||
}
|
||||
@@ -480,6 +482,11 @@ namespace ApiWithoutSecrets {
|
||||
if( static_cast<int>(desired_present_mode) == -1 ) {
|
||||
return false;
|
||||
}
|
||||
if( (desired_extent.width == 0) || (desired_extent.height == 0) ) {
|
||||
// Current surface size is (0, 0) so we can't create a swap chain and render anything (CanRender == false)
|
||||
// But we don't wont to kill the application as this situation may occur i.e. when window gets minimized
|
||||
return true;
|
||||
}
|
||||
|
||||
VkSwapchainCreateInfoKHR swap_chain_create_info = {
|
||||
VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, // VkStructureType sType
|
||||
@@ -510,6 +517,8 @@ namespace ApiWithoutSecrets {
|
||||
vkDestroySwapchainKHR( Vulkan.Device, old_swap_chain, nullptr );
|
||||
}
|
||||
|
||||
CanRender = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user