Device.Device(IntPtr) Constructor (Microsoft.DirectX.Direct3D)

How Do I...?

  • Maintain Floating Point Precision after Device Creation

Initializes a new instance of the current class.

Definition

Visual Basic Public Sub New( _
    ByVal unmanagedObject As IntPtrLeave Site _
)
C# public Device(
    IntPtrLeave Site unmanagedObject
);
C++ public:
 Device(
    IntPtrLeave Site unmanagedObject
);
JScript public function Device(
    unmanagedObject : IntPtrLeave Site
);

Parameters

unmanagedObject System.IntPtr
Pointer to an unmanaged Component Object Model (COM) IDirect3DDevice9 interface. This parameter is useful for working with unmanaged applications from managed code. Not supported.

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