Class GraphicsDeviceManager
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
DefaultBackBufferWidth
Default width for the back buffer.
public static readonly int DefaultBackBufferWidth
Field Value
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
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
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
GraphicsDeviceInformationThe 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
boolif 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
OnDeviceCreated(object, EventArgs)
protected virtual void OnDeviceCreated(object sender, EventArgs args)
Parameters
OnDeviceDisposing(object, EventArgs)
protected virtual void OnDeviceDisposing(object sender, EventArgs args)
Parameters
OnDeviceReset(object, EventArgs)
protected virtual void OnDeviceReset(object sender, EventArgs args)
Parameters
OnDeviceResetting(object, EventArgs)
protected virtual void OnDeviceResetting(object sender, EventArgs args)
Parameters
OnPreparingDeviceSettings(object, PreparingDeviceSettingsEventArgs)
protected virtual void OnPreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs args)
Parameters
sender
objectargs
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
DisplayOrientationwidth
intheight
intallowLandscapeLeftAndRight
bool
Returns
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
DeviceDisposing
Occurs when a device is disposing.
public event EventHandler<EventArgs> DeviceDisposing
Event Type
DeviceReset
Occurs when a device is reseted.
public event EventHandler<EventArgs> DeviceReset
Event Type
DeviceResetting
Occurs when a device is resetting.
public event EventHandler<EventArgs> DeviceResetting
Event Type
PreparingDeviceSettings
public event EventHandler<PreparingDeviceSettingsEventArgs> PreparingDeviceSettings