GraphicsDeviceManager Constructor

Creates a new GraphicsDeviceManager and registers it to handle the configuration and management of the graphics device for the specified Game.

Syntax

'Declaration
Public Sub New ( _
         game As Game _
)
public GraphicsDeviceManager (
         Game game
)
public:
GraphicsDeviceManager(
         Game game
)

Parameters

Exceptions

Exception type Condition
ArgumentNullException The game parameter is null.
ArgumentException A graphics device manager has already been added to Services and registered as the graphics device manager for the application. The graphics device manager cannot be changed once it is set.

Remarks

This constructor adds this GraphicsDeviceManager to the collection of game services that have been implicitly registered by adding them to the Game.Services property.

Warning

Although this constructor requires an instance of Game, if the application does not otherwise require an instance of Game it is often better to implement a the IGraphicsDeviceService and IGraphicsDeviceManager interfaces to provide the same services that would be provided by the GraphicsDeviceManager.

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);

Requirements

Namespace: Microsoft.Xna.Framework

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

See Also

Reference

GraphicsDeviceManager Class
GraphicsDeviceManager Members
Microsoft.Xna.Framework Namespace

Platforms

Windows Phone