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

Public Member Functions

 Impl (ID3D11Device &device, ID3D11DeviceContext &device_context, NotNull< HWND > window, DisplayConfiguration &display_configuration)
 
 Impl (const Impl &swap_chain)=delete
 
 Impl (Impl &&swap_chain) noexcept
 
 ~Impl ()
 
Imploperator= (const Impl &swap_chain)=delete
 
Imploperator= (Impl &&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 Member Functions

bool IsTrackedFullScreen () const noexcept
 
void SetTrackedFullScreen (bool fullscreen) noexcept
 
void SetupSwapChain ()
 
void ResetSwapChain ()
 
void CreateSwapChain ()
 
void CreateRTV ()
 

Private Attributes

NotNull< HWND > m_window
 
DisplayConfigurationm_display_configuration
 
ID3D11Device & m_device
 
ID3D11DeviceContext & m_device_context
 
ComPtr< DXGISwapChainm_swap_chain
 
ComPtr< ID3D11RenderTargetView > m_rtv
 

Detailed Description

A class of swap chains.

Constructor & Destructor Documentation

◆ Impl() [1/3]

mage::rendering::SwapChain::Impl::Impl ( 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.

◆ Impl() [2/3]

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

Constructs a swap chain from the given swap chain.

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

◆ Impl() [3/3]

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

Constructs a swap chain by moving the given swap chain.

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

◆ ~Impl()

mage::rendering::SwapChain::Impl::~Impl ( )

Destructs this swap chain.

Member Function Documentation

◆ Clear()

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

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

◆ CreateRTV()

void mage::rendering::SwapChain::Impl::CreateRTV ( )
private

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

Exceptions
ExceptionFailed to obtain the back buffer resource of this swap chain.
ExceptionFailed to create the render target view of the back buffer of this swap chain.

◆ CreateSwapChain()

void mage::rendering::SwapChain::Impl::CreateSwapChain ( )
private

Creates the swap chain.

Exceptions
ExceptionFailed to create the swap chain.

◆ GetRTV()

ID3D11RenderTargetView& mage::rendering::SwapChain::Impl::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::Impl::GetWindow ( )
noexcept

Returns the window handle of this swap chain.

Returns
The window handle of this swap chain.

◆ IsFullScreen()

bool mage::rendering::SwapChain::Impl::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.

◆ IsTrackedFullScreen()

bool mage::rendering::SwapChain::Impl::IsTrackedFullScreen ( ) const
privatenoexcept

Checks whether the tracked mode of this swap chain corresponds to fullscreen mode.

Returns
true if the tracked mode of this swap chain corresponds to fullscreen mode. false otherwise.

◆ IsWindowed()

bool mage::rendering::SwapChain::Impl::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::Impl::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]

Impl& mage::rendering::SwapChain::Impl::operator= ( const Impl 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]

Impl& mage::rendering::SwapChain::Impl::operator= ( Impl &&  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::Impl::Present ( ) const
noexcept

Presents the back buffer of this swap chain.

◆ ResetSwapChain()

void mage::rendering::SwapChain::Impl::ResetSwapChain ( )
private

Resets the swap chain.

Exceptions
ExceptionFailed to reset up the swap chain.

◆ SetInitialMode()

void mage::rendering::SwapChain::Impl::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.

◆ SetTrackedFullScreen()

void mage::rendering::SwapChain::Impl::SetTrackedFullScreen ( bool  fullscreen)
privatenoexcept

Sets the tracked mode of this swap chain.

Parameters
[in]fullscreentrue if the tracked mode corresponds to fullscreen mode. false otherwise.

◆ SetupSwapChain()

void mage::rendering::SwapChain::Impl::SetupSwapChain ( )
private

Sets up the swap chain.

Exceptions
ExceptionFailed to set up the swap chain.

◆ SwitchMode()

void mage::rendering::SwapChain::Impl::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::Impl::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_device

ID3D11Device& mage::rendering::SwapChain::Impl::m_device
private

A reference to the device.

◆ m_device_context

ID3D11DeviceContext& mage::rendering::SwapChain::Impl::m_device_context
private

A reference to the device context.

◆ m_display_configuration

DisplayConfiguration& mage::rendering::SwapChain::Impl::m_display_configuration
private

A reference to the display configuration of this swap chain.

◆ m_rtv

ComPtr< ID3D11RenderTargetView > mage::rendering::SwapChain::Impl::m_rtv
private

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

◆ m_swap_chain

ComPtr< DXGISwapChain > mage::rendering::SwapChain::Impl::m_swap_chain
private

A pointer to the swap chain.

◆ m_window

NotNull< HWND > mage::rendering::SwapChain::Impl::m_window
private

The handle of the parent window of this swap chain.