GraphicsDevice Constructor
Collapse the table of content
Expand the table of content

GraphicsDevice Constructor

XNA Game Studio Express
Creates a new instance of GraphicsDevice

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

public GraphicsDevice (
         GraphicsAdapter adapter,
         DeviceType deviceType,
         IntPtr renderWindowHandle,
         CreateOptions creationOptions,
         PresentationParameters presentationParameters


The display adapter.
The desired device type.
The focus window.
Combination of one or more options that control the global behavior of the device.
The presentation parameters for the device to be created.

Exception typeCondition
ArgumentNullException adapter or presentationParameters is null.

One of the following conditions is true:

InvalidOperationException PresentationParameters.EnableAutoDepthStencil is true, but PresentationParameters.AutoDepthStencilFormat is not a valid value.
DeviceNotSupportedExceptionThe graphics adapter does not support the requested capabilities. For Xbox 360, DeviceType.Hardware is the only device type supported on this platform.

When you create a new XNA Framework game using XNA Game Studio Express, the game derives from Game and contains a member variable that is a GraphicsDeviceManager. This GraphicsDeviceManager automatically creates the best device that is available for the application and exposes it as the GraphicsDeviceManager.GraphicsDevice property. If you wish to change the settings used to create the device, you can create a custom PreparingDeviceSettings event handler for the graphics device manager with the settings you require for your application. For more information on using the PreparingDeviceSettings event handler, see GraphicsDeviceManager.

If a graphics device has been constructed without the GraphicsDeviceManager, it is necessary to manually call Present subsequent to any draw calls to present the back buffer.

Xbox 360, Windows XP SP2, Windows Vista

© 2016 Microsoft