Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GraphicsDevice Constructor

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
)

Parameters

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

Exception typeCondition
ArgumentNullException adapter or presentationParameters is null.
ArgumentException

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.

Bb195941.note(en-US,XNAGameStudio.10).gifNote
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

Show:
© 2015 Microsoft