Platform SDK: DirectX |
This section pertains only to application development in Visual Basic. See Direct3D Immediate Mode C/C++ Tutorials.
The following code fragment illustrates a way to determine device capabilities. The Enumeration application uses the following algorithm to choose a supported display mode for the given device:
The Enumeration application executes the following code to implement the algorithm:
For j = 1 To g_ddEnumModes.GetCount() ' We have not tested this display mode yet, so assume it is not compatible. bCompatible = False ' Step 1: g_ddEnumModes.GetItem j, g_enumInfo ' Step 2: modeDepth = g_enumInfo.ddpfPixelFormat.lRGBBitCount ' Step 3: bitDepth = deviceDesc.lDeviceRenderBitDepth ' Step 4: If (32 = modeDepth) And (bitDepth And DDBD_32) Then bCompatible = True If (24 = modeDepth) And (bitDepth And DDBD_24) Then bCompatible = True If (16 = modeDepth) And (bitDepth And DDBD_16) Then bCompatible = True ' Populate the combo box with only the display modes that we want. If bCompatible Then cmbMode.AddItem Str(g_enumInfo.lWidth) + " x" + Str(g_enumInfo.lHeight) + " x" + Str(g_enumInfo.ddpfPixelFormat.lRGBBitCount) End If Next j
After this algorithm completes, the combo box, cmbMode, will hold a list display modes that meet the specified criteria, all other display modes will be ignored.