SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::ISwapChain Class Referenceabstract

Interface for a swap chain, a chain of multiple IImage instances that can be presented using a ISurface. More...

#include <SwapChain.h>

Inheritance diagram for spark::render::ISwapChain:
spark::render::SwapChain< IVulkanImage, VulkanFrameBuffer > spark::render::SwapChain< ImageType, FrameBufferType > spark::render::vk::VulkanSwapChain

Public Member Functions

virtual Format surfaceFormat () const noexcept=0
 Gets the swap chain's surface format.
 
virtual unsigned int buffers () const noexcept=0
 Gets the number of images in the swap chain.
 
virtual math::Vector2< unsigned int > renderArea () const noexcept=0
 Gets the swap chain's render area.
 
virtual const IImageimage (unsigned int back_buffer) const =0
 Gets the swap chain's current image for the given back buffer.
 
std::vector< const IImage * > images () const noexcept
 Gets all the swap chain's images.
 
void present (const IFrameBuffer &frame_buffer) const noexcept
 Queues a present that gets executed after frame_buffer signals that it's done rendering.
 
virtual std::vector< Format > surfaceFormats () const noexcept=0
 Gets all the swap chain's supported surface formats.
 
virtual void reset (Format surface_format, math::Vector2< unsigned int > render_area, unsigned int buffers) noexcept=0
 Recreates the swap chain with the given parameters. All frame buffers that use this swap chain will be invalidated and recreated.
 
virtual unsigned int swapBackBuffer () const noexcept=0
 Swaps the front buffer with the next back buffer in order.
 

Detailed Description

Interface for a swap chain, a chain of multiple IImage instances that can be presented using a ISurface.

Member Function Documentation

◆ buffers()

virtual unsigned int spark::render::ISwapChain::buffers ( ) const
nodiscardpure virtualnoexcept

Gets the number of images in the swap chain.

Returns
The number of images in the swap chain.

Implemented in spark::render::vk::VulkanSwapChain.

◆ image()

virtual const IImage * spark::render::ISwapChain::image ( unsigned int back_buffer) const
nodiscardpure virtual

Gets the swap chain's current image for the given back buffer.

Parameters
back_bufferIndex of the back buffer to get the image for.
Returns
A IImage pointer to the swap chain's current image for the given back buffer.
Exceptions
base::ArgumentOutOfRangeExceptionIf back_buffer is out of range.

◆ images()

std::vector< const IImage * > spark::render::ISwapChain::images ( ) const
inlinenodiscardnoexcept

Gets all the swap chain's images.

Returns
A std::vector containing pointers to all the swap chain's images.

◆ present()

void spark::render::ISwapChain::present ( const IFrameBuffer & frame_buffer) const
inlinenoexcept

Queues a present that gets executed after frame_buffer signals that it's done rendering.

Parameters
frame_bufferThe frame buffer for which the present should wait.

◆ renderArea()

virtual math::Vector2< unsigned int > spark::render::ISwapChain::renderArea ( ) const
nodiscardpure virtualnoexcept

Gets the swap chain's render area.

Returns
A math::Vector2<unsigned int> describing the swap chain's render area.

Implemented in spark::render::vk::VulkanSwapChain.

◆ reset()

virtual void spark::render::ISwapChain::reset ( Format surface_format,
math::Vector2< unsigned int > render_area,
unsigned int buffers )
pure virtualnoexcept

Recreates the swap chain with the given parameters. All frame buffers that use this swap chain will be invalidated and recreated.

There is no guarantee that:

  • the swap chain images will end up in the exact format, as specified by surface_format. If the format itself is not supported, a compatible format may be looked up. If the lookup fails, the method may raise an exception.
  • that the number of images returned by ISwapChain::images() matches the number specified in buffers. A swap chain may require a minimum number of images or may constraint a maximum number of images. In both cases, buffers will be clamped.
Parameters
surface_formatA Format describing the swap chain's surface format.
render_areaA math::Vector2<unsigned int> describing the swap chain's frame buffers size.
buffersThe number of buffers in the swap chain.

◆ surfaceFormat()

virtual Format spark::render::ISwapChain::surfaceFormat ( ) const
nodiscardpure virtualnoexcept

Gets the swap chain's surface format.

Returns
A Format describing the swap chain's surface format.

Implemented in spark::render::vk::VulkanSwapChain.

◆ surfaceFormats()

virtual std::vector< Format > spark::render::ISwapChain::surfaceFormats ( ) const
nodiscardpure virtualnoexcept

Gets all the swap chain's supported surface formats.

Returns
A std::vector containing all the swap chain's supported surface formats.

Implemented in spark::render::vk::VulkanSwapChain.

◆ swapBackBuffer()

virtual unsigned int spark::render::ISwapChain::swapBackBuffer ( ) const
nodiscardpure virtualnoexcept

Swaps the front buffer with the next back buffer in order.

Returns
The new front buffer after the swap.

Implemented in spark::render::vk::VulkanSwapChain.