How it works...

Assume we want to draw a single object. We want the object to appear directly on screen so, before we begin, we must acquire a swapchain image (refer to the Acquiring a swapchain image recipe from Chapter 2, Image Presentation). Next, we start recording the command buffer (refer to the Beginning a command buffer recording operation recipe from Chapter 3, Command Buffers and Synchronization):

if( !BeginCommandBufferRecordingOperation( command_buffer, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr ) ) { 
  return false; 
}

The first thing we need to record is to change the swapchain image's layout to a VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL layout. This operation should be performed implicitly using appropriate render ...

Get Vulkan Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.