Destroying a framebuffer
When a framebuffer is no longer used by the pending commands and we don't need it anymore, we can destroy it.
How to do it...
- Initialize a variable of type
VkDevice
namedlogical_device
with the handle of a logical device on which the framebuffer was created. - Take the framebuffer's handle and store it in a variable of type
VkFramebuffer
namedframebuffer
. - Make the following call:
vkDestroyFramebuffer( logical_device, framebuffer, nullptr )
, for which we provide thelogical_device
andframebuffer
variables and anullptr
value. - For safety reasons, store a
VK_NULL_HANDLE
value in theframebuffer
variable.
How it works...
The framebuffer is destroyed with the vkDestroyFramebuffer()
function call. However, before we can destroy it, we must make sure that commands referencing the given framebuffer are no longer executed on the hardware.
The following code destroys a framebuffer:
if( VK_NULL_HANDLE != framebuffer ) { vkDestroyFramebuffer( logical_device, framebuffer, nullptr...