Device.Device(Int32,DeviceType,IntPtr,CreateFlags,PresentParameters[]) 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 adapter As Integer, _
ByVal deviceType As DeviceType, _
ByVal renderWindowHandle As IntPtr, _
ByVal behaviorFlags As CreateFlags, _
ByVal presentationParameters() As PresentParameters _
)C# public Device(
int adapter,
DeviceType deviceType,
IntPtr renderWindowHandle,
CreateFlags behaviorFlags,
PresentParameters[] presentationParameters
);C++ public:
Device(
int adapter,
DeviceType deviceType,
IntPtr renderWindowHandle,
CreateFlags behaviorFlags,
array<PresentParameters^>^ presentationParameters
);JScript public function Device(
adapter : int,
deviceType : DeviceType,
renderWindowHandle : IntPtr,
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 Form, Panel, or any other Control 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.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.
- User-specified nonzero ForcedRefreshRate registry key, if supported by the device.
- Application-specified nonzero refresh rate value in the presentation parameter.
- Refresh rate of the latest desktop mode, if supported by the device.
- 75 hertz if supported by the device.
- 60 hertz if supported by the device.
- Device default.
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.
- BackBufferCount, BackBufferWidth, and BackBufferHeight = 0 for windowed or full-screen mode.
- BackBufferFormat = Unknown for windowed mode only. Full-screen mode must specify a format.
Remarks
Exceptions
The device has been lost but cannot be reset at this time. Therefore, rendering is not possible.
The method call is invalid. For example, a method's parameter may have an invalid value.
This device does not support the queried technique.
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