Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Retrieves the display mode's spatial resolution, color resolution, and refresh frequency.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework.Graphics (in microsoft.xna.framework.graphics.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 may be inactive 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 class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.PreparingDeviceSettings +=
new EventHandler<PreparingDeviceSettingsEventArgs>(
graphics_PreparingDeviceSettings);
}
/// <summary>
/// Modifies the display mode for the graphics device
/// when it is reset or recreated.
/// </summary>
void graphics_PreparingDeviceSettings(object sender,
PreparingDeviceSettingsEventArgs e)
{
foreach (Microsoft.Xna.Framework.Graphics.DisplayMode displayMode
in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
{
if (displayMode.Width == 640 && displayMode.Height == 480)
{
e.GraphicsDeviceInformation.PresentationParameters.
BackBufferFormat = displayMode.Format;
e.GraphicsDeviceInformation.PresentationParameters.
BackBufferHeight = displayMode.Height;
e.GraphicsDeviceInformation.PresentationParameters.
BackBufferWidth = displayMode.Width;
}
}
}
See Also
Concepts
Xbox 360 Programming Considerations
Reference
GraphicsAdapter.SupportedDisplayModes Property
GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows 7, Windows Vista, Windows XP