Share via


GraphicsDevice Constructor

Creates a new instance of GraphicsDevice

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

Syntax

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.

Exceptions

Exception type Condition
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.
DeviceNotSupportedException The graphics adapter does not support the requested capabilities. For Xbox 360, DeviceType.Hardware is the only device type supported on this platform.

Remarks

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.

Note

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.

See Also

Tasks

How to: Use the Reference Device

Reference

GraphicsDeviceManager Class
GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista