Cogs.Core
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Cogs::SwapChainD3D11 Class Reference
Inheritance diagram for Cogs::SwapChainD3D11:
Cogs::ISwapChain

Public Member Functions

 SwapChainD3D11 (GraphicsDeviceD3D11 *device)
 
bool initialize (WindowData *windowData)
 
virtual void beginFrame () override
 Signal the beginning of a new frame to the graphics device.
 
virtual void endFrame (uint32_t syncInterval=0, uint32_t presentFlags=PresentFlags::None) override
 Signal the end of a frame to the graphics device.
 
virtual void setSize (int newWidth, int newHeight, bool forceIt=false) override
 Set the size of the main drawing buffer used by the graphics device in pixels.
 
virtual void setFullscreen (bool enabled) override
 Changes this swapchain's fullscreen state if neccessary.
 
virtual bool isFullscreen () override
 Test whether the current swap chain is fullscreen.
 
virtual int getWidth () const override
 Returns the pixel width of this swap chain.
 
virtual int getHeight () const override
 Returns the pixel height of this swap chain.
 
virtual int getSamples () const override
 Returns the number of samples this swap chain has.
 
virtual const RenderTargetHandlegetRenderTarget () const override
 Returns the render target managed by this swap chain.
 
virtual const DepthStencilHandlegetDepthStencil () const override
 Returns the depth stencil managed by this swap chain.
 
ResourcePointer< ID3D11Texture2D > & getSharedBackBuffer ()
 
bool recreateOffscreenBuffers ()
 
virtual void setSize (int newWidth, int newHeight, bool forceIt=false)=0
 Set the size of the main drawing buffer used by the graphics device in pixels.
 
virtual void setFullscreen (bool enabled)=0
 Switch this swap chain to fullscreen or windowed depending on the parameter.
 
virtual bool isFullscreen ()=0
 Test whether the current swap chain is fullscreen.
 
virtual void beginFrame ()=0
 Signal the beginning of a new frame to the graphics device.
 
virtual void endFrame (uint32_t syncInterval=0, uint32_t presentFlags=PresentFlags::None)=0
 Signal the end of a frame to the graphics device.
 
virtual const RenderTargetHandlegetRenderTarget () const =0
 Returns the render target managed by this swap chain.
 
virtual const DepthStencilHandlegetDepthStencil () const =0
 Returns the depth stencil managed by this swap chain.
 
virtual int getWidth () const =0
 Returns the pixel width of this swap chain.
 
virtual int getHeight () const =0
 Returns the pixel height of this swap chain.
 
virtual int getSamples () const =0
 Returns the number of samples this swap chain has.
 

Private Member Functions

void resize ()
 
bool createRenderTargetView ()
 Recreates the render target view used by directx when selecting render targets prior to rendering.
 
bool createDepthStencilView ()
 Recreates the depth/stencil view used by directx when rendering.
 

Private Attributes

GraphicsDeviceD3D11graphicsDevice = nullptr
 
TextureFormat colorFormat = TextureFormat::R8G8B8A8_UNORM_SRGB
 
TextureFormat depthFormat = TextureFormat::D32_FLOAT
 
int numSamples = 1
 
int width = 1280
 
int height = 720
 
bool inFrame = false
 
bool needResize = false
 
ResourcePointer< IDXGISwapChain > swapChain
 
ResourcePointer< ID3D11Texture2D > backBuffer
 
ResourcePointer< ID3D11Texture2D > sharedBackBuffer
 
RenderTargetHandle renderTarget
 
DepthStencilHandle depthStencil
 

Additional Inherited Members

- Protected Attributes inherited from Cogs::ISwapChain
WindowDatawindowData = nullptr
 

Detailed Description

Definition at line 12 of file SwapChainD3D11.h.

Constructor & Destructor Documentation

◆ SwapChainD3D11()

Cogs::SwapChainD3D11::SwapChainD3D11 ( GraphicsDeviceD3D11 device)

Definition at line 13 of file SwapChainD3D11.cpp.

◆ ~SwapChainD3D11()

Cogs::SwapChainD3D11::~SwapChainD3D11 ( )

Definition at line 16 of file SwapChainD3D11.cpp.

Member Function Documentation

◆ beginFrame()

void Cogs::SwapChainD3D11::beginFrame ( )
overridevirtual

Signal the beginning of a new frame to the graphics device.

Implements Cogs::ISwapChain.

Definition at line 99 of file SwapChainD3D11.cpp.

◆ createDepthStencilView()

bool Cogs::SwapChainD3D11::createDepthStencilView ( )
private

Recreates the depth/stencil view used by directx when rendering.

*============================================================================================

Definition at line 309 of file SwapChainD3D11.cpp.

References Cogs::RenderTargetsD3D11::createDepthStencilTarget(), and Cogs::RenderTargetsD3D11::releaseDepthStencilTarget().

◆ createRenderTargetView()

bool Cogs::SwapChainD3D11::createRenderTargetView ( )
private

Recreates the render target view used by directx when selecting render targets prior to rendering.

*============================================================================================

Definition at line 280 of file SwapChainD3D11.cpp.

References Cogs::RenderTargetsD3D11::releaseRenderTarget(), and Cogs::UseSwapEffectDiscard.

◆ endFrame()

void Cogs::SwapChainD3D11::endFrame ( uint32_t  syncInterval = 0,
uint32_t  presentFlags = PresentFlags::None 
)
overridevirtual

Signal the end of a frame to the graphics device.

When the graphics device itself is responsible for managing the device context (e.g in D3D11), and the PresentFlags::NoSwap flag is not set, this will swap the back buffer to make the result of previous drawing visible.

Parameters
syncIntervalSynchronization interval.
  • 0 - No synchronization, presentation occurs immediately.
  • 1 - Synchronize presentation after 1 vertical blank.
presentFlagsA combination of PresentFlags controlling the presentation of the rendered frame.
See also
PresentFlags

Implements Cogs::ISwapChain.

Definition at line 107 of file SwapChainD3D11.cpp.

References Cogs::Direct3D11::Formats, Cogs::PresentFlags::NoSwap, and Cogs::UseSwapEffectDiscard.

◆ getDepthStencil()

virtual const DepthStencilHandle & Cogs::SwapChainD3D11::getDepthStencil ( ) const
inlineoverridevirtual

Returns the depth stencil managed by this swap chain.

Implements Cogs::ISwapChain.

Definition at line 32 of file SwapChainD3D11.h.

Referenced by Cogs::ContextD3D11::setRenderTarget().

◆ getHeight()

virtual int Cogs::SwapChainD3D11::getHeight ( ) const
inlineoverridevirtual

Returns the pixel height of this swap chain.

Implements Cogs::ISwapChain.

Definition at line 28 of file SwapChainD3D11.h.

◆ getRenderTarget()

virtual const RenderTargetHandle & Cogs::SwapChainD3D11::getRenderTarget ( ) const
inlineoverridevirtual

Returns the render target managed by this swap chain.

Implements Cogs::ISwapChain.

Definition at line 31 of file SwapChainD3D11.h.

Referenced by Cogs::ContextD3D11::setRenderTarget().

◆ getSamples()

virtual int Cogs::SwapChainD3D11::getSamples ( ) const
inlineoverridevirtual

Returns the number of samples this swap chain has.

Implements Cogs::ISwapChain.

Definition at line 29 of file SwapChainD3D11.h.

◆ getSharedBackBuffer()

ResourcePointer< ID3D11Texture2D > & Cogs::SwapChainD3D11::getSharedBackBuffer ( )
inline

Definition at line 33 of file SwapChainD3D11.h.

◆ getWidth()

virtual int Cogs::SwapChainD3D11::getWidth ( ) const
inlineoverridevirtual

Returns the pixel width of this swap chain.

Implements Cogs::ISwapChain.

Definition at line 27 of file SwapChainD3D11.h.

◆ initialize()

bool Cogs::SwapChainD3D11::initialize ( WindowData windowData)

Definition at line 22 of file SwapChainD3D11.cpp.

◆ isFullscreen()

bool Cogs::SwapChainD3D11::isFullscreen ( )
overridevirtual

Test whether the current swap chain is fullscreen.

Implements Cogs::ISwapChain.

Definition at line 185 of file SwapChainD3D11.cpp.

◆ recreateOffscreenBuffers()

bool Cogs::SwapChainD3D11::recreateOffscreenBuffers ( )

Definition at line 222 of file SwapChainD3D11.cpp.

◆ resize()

void Cogs::SwapChainD3D11::resize ( )
private

Definition at line 194 of file SwapChainD3D11.cpp.

◆ setFullscreen()

void Cogs::SwapChainD3D11::setFullscreen ( bool  enabled)
overridevirtual

Changes this swapchain's fullscreen state if neccessary.

*============================================================================================

Implements Cogs::ISwapChain.

Definition at line 169 of file SwapChainD3D11.cpp.

◆ setSize()

void Cogs::SwapChainD3D11::setSize ( int  newWidth,
int  newHeight,
bool  forceIt = false 
)
overridevirtual

Set the size of the main drawing buffer used by the graphics device in pixels.

Parameters
newWidthWidth of the drawing buffer in pixels.
newHeightHeight of the drawing buffer in pixels.
forceItForce the resize even if the new width and height are identical to the existing values.

Implements Cogs::ISwapChain.

Definition at line 150 of file SwapChainD3D11.cpp.

Member Data Documentation

◆ backBuffer

ResourcePointer<ID3D11Texture2D> Cogs::SwapChainD3D11::backBuffer
private

Definition at line 47 of file SwapChainD3D11.h.

◆ colorFormat

TextureFormat Cogs::SwapChainD3D11::colorFormat = TextureFormat::R8G8B8A8_UNORM_SRGB
private

Definition at line 39 of file SwapChainD3D11.h.

◆ depthFormat

TextureFormat Cogs::SwapChainD3D11::depthFormat = TextureFormat::D32_FLOAT
private

Definition at line 40 of file SwapChainD3D11.h.

◆ depthStencil

DepthStencilHandle Cogs::SwapChainD3D11::depthStencil
private

Definition at line 50 of file SwapChainD3D11.h.

◆ graphicsDevice

GraphicsDeviceD3D11* Cogs::SwapChainD3D11::graphicsDevice = nullptr
private

Definition at line 38 of file SwapChainD3D11.h.

◆ height

int Cogs::SwapChainD3D11::height = 720
private

Definition at line 43 of file SwapChainD3D11.h.

◆ inFrame

bool Cogs::SwapChainD3D11::inFrame = false
private

Definition at line 44 of file SwapChainD3D11.h.

◆ needResize

bool Cogs::SwapChainD3D11::needResize = false
private

Definition at line 45 of file SwapChainD3D11.h.

◆ numSamples

int Cogs::SwapChainD3D11::numSamples = 1
private

Definition at line 41 of file SwapChainD3D11.h.

◆ renderTarget

RenderTargetHandle Cogs::SwapChainD3D11::renderTarget
private

Definition at line 49 of file SwapChainD3D11.h.

◆ sharedBackBuffer

ResourcePointer<ID3D11Texture2D> Cogs::SwapChainD3D11::sharedBackBuffer
private

Definition at line 48 of file SwapChainD3D11.h.

◆ swapChain

ResourcePointer<IDXGISwapChain> Cogs::SwapChainD3D11::swapChain
private

Definition at line 46 of file SwapChainD3D11.h.

◆ width

int Cogs::SwapChainD3D11::width = 1280
private

Definition at line 42 of file SwapChainD3D11.h.


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