vpr::Swapchain class

This class abstracts away much of the detailed work and boilerplate code required to setup a swapchain in Vulkan.

Swapchain recreation can be done by calling the suitable method, or by using the static method as well.

Constructors, destructors, conversion operators

Swapchain(const Device* _device, void* platform_window, VkSurfaceKHR surface, vertical_sync_mode sync_mode)
Creates a new swapchain on the specified device.

Public functions

void Recreate(VkSurfaceKHR surface)
Required as part of a swapchain recreation event - must take a parameter to the new surface to use for the updated swapchain.
auto Extent() const -> const VkExtent2D& noexcept
Returns current extent of the swapchain.
auto ImageCount() const -> const uint32_t& noexcept
Number of images this swapchain has created and expects to use during the rendering process.
auto Image(const size_t& idx) const -> const VkImage&
Returns handles to the implementation-created and managed backing images used for presentation.
auto ImageView(const size_t& idx) const -> const VkImageView&
Returns handles to the implementation-created and managed backing image views used for presentation.

Function documentation

vpr::Swapchain::Swapchain(const Device* _device, void* platform_window, VkSurfaceKHR surface, vertical_sync_mode sync_mode)

Creates a new swapchain on the specified device.

Parameters
_device
platform_window Is either a GLFWwindow pointer, or an ANativeWindow pointer
surface Surface this swapchain will be presenting images to
sync_mode One of the potential vertical_sync_mode enum values specified what presentation mode to use. Defaults to mailbox.

const VkExtent2D& vpr::Swapchain::Extent() const noexcept

Returns current extent of the swapchain.

Set based on platform window values - which are generally set before this object is created, or is set based on limits for the platform to satisfy initialization requirements.