Determining Whether a Hardware Device Is Available

The manager class has a multitude of functions that can be used to determine the support your adapter has for a particular feature. For example, if you wanted to determine whether or not your device supported a particular format, and didn't want to enumerate all possible adapters and formats, you could use the manager class to make this determination. The following function can be used:

 public static System.Boolean CheckDeviceType ( System.Int32 adapter ,   Microsoft.DirectX.Direct3D.DeviceType checkType ,   Microsoft.DirectX.Direct3D.Format displayFormat ,   Microsoft.DirectX.Direct3D.Format backBufferFormat ,   System.Boolean windowed , System.Int32 result ) 

This can be used to determine quickly whether your device supports the type of format you wish to use. The first parameter is the adapter ordinal you are checking against. The second is the type of device you are checking, but this will invariably be DeviceType.Hardware the majority of the time. Finally, you specify the back buffer and display formats, and whether or not you want to run in windowed or full screen mode. The final parameter is optional, and if used, will return the integer code (HRESULT in COM) of the function. The method will return true if this is a valid device type, and false otherwise.

DETECTING FORMAT CONVERSION

It's important to note that in windowed mode, the back buffer format does not need to match the display mode format if the hardware can support the appropriate color conversion. While the CheckDeviceType method will return appropriate results regardless of whether or not this support is available, you can also use the CheckDeviceFormat Conversion method off of the Manager class to detect this ability directly. Full-screen applications cannot do color conversion at all. You may also use Format.Unknown in windowed mode.

This is quite useful if you know beforehand the only types of formats you will support. There isn't much of a need to enumerate through every possible permutation of device types and formats if you already know what you need.



Managed DirectX 9 Graphics and Game Programming, Kick Start
Managed DirectX 9 Kick Start: Graphics and Game Programming
ISBN: B003D7JUW6
EAN: N/A
Year: 2002
Pages: 180
Authors: Tom Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net