Destroying an image view
When we don't need an image view any more, we should destroy it.
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 an image view stored in a variable of type
VkImageView
namedimage_view
. - Call
vkDestroyImageView( logical_device, image_view, nullptr )
and provide the handle of the logical device, the handle of the image view, and anullptr
value. - For safety reasons, assign a
VK_NULL_HANDLE
value to theimage_view
variable.
How it works...
Destroying an image view requires us to use its handle and the handle of the logical device on which the image view was created. It is performed in the following way:
if( VK_NULL_HANDLE != image_view ) { vkDestroyImageView( logical_device, image_view, nullptr ); image_view = VK_NULL_HANDLE; }
First, we check whether the handle is not empty. We don't need to do it--destroying a null handle is silently ignored. But it's good to skip unnecessary function...