Table of Contents

Class SwapChainGraphicsPresenter

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

A GraphicsPresenter wrapping a DirectX Swap-Chain (Silk.NET.DXGI.IDXGISwapChain).

public class SwapChainGraphicsPresenter : GraphicsPresenter, IDisposable, IComponent, IReferencable, ICollectorHolder
Inheritance
object
SwapChainGraphicsPresenter
Implements
Inherited Members
Extension Methods

Remarks

A Swap-Chain is a collection of same-sized buffers (one front-buffer, one or more -usually one- Back-Buffer, and an optional Depth-Stencil Buffer) that are used to present the final rendered image to the screen.

In order to create a new GraphicsPresenter, a GraphicsDevice should have been initialized first.

Constructors

SwapChainGraphicsPresenter(GraphicsDevice, PresentationParameters)

Initializes a new instance of the SwapChainGraphicsPresenter class.

public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters)

Parameters

device GraphicsDevice

The Graphics Device.

presentationParameters PresentationParameters

The parameters describing the buffers the device will present to.

Exceptions

ArgumentNullException

device is null.

ArgumentNullException

presentationParameters is null.

InvalidOperationException

DeviceWindowHandle is null or the Handle is invalid or zero.

NotSupportedException

The Depth-Stencil format specified is not supported.

Properties

BackBuffer

Gets the default Back-Buffer for the Graphics Presenter.

public override Texture BackBuffer { get; }

Property Value

Texture

The Texture where rendering will happen, which will then be presented to the front-buffer.

IsFullScreen

Gets or sets a value indicating if the Graphics Presenter is in full-screen mode.

public override bool IsFullScreen { get; set; }

Property Value

bool

A value indicating whether the presentation will be in full screen.

  • true if the presentation will be in full screen.
  • false if the presentation will be in a window.

Remarks

This property is only valid on desktop Windows. It has no effect on UWP.

NativePresenter

Gets the underlying native presenter.

public override object NativePresenter { get; }

Property Value

object

The native presenter. Depending on platform, for exmaple, it can be a Silk.NET.DXGI.IDXGISwapChain or Silk.NET.DXGI.IDXGISwapChain1 or null.

Methods

BeginDraw(CommandList)

Marks the beginning of a frame that will be presented later by the Graphics Presenter.

public override void BeginDraw(CommandList commandList)

Parameters

commandList CommandList

The Command List where rendering commands will be registered.

Remarks

When overriden in a derived class, this method should prepare the Graphics Presenter to receive graphics commands to be executed at the beginning of the current frame.

EndDraw(CommandList, bool)

Marks the end of a frame that will be presented later by the Graphics Presenter.

public override void EndDraw(CommandList commandList, bool present)

Parameters

commandList CommandList

The Command List where rendering commands will be registered.

present bool

A value indicating whether the frame will be presented, i.e. if the Back-Buffer will be shown to the screen.

Remarks

When overriden in a derived class, this method should prepare the Graphics Presenter to receive graphics commands to be executed at the end of the current frame.

OnDestroyed(bool)

Called when the Graphics Presenter has been destroyed.

protected override void OnDestroyed(bool immediately = false)

Parameters

immediately bool

A value indicating whether the resources used by the Graphics Presenter should be destroyed immediately (true), or if it can be deferred until it's safe to do so (false).

Remarks

When overriden in a derived class, this method allows to perform additional cleanup and release of associated resources.

OnNameChanged()

Called when the Name property has changed.

protected override void OnNameChanged()

OnRecreated()

Called when the Graphics Presenter has been reinitialized.

public override void OnRecreated()

Remarks

When overriden in a derived class, this method allows to perform additional resource creation, configuration, and initialization.

Exceptions

InvalidOperationException

DeviceWindowHandle is null or the Handle is invalid or zero.

Present()

Presents the Back-Buffer to the screen.

public override void Present()

Exceptions

GraphicsDeviceException

An unexpected error occurred while presenting. Check the status of the Graphics Device for more information (Status).

GraphicsDeviceException

An unexpected error occurred while presenting the Swap-Chain. Check the status of the Graphics Device for more information (Status).

ResizeBackBuffer(int, int, PixelFormat)

Resizes the Back-Buffer.

protected override void ResizeBackBuffer(int width, int height, PixelFormat format)

Parameters

width int

The new width of the Back-Buffer, in pixels.

height int

The new height of the Back-Buffer, in pixels.

format PixelFormat

The new pixel format for the Back-Buffer.

Remarks

When implementing this method, the derived class should resize the Back-Buffer to the specified size and format.

Exceptions

NotSupportedException

The specified pixel format or size is not supported by the Graphics Device.

ResizeDepthStencilBuffer(int, int, PixelFormat)

Resizes the Depth-Stencil Buffer.

protected override void ResizeDepthStencilBuffer(int width, int height, PixelFormat format)

Parameters

width int

The new width of the Depth-Stencil Buffer, in pixels.

height int

The new height of the Depth-Stencil Buffer, in pixels.

format PixelFormat

The new pixel format for the Depth-Stencil Buffer.

Remarks

When implementing this method, the derived class should resize the Depth-Stencil Buffer to the specified size and format.

Exceptions

NotSupportedException

The specified depth format or size is not supported by the Graphics Device.