GraphicsDeviceManager Class

Handles the configuration and management of the graphics device.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework.Game (in microsoft.xna.framework.game.dll)

Syntax

public class GraphicsDeviceManager : IGraphicsDeviceService, IDisposable, IGraphicsDeviceManager

Remarks

Custom behavior of the GraphicsDeviceManager can be achieved by deriving a class from GraphicsDeviceManager. For example, to allow only widescreen devices in full-screen mode the RankDevices method could be overridden to drop non-widescreen devices.

Or, if you are creating a 2D game, you might want to create a graphics device without a depth buffer. By adding an event handler for the PreparingDeviceSettings event to the GraphicsDeviceManager, you can control the PresentationParameters properties associated with the graphics device. In the example below, the event handler is named graphics_Settings_NoDepthBuffer.

graphics = new GraphicsDeviceManager(this);
graphics.PreparingDeviceSettings +=
    new EventHandler<PreparingDeviceSettingsEventArgs>(
                        graphics_Settings_NoDepthBuffer);

See Also

Reference

GraphicsDeviceManager Members
Microsoft.Xna.Framework Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP