MAGE  v0.171.0
Matthias Advanced Game Engine
mage::rendering::SwapChain Class Reference

#include <swap_chain.hpp>

Classes

class  Impl
 

Public Member Functions

 SwapChain (ID3D11Device &device, ID3D11DeviceContext &device_context, NotNull< HWND > window, DisplayConfiguration &display_configuration)
 
 SwapChain (const SwapChain &swap_chain)=delete
 
 SwapChain (SwapChain &&swap_chain) noexcept
 
 ~SwapChain ()
 
SwapChainoperator= (const SwapChain &swap_chain)=delete
 
SwapChainoperator= (SwapChain &&swap_chain)=delete
 
NotNull< HWND > GetWindow () noexcept
 
bool IsWindowed () const noexcept
 
bool IsFullScreen () const noexcept
 
bool LostMode () const noexcept
 
void SetInitialMode ()
 
void SwitchMode (bool toggle)
 
ID3D11RenderTargetView & GetRTV () const noexcept
 
void Clear () const noexcept
 
void Present () const noexcept
 
void TakeScreenShot (const std::wstring &fname) const
 

Private Attributes

UniquePtr< Implm_impl
 

Detailed Description

A class of swap chains.

Constructor & Destructor Documentation

◆ SwapChain() [1/3]

mage::rendering::SwapChain::SwapChain ( ID3D11Device &  device,
ID3D11DeviceContext &  device_context,
NotNull< HWND >  window,
DisplayConfiguration display_configuration 
)
explicit

Constructs a swap chain.

Parameters
[in,out]deviceA reference to the device.
[in,out]device_contextA reference to the device context.
[in]windowThe main window handle.
[in,out]display_configurationA reference to the display configuration.

◆ SwapChain() [2/3]

mage::rendering::SwapChain::SwapChain ( const SwapChain swap_chain)
delete

Constructs a swap chain from the given swap chain.

Parameters
[in]swap_chainA reference to a swap chain to copy.

◆ SwapChain() [3/3]

mage::rendering::SwapChain::SwapChain ( SwapChain &&  swap_chain)
defaultnoexcept

Constructs a swap chain by moving the given swap chain.

Parameters
[in]swap_chainA reference to a swap chain to move.

◆ ~SwapChain()

mage::rendering::SwapChain::~SwapChain ( )
default

Destructs this swap chain.

Member Function Documentation

◆ Clear()

void mage::rendering::SwapChain::Clear ( ) const
noexcept

Clears the render target view of the back buffer of this swap chain.

◆ GetRTV()

ID3D11RenderTargetView & mage::rendering::SwapChain::GetRTV ( ) const
noexcept

Returns the render target view of the back buffer of this swap chain.

Returns
A reference to the render target view of the back buffer of this swap chain.

◆ GetWindow()

NotNull< HWND > mage::rendering::SwapChain::GetWindow ( )
noexcept

Returns the window handle of this swap chain.

Returns
The window handle of this swap chain.

◆ IsFullScreen()

bool mage::rendering::SwapChain::IsFullScreen ( ) const
noexcept

Checks whether this swap chain displays in full screen mode.

Returns
true if this swap chain displays in full screen mode. false otherwise.

◆ IsWindowed()

bool mage::rendering::SwapChain::IsWindowed ( ) const
noexcept

Checks whether this swap chain displays in windowed mode.

Returns
true if this swap chain displays in windowed mode. false otherwise.

◆ LostMode()

bool mage::rendering::SwapChain::LostMode ( ) const
noexcept

Checks whether this swap chain lost its mode, i.e. the tracked mode of this swap chain differs from its actual mode (e.g. ALT + TAB).

Returns
true if this swap chain lost its mode. false otherwise.

◆ operator=() [1/2]

SwapChain& mage::rendering::SwapChain::operator= ( const SwapChain swap_chain)
delete

Copies the given swap chain to this swap chain.

Parameters
[in]swap_chainA reference to a swap chain to copy.
Returns
A reference to the copy of the given swap chain (i.e. this swap chain).

◆ operator=() [2/2]

SwapChain& mage::rendering::SwapChain::operator= ( SwapChain &&  swap_chain)
delete

Moves the given swap chain to this swap chain.

Parameters
[in]swap_chainA reference to a swap chain to move.
Returns
A reference to the moved swap chain (i.e. this swap chain).

◆ Present()

void mage::rendering::SwapChain::Present ( ) const
noexcept

Presents the back buffer of this swap chain.

◆ SetInitialMode()

void mage::rendering::SwapChain::SetInitialMode ( )

Sets the initial mode of this swap chain.

Call this method before starting the game loop.

Exceptions
ExceptionFailed to reset up the swap chain.

◆ SwitchMode()

void mage::rendering::SwapChain::SwitchMode ( bool  toggle)

Recreates the swap chain buffers and switches the mode of this swap chain. Windowed mode is switched to full screen mode and vice versa.

Parameters
[in]toggleIf true, then only the swap chain buffers will be recreated to match the current mode of this swap chain and no mode switch will occurs. If false, then the swap chain buffers will be recreated and a mode switch will occur.
Exceptions
ExceptionFailed to reset up the swap chain.

◆ TakeScreenShot()

void mage::rendering::SwapChain::TakeScreenShot ( const std::wstring &  fname) const

Takes a screenshot of the current back buffer of this swap chain.

Parameters
[in]fnameA reference to the filename.
Exceptions
ExceptionFailed to take a screenshot of the current back buffer of this swap chain.

Member Data Documentation

◆ m_impl

UniquePtr< Impl > mage::rendering::SwapChain::m_impl
private

A pointer to the implementation of this swap chain.