Setting viewport states dynamically
The graphics pipeline defines parameters of lots of different states used during rendering. Creating separate pipeline objects every time we need to use slightly different values of some of these parameters would be cumbersome and very impractical. That's why dynamic states are available in Vulkan. We can define a viewport transformation to be one of them. In such a situation, we specify its parameters through a function call recorded in command buffers.
How to do it...
- Take the handle of a command buffer that is in a recording state. Using its handle, initialize a variable of type
VkCommandBuffer
namedcommand_buffer
.
- Specify the number of the first viewport whose parameters should be set. Store the number in a variable of type
uint32_t
namedfirst_viewport
. - Create a variable of type
std::vector<VkViewport>
namedviewports
. For each viewport that was defined during the pipeline creation, add a new element to theviewports
vector. Through it, specify...