Table of Contents

Class GraphicsDeviceManager

Namespace
Stride.Games
Assembly
Stride.Games.dll

Manages the GraphicsDevice lifecycle.

public class GraphicsDeviceManager : ComponentBase, IDisposable, IComponent, IReferencable, ICollectorHolder, IGraphicsDeviceManager, IGraphicsDeviceService
Inheritance
GraphicsDeviceManager
Implements
Inherited Members
Extension Methods

Fields

DefaultBackBufferHeight

Default height for the back buffer.

public static readonly int DefaultBackBufferHeight

Field Value

int

DefaultBackBufferWidth

Default width for the back buffer.

public static readonly int DefaultBackBufferWidth

Field Value

int

Properties

DeviceCreationFlags

Gets or sets the device creation flags that will be used to create the GraphicsDevice

public DeviceCreationFlags DeviceCreationFlags { get; set; }

Property Value

DeviceCreationFlags

The device creation flags.

GraphicsDevice

Gets the current graphcs device.

public GraphicsDevice GraphicsDevice { get; }

Property Value

GraphicsDevice

The graphics device.

IsFullScreen

Gets or sets a value indicating whether this instance is full screen.

public bool IsFullScreen { get; set; }

Property Value

bool

true if this instance is full screen; otherwise, false.

PreferredBackBufferFormat

Gets or sets the preferred back buffer format.

public PixelFormat PreferredBackBufferFormat { get; set; }

Property Value

PixelFormat

The preferred back buffer format.

PreferredBackBufferHeight

Gets or sets the height of the preferred back buffer.

public int PreferredBackBufferHeight { get; set; }

Property Value

int

The height of the preferred back buffer.

PreferredBackBufferWidth

Gets or sets the width of the preferred back buffer.

public int PreferredBackBufferWidth { get; set; }

Property Value

int

The width of the preferred back buffer.

PreferredColorSpace

Gets or sets the default color space.

public ColorSpace PreferredColorSpace { get; set; }

Property Value

ColorSpace

The default color space.

PreferredDepthStencilFormat

Gets or sets the preferred depth stencil format.

public PixelFormat PreferredDepthStencilFormat { get; set; }

Property Value

PixelFormat

The preferred depth stencil format.

PreferredFullScreenOutputIndex

The output (monitor) index to use when switching to fullscreen mode. Doesn't have any effect when windowed mode is used.

public int PreferredFullScreenOutputIndex { get; set; }

Property Value

int

PreferredGraphicsProfile

Gets or sets the list of graphics profile to select from the best feature to the lower feature. See remarks.

public GraphicsProfile[] PreferredGraphicsProfile { get; set; }

Property Value

GraphicsProfile[]

The graphics profile.

Remarks

By default, the PreferredGraphicsProfile is set to { Level_11_1, Level_11_0, Level_10_1, Level_10_0, Level_9_3, Level_9_2, Level_9_1}

PreferredMultisampleCount

Gets or sets a value indicating whether [prefer multi sampling].

public MultisampleCount PreferredMultisampleCount { get; set; }

Property Value

MultisampleCount

true if [prefer multi sampling]; otherwise, false.

PreferredRefreshRate

Gets or sets the preferred refresh rate.

public Rational PreferredRefreshRate { get; set; }

Property Value

Rational

The preferred refresh rate.

RequiredAdapterUid

If populated the engine will try to initialize the device with the same unique id

public string RequiredAdapterUid { get; set; }

Property Value

string

ShaderProfile

Gets or sets the shader graphics profile that will be used to compile shaders. See remarks.

public GraphicsProfile? ShaderProfile { get; set; }

Property Value

GraphicsProfile?

The shader graphics profile.

Remarks

If this property is not set, the profile used to compile the shader will be taken from the GraphicsDevice based on the list provided by PreferredGraphicsProfile

SupportedOrientations

Gets or sets the supported orientations.

public DisplayOrientation SupportedOrientations { get; set; }

Property Value

DisplayOrientation

The supported orientations.

SynchronizeWithVerticalRetrace

Gets or sets a value indicating whether [synchronize with vertical retrace].

public bool SynchronizeWithVerticalRetrace { get; set; }

Property Value

bool

true if [synchronize with vertical retrace]; otherwise, false.

Methods

ApplyChanges()

Applies the changes from this instance and change or create the GraphicsDevice according to the new values.

public void ApplyChanges()

CanResetDevice(GraphicsDeviceInformation)

Determines whether this instance is compatible with the the specified new GraphicsDeviceInformation.

protected virtual bool CanResetDevice(GraphicsDeviceInformation newDeviceInfo)

Parameters

newDeviceInfo GraphicsDeviceInformation

The new device info.

Returns

bool

true if this instance this instance is compatible with the the specified new GraphicsDeviceInformation; otherwise, false.

Destroy()

Disposes of object resources.

protected override void Destroy()

FindBestDevice(bool)

Finds the best device that is compatible with the preferences defined in this instance.

protected virtual GraphicsDeviceInformation FindBestDevice(bool anySuitableDevice)

Parameters

anySuitableDevice bool

if set to true a device can be selected from any existing adapters, otherwise, it will select only from default adapter.

Returns

GraphicsDeviceInformation

The graphics device information.

IsPreferredProfileAvailable(GraphicsProfile[], out GraphicsProfile)

protected virtual bool IsPreferredProfileAvailable(GraphicsProfile[] preferredProfiles, out GraphicsProfile availableProfile)

Parameters

preferredProfiles GraphicsProfile[]
availableProfile GraphicsProfile

Returns

bool

OnDeviceCreated(object, EventArgs)

protected virtual void OnDeviceCreated(object sender, EventArgs args)

Parameters

sender object
args EventArgs

OnDeviceDisposing(object, EventArgs)

protected virtual void OnDeviceDisposing(object sender, EventArgs args)

Parameters

sender object
args EventArgs

OnDeviceReset(object, EventArgs)

protected virtual void OnDeviceReset(object sender, EventArgs args)

Parameters

sender object
args EventArgs

OnDeviceResetting(object, EventArgs)

protected virtual void OnDeviceResetting(object sender, EventArgs args)

Parameters

sender object
args EventArgs

OnPreparingDeviceSettings(object, PreparingDeviceSettingsEventArgs)

protected virtual void OnPreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs args)

Parameters

sender object
args PreparingDeviceSettingsEventArgs

RankDevices(List<GraphicsDeviceInformation>)

Ranks a list of GraphicsDeviceInformation before creating a new device.

protected virtual void RankDevices(List<GraphicsDeviceInformation> foundDevices)

Parameters

foundDevices List<GraphicsDeviceInformation>

The list of devices that can be reorder.

SelectOrientation(DisplayOrientation, int, int, bool)

protected static DisplayOrientation SelectOrientation(DisplayOrientation orientation, int width, int height, bool allowLandscapeLeftAndRight)

Parameters

orientation DisplayOrientation
width int
height int
allowLandscapeLeftAndRight bool

Returns

DisplayOrientation

SetPreferredGraphicsProfile(params GraphicsProfile[])

Sets the preferred graphics profile.

public void SetPreferredGraphicsProfile(params GraphicsProfile[] levels)

Parameters

levels GraphicsProfile[]

The levels.

See Also

Events

DeviceCreated

Occurs when a device is created.

public event EventHandler<EventArgs> DeviceCreated

Event Type

EventHandler<EventArgs>

DeviceDisposing

Occurs when a device is disposing.

public event EventHandler<EventArgs> DeviceDisposing

Event Type

EventHandler<EventArgs>

DeviceReset

Occurs when a device is reseted.

public event EventHandler<EventArgs> DeviceReset

Event Type

EventHandler<EventArgs>

DeviceResetting

Occurs when a device is resetting.

public event EventHandler<EventArgs> DeviceResetting

Event Type

EventHandler<EventArgs>

PreparingDeviceSettings

public event EventHandler<PreparingDeviceSettingsEventArgs> PreparingDeviceSettings

Event Type

EventHandler<PreparingDeviceSettingsEventArgs>