Blowbox 2017
A 3D Game Engine by Riko Ophorst using DirectX 12
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
blowbox::SwapChain Class Reference

#include <swap_chain.h>

Public Member Functions

void Create (HWND output_window, UINT width, UINT height, DXGI_FORMAT format, UINT buffer_count, DXGI_SWAP_EFFECT swap_effect, UINT flags, bool disable_alt_enter=true, bool windowed=true)
 
void Present (bool vsync=true)
 
ColorBufferGetBuffer (UINT buffer_index)
 
const ColorBufferGetBuffer (UINT buffer_index) const
 
ColorBufferGetBackBuffer ()
 
const ColorBufferGetBackBuffer () const
 
const UINT & GetBufferCount () const
 
const UINT & GetBackBufferIndex () const
 
const UINT & GetBufferWidth () const
 
const UINT & GetBufferHeight () const
 
 operator IDXGISwapChain * ()
 
IDXGISwapChain * operator-> ()
 
const IDXGISwapChain * operator-> () const
 

Protected Member Functions

DXGI_SWAP_CHAIN_DESC DescribeSwapChain (HWND output_window, UINT width, UINT height, DXGI_FORMAT format, UINT buffer_count, DXGI_SWAP_EFFECT swap_effect, UINT flags, bool windowed=true)
 

Private Attributes

IDXGISwapChain * swap_chain_
 
DXGI_SWAP_CHAIN_DESC desc_
 
UINT back_buffer_index_
 
UINT buffer_count_
 
ColorBuffer buffers_ [SWAP_CHAIN_MAX_BUFFER_COUNT]
 

Detailed Description

Wraps the IDXGISwapChain.

This class wraps all the functionality of a IDXGISwapChain. It creates the ColorBuffers for the back buffers and makes it easy to swap the buffers via Present calls.

Member Function Documentation

void blowbox::SwapChain::Create ( HWND  output_window,
UINT  width,
UINT  height,
DXGI_FORMAT  format,
UINT  buffer_count,
DXGI_SWAP_EFFECT  swap_effect,
UINT  flags,
bool  disable_alt_enter = true,
bool  windowed = true 
)

Creates the actual SwapChain.

Parameters
[in]output_windowThe output window to which the SwapChain has to bind.
[in]widthThe width of the output window.
[in]heightThe height of the output window.
[in]formatThe formats you want to use for the back buffers.
[in]buffer_countThe number of back buffers that should be created.
[in]swap_effectThe swap effect that should be used when Presenting to the output window.
[in]flagsAny flags that should be attached to the swap chain.
[in]disable_alt_enterWhether alt-enter (for fullscreen stuff) should be disabled.
[in]windowedWhether the swap chain should be windowed or fullscreen.
DXGI_SWAP_CHAIN_DESC blowbox::SwapChain::DescribeSwapChain ( HWND  output_window,
UINT  width,
UINT  height,
DXGI_FORMAT  format,
UINT  buffer_count,
DXGI_SWAP_EFFECT  swap_effect,
UINT  flags,
bool  windowed = true 
)
protected

Creates a DXGI_SWAP_CHAIN_DESC based on input params.

Parameters
[in]output_windowThe window that should be output into.
[in]widthThe width of the of the SwapChain buffers.
[in]heightThe height of the SwapChain buffers.
[in]formatThe format for the SwapChain buffers.
[in]buffer_countThe number of buffers in the SwapChain.
[in]swap_effectThe swap effect that should be used when swapping out presenting buffers.
[in]flagsAny flags that should be set on the SwapChain.
[in]windowedWhether the swap chain should be windowed or not.
ColorBuffer& blowbox::SwapChain::GetBackBuffer ( )
inline
Returns
A ColorBuffer that represents the current back buffer in the SwapChain.
const ColorBuffer& blowbox::SwapChain::GetBackBuffer ( ) const
inline
Returns
A ColorBuffer that represents the current back buffer in the SwapChain.
const UINT& blowbox::SwapChain::GetBackBufferIndex ( ) const
inline
Returns
The number of buffers in this SwapChain.
ColorBuffer& blowbox::SwapChain::GetBuffer ( UINT  buffer_index)
inline

Retrieve a certain buffer from the SwapChain buffers.

Parameters
[in]buffer_indexAn index into the SwapChain buffers array.
Returns
A ColorBuffer that represents a SwapChain buffer.
const ColorBuffer& blowbox::SwapChain::GetBuffer ( UINT  buffer_index) const
inline

Retrieve a certain buffer from the SwapChain buffers.

Parameters
[in]buffer_indexAn index into the SwapChain buffers array.
Returns
A ColorBuffer that represents a SwapChain buffer.
const UINT& blowbox::SwapChain::GetBufferCount ( ) const
inline
Returns
The number of buffers in this SwapChain.
const UINT& blowbox::SwapChain::GetBufferHeight ( ) const
inline
Returns
The height of every buffer in the SwapChain.
const UINT& blowbox::SwapChain::GetBufferWidth ( ) const
inline
Returns
The width of every buffer in the SwapChain.
blowbox::SwapChain::operator IDXGISwapChain * ( )
inline

Implicit cast to a IDXGISwapChain.

IDXGISwapChain* blowbox::SwapChain::operator-> ( )
inline

Overloads the pointer operator to return the underlying IDXGISwapChain.

const IDXGISwapChain* blowbox::SwapChain::operator-> ( ) const
inline

Overloads the pointer operator to return the underlying IDXGISwapChain.

void blowbox::SwapChain::Present ( bool  vsync = true)

Presents the back buffer to the screen.

Parameters
[in]vsyncWhether the present call should wait for the next V_BLANK. (i.e. whether to use vsync or not)

Member Data Documentation

UINT blowbox::SwapChain::back_buffer_index_
private

The current back buffer index.

UINT blowbox::SwapChain::buffer_count_
private

The number of buffers in use by the SwapChain.

ColorBuffer blowbox::SwapChain::buffers_[SWAP_CHAIN_MAX_BUFFER_COUNT]
private

All the different SwapChain buffers.

DXGI_SWAP_CHAIN_DESC blowbox::SwapChain::desc_
private

The description of the IDXGISwapChain.

IDXGISwapChain* blowbox::SwapChain::swap_chain_
private

The underlying IDXGISwapChain.


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