Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Public Member Functions | Private Member Functions | Private Attributes
Fling::Swapchain Class Reference

Represents a swap chain that can be used throughout the program. More...

#include <SwapChain.h>

Public Member Functions

 Swapchain (const VkExtent2D &t_Extent)
 
 ~Swapchain () noexcept
 
VkResult AquireNextImage (const VkSemaphore &t_CompletedSemaphore)
 
VkResult QueuePresent (const VkQueue &t_PresentQueue, const VkSemaphore &t_WaitSemaphore)
 
void Recreate (const VkExtent2D &t_Extent)
 Recreate this swap chain including image views, render passes, and command buffers. More...
 
void Cleanup ()
 Cleanup all swapchain resources. More...
 
const VkSwapchainKHR & GetVkSwapChain () const
 
const VkPresentModeKHR & GetPresentMode () const
 
const VkExtent2D & GetExtents () const
 
const VkFormat & GetImageFormat () const
 
const std::vector< VkImage > & GetImages () const
 
const size_t GetImageCount () const
 
const VkImage & GetActiveImage () const
 
const UINT32 GetActiveImageIndex () const
 
const size_t GetImageViewCount () const
 
const std::vector< VkImageView > & GetImageViews () const
 

Private Member Functions

void CreateResources ()
 Create any swap chain resources (present mode, KGR swap chain) More...
 
void CreateImageViews ()
 Create the image views from the swap chain so that we can actually render them. More...
 
SwapChainSupportDetails QuerySwapChainSupport ()
 Check the swap chain support of a given device. More...
 
VkSurfaceFormatKHR ChooseSwapChainSurfaceFormat (const std::vector< VkSurfaceFormatKHR > &t_AvailableFormats)
 Choose a swap chain format based on the available formats. More...
 
VkPresentModeKHR ChooseSwapChainPresentMode (const std::vector< VkPresentModeKHR > &t_AvialableFormats)
 Choose a present mode for the swap chain based on the given formats. More...
 

Private Attributes

VkSwapchainKHR m_SwapChain = VK_NULL_HANDLE
 
VkPresentModeKHR m_PresentMode
 
VkExtent2D m_Extents
 
VkFormat m_ImageFormat
 
UINT32 m_ActiveImageIndex
 
std::vector< VkImage > m_Images
 The images inside of the swap chain. More...
 
std::vector< VkImageView > m_ImageViews
 

Detailed Description

Represents a swap chain that can be used throughout the program.

Note
You must EXPLICITLY call Cleanup() on the swap chain

Constructor & Destructor Documentation

◆ Swapchain()

Fling::Swapchain::Swapchain ( const VkExtent2D &  t_Extent)
explicit

◆ ~Swapchain()

Fling::Swapchain::~Swapchain ( )
inlinenoexcept

Member Function Documentation

◆ AquireNextImage()

VkResult Fling::Swapchain::AquireNextImage ( const VkSemaphore &  t_CompletedSemaphore)

◆ ChooseSwapChainPresentMode()

VkPresentModeKHR Fling::Swapchain::ChooseSwapChainPresentMode ( const std::vector< VkPresentModeKHR > &  t_AvialableFormats)
private

Choose a present mode for the swap chain based on the given formats.

Prefer VK_PRESENT_MODE_MAILBOX_KHR If none are available, than return VK_PRESENT_MODE_FIFO_KHR or VK_PRESENT_MODE_IMMEDIATE_KHR based on support

Parameters
Vectorof available formats
Returns
Preferred present mode from the available formats

◆ ChooseSwapChainSurfaceFormat()

VkSurfaceFormatKHR Fling::Swapchain::ChooseSwapChainSurfaceFormat ( const std::vector< VkSurfaceFormatKHR > &  t_AvailableFormats)
private

Choose a swap chain format based on the available formats.

Prefer to format that has VK_FORMAT_B8G8R8A8_UNORM and VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, otherwise get the first available.

Parameters
Availableswap chain formats
Returns
Best swap chain surface formate based on the available ones

◆ Cleanup()

void Fling::Swapchain::Cleanup ( )

Cleanup all swapchain resources.

◆ CreateImageViews()

void Fling::Swapchain::CreateImageViews ( )
private

Create the image views from the swap chain so that we can actually render them.

◆ CreateResources()

void Fling::Swapchain::CreateResources ( )
private

Create any swap chain resources (present mode, KGR swap chain)

◆ GetActiveImage()

const VkImage& Fling::Swapchain::GetActiveImage ( ) const
inline

◆ GetActiveImageIndex()

const UINT32 Fling::Swapchain::GetActiveImageIndex ( ) const
inline

◆ GetExtents()

const VkExtent2D& Fling::Swapchain::GetExtents ( ) const
inline

◆ GetImageCount()

const size_t Fling::Swapchain::GetImageCount ( ) const
inline

◆ GetImageFormat()

const VkFormat& Fling::Swapchain::GetImageFormat ( ) const
inline

◆ GetImages()

const std::vector<VkImage>& Fling::Swapchain::GetImages ( ) const
inline

◆ GetImageViewCount()

const size_t Fling::Swapchain::GetImageViewCount ( ) const
inline

◆ GetImageViews()

const std::vector<VkImageView>& Fling::Swapchain::GetImageViews ( ) const
inline

◆ GetPresentMode()

const VkPresentModeKHR& Fling::Swapchain::GetPresentMode ( ) const
inline

◆ GetVkSwapChain()

const VkSwapchainKHR& Fling::Swapchain::GetVkSwapChain ( ) const
inline

◆ QuerySwapChainSupport()

SwapChainSupportDetails Fling::Swapchain::QuerySwapChainSupport ( )
private

Check the swap chain support of a given device.

Parameters
Thedevice to check support on
Returns
Details of the the swap chain support on this device

◆ QueuePresent()

VkResult Fling::Swapchain::QueuePresent ( const VkQueue &  t_PresentQueue,
const VkSemaphore &  t_WaitSemaphore 
)

◆ Recreate()

void Fling::Swapchain::Recreate ( const VkExtent2D &  t_Extent)

Recreate this swap chain including image views, render passes, and command buffers.

DOES NOT Clean up any resources.

Field Documentation

◆ m_ActiveImageIndex

UINT32 Fling::Swapchain::m_ActiveImageIndex
private

◆ m_Extents

VkExtent2D Fling::Swapchain::m_Extents
private

◆ m_ImageFormat

VkFormat Fling::Swapchain::m_ImageFormat
private

◆ m_Images

std::vector<VkImage> Fling::Swapchain::m_Images
private

The images inside of the swap chain.

◆ m_ImageViews

std::vector<VkImageView> Fling::Swapchain::m_ImageViews
private

◆ m_PresentMode

VkPresentModeKHR Fling::Swapchain::m_PresentMode
private

◆ m_SwapChain

VkSwapchainKHR Fling::Swapchain::m_SwapChain = VK_NULL_HANDLE
private

The documentation for this class was generated from the following files: