Presenting an image
After we are done rendering into a swapchain image or using it for any other purposes, we need to give the image back to the presentation engine. This operation is called a presentation and it displays an image on screen.
Getting ready
In this recipe, we will be using a custom structure defined as follows:
struct PresentInfo { VkSwapchainKHR Swapchain; uint32_t ImageIndex; };
It is used to define a swapchain from which we want to present an image, and an image (its index) that we want to display. For each swapchain, we can present only one image at a time.
How to do it...
- Prepare a handle of a queue that supports presenting. Store it in a variable of type
VkQueue
namedqueue
. - Prepare a variable of type
std::vector<VkSemaphore>
namedrendering_semaphores
. Into this vector, insert semaphores associated with rendering commands that reference images which we want to present. - Create a variable of type
std::vector<VkSwapchainKHR>
namedswapchains
in which...