Device.Device(Int32,DeviceType,IntPtr,CreateFlags,PresentParameters[]) Constructor (Microsoft.DirectX.Direct3D)

Initializes a new instance of the current class.

Definition

Visual BasicPublic Sub New( _
    ByVal adapter As Integer, _
    ByVal deviceType As DeviceType, _
    ByVal renderWindowHandle As IntPtrLeave Site, _
    ByVal behaviorFlags As CreateFlags, _
    ByVal presentationParameters() As PresentParameters _
)
C#public Device(
    int adapter,
    DeviceType deviceType,
    IntPtrLeave Site renderWindowHandle,
    CreateFlags behaviorFlags,
    PresentParameters[] presentationParameters
);
C++public:
 Device(
    int adapter,
    DeviceType deviceType,
    IntPtrLeave Site renderWindowHandle,
    CreateFlags behaviorFlags,
    array<PresentParameters^>^ presentationParameters
);
JScriptpublic function Device(
    adapter : int,
    deviceType : DeviceType,
    renderWindowHandle : IntPtrLeave Site,
    behaviorFlags : CreateFlags,
    presentationParameters : PresentParameters[]
);

Parameters

adapter System.Int32
Ordinal number that identifies which physical device the object represents. Device 0 is the default device. The highest value that can be used in this parameter is one less than the total number of physical devices.
deviceType Microsoft.DirectX.Direct3D.DeviceType
Member of the DeviceType enumerated type that denotes the desired device type. If the desired device type is not available, the method fails.
renderWindowHandle System.IntPtr
Handle to a FormLeave Site, PanelLeave Site, or any other ControlLeave Site derived class. This parameter indicates the surface to bind to the device.

For full-screen mode, the window specified must be a top-level window.

For windowed mode, this parameter can be null. If null is specified, a non-null handle must be specified when calling Device.Present. This can be done either by setting the PresentParameters.DeviceWindow property, or by using the optional param_Control_overrideWindow parameter of the Device.Present method.

behaviorFlags Microsoft.DirectX.Direct3D.CreateFlags
Combination of one or more options that control device creation.
presentationParameters Microsoft.DirectX.Direct3D.PresentParameters[]
[in, out] Pointer to a PresentParameters object that describes the presentation parameters for the device to create. For Microsoft Windows 2000 and Windows XP, the full-screen device display refresh rate is set in the following order.
  1. User-specified nonzero ForcedRefreshRate registry key, if supported by the device.
  2. Application-specified nonzero refresh rate value in the presentation parameter.
  3. Refresh rate of the latest desktop mode, if supported by the device.
  4. 75 hertz if supported by the device.
  5. 60 hertz if supported by the device.
  6. Device default.
By default, if a refresh rate is unsupported, the closest supported refresh rate below it is used. For example, if the application specifies 63 hertz, 60 hertz is used. No refresh rates below 57 hertz are supported.

Calling this method changes the value of several members of PresentParameters. If AdapterGroupDevice is set, param_PresentParametersA_presentationParameters is an array. Regardless of the number of heads that exist, only one depth stencil surface is automatically created.

Remarks

Exceptions
DeviceLostException The device has been lost but cannot be reset at this time. Therefore, rendering is not possible.
InvalidCallException The method call is invalid. For example, a method's parameter may have an invalid value.
NotAvailableException This device does not support the queried technique.
OutOfVideoMemoryException Direct3D does not have enough display memory to perform the operation.

This constructor creates a fully functional device object that is set to the required display mode (or windowed mode) and allocated with the appropriate back buffers. To begin rendering, the application needs only to create and set a depth buffer (assuming EnableAutoDepthStencil is false in PresentParameters).

Note that the HardwareVertexProcessing, MixedVertexProcessing, and SoftwareVertexProcessing vertex flags are mutually exclusive, and that at least one must be specified when calling this method.

Back buffers created as part of the device are lockable only if LockableBackBuffer is specified in PresentParameters. Multisampled back buffers and depth surfaces are never lockable.

The Device.Reset and Device.TestCooperativeLevel methods must be called from the same thread that used this method to create a device.

The Format.Unknown type can be specified for the windowed mode back-buffer format when calling Device, Device.Reset, and SwapChain.SwapChain(Device, PresentParameters) (the constructor override for creating a new swap chain). This means the application does not have to query the current desktop format before calling Device for windowed mode. For full-screen mode, the back-buffer format must be specified.

The Device method fails if an attempt is made to create a device on a 0x0-sized window.

How Do I...?

Maintain Floating Point Precision after Device Creation

When a Device object is created, the common language runtime will change the floating-point unit (FPU) to single precision to maintain better performance. To maintain the default double precision FPU, which is default for the common language runtime, use the CreateFlags.FpuPreserve flag when creating a Device object as in the sample code below.

[C#]Device device = null;              // Create rendering device
	PresentParameters presentParams = new PresentParameters();

	device = new Device(0, DeviceType.Hardware, this, 
			CreateFlags.SoftwareVertexProcessing | 
			CreateFlags.FpuPreserve, presentParams);

See Also

Show: