Device.Device Constructor |
Language: |
Initializes a new instance of the current class.
Visual Basic Public Sub New( _
ByVal adapter As Integer, _
ByVal deviceType As DeviceType, _
ByVal renderWindow As Control, _
ByVal behaviorFlags As CreateFlags, _
ByVal presentationParameters() As PresentParameters _
)C# public Device(
int adapter,
DeviceType deviceType,
Control renderWindow,
CreateFlags behaviorFlags,
PresentParameters[] presentationParameters
);C++ public:
Device(
int adapter,
DeviceType deviceType,
Control^ renderWindow,
CreateFlags behaviorFlags,
array<PresentParameters^>^ presentationParameters
);JScript public function Device(
adapter : int,
deviceType : DeviceType,
renderWindow : Control,
behaviorFlags : CreateFlags,
presentationParameters : PresentParameters[]
);
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.renderWindow System.Windows.Forms.Control
Pointer to an unmanaged (or non-Windows form) window handle.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.
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.
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);
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center