Destroying a swapchain
When we are done using a swapchain, because we don't want to present images any more, or because we are just closing our application, we should destroy it. We need to destroy it before we destroy a presentation surface which was used during a given swapchain creation.
How to do it...
- Take the handle of a logical device and store it in a variable of type
VkDevice
namedlogical_device
. - Take the handle of a swapchain object that needs to be destroyed. Store it in a variable of type
VkSwapchainKHR
namedswapchain
. - Call
vkDestroySwapchainKHR( logical_device, swapchain, nullptr )
and provide thelogical_device
variable as the first argument and the swapchain handle as the second argument. Set the last parameter tonullptr
. - For safety reasons, assign a
VK_NULL_HANDLE
value to theswapchain
variable.
How it works...
To destroy a swapchain, we can prepare code that is similar to the following example:
if( swapchain ) { vkDestroySwapchainKHR( logical_device, swapchain, nullptr )...