GraphicsDevice.DisplayMode Property
Retrieves the display mode's spatial resolution, color resolution, and refresh frequency.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public DisplayMode DisplayMode { get; }
Property Value
Data describing the display mode of the adapter (as opposed to the display mode of the GraphicsDevice, which might not be active if the GraphicsDevice does not own full-screen mode).
Remarks
For a list of all supported display modes for an adapter, see the SupportedDisplayModes property.
Example
This simple example checks for a supported display mode and sets the back buffer dimensions to match the resolution of the desired display mode.
public Game1()
{
content = new ContentManager(Services);
graphics = new GraphicsDeviceManager(this);
graphics.PreparingDeviceSettings +=
new EventHandler<PreparingDeviceSettingsEventArgs>(
graphics_PreparingDeviceSettings );
}
void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
foreach (Microsoft.Xna.Framework.Graphics.DisplayMode displayMode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
{
// If 1080i (Widescreen) format is available, set it to use this format.
// 1080i is 19201080, so check to see if there is a DisplayMode available
// that matches this
if (displayMode.Width == 1920 && displayMode.Height == 1080)
{
e.GraphicsDeviceInformation.PresentationParameters.BackBufferFormat = displayMode.Format;
e.GraphicsDeviceInformation.PresentationParameters.BackBufferHeight = displayMode.Height;
e.GraphicsDeviceInformation.PresentationParameters.BackBufferWidth = displayMode.Width;
e.GraphicsDeviceInformation.PresentationParameters.FullScreenRefreshRateInHz = displayMode.RefreshRate;
e.GraphicsDeviceInformation.PresentationParameters.IsFullScreen = true;
}
}
}
See Also
Concepts
Displays, Client Bounds, Viewports, and Back Buffers
Xbox 360 Programming Considerations
Reference
GraphicsAdapter.SupportedDisplayModes Property
GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows XP SP2, Windows Vista