Platform SDK: DirectX

Step 2.1: Retrieve the Device

[C++]

This section pertains only to application development in Visual Basic. See Direct3D Immediate Mode C/C++ Tutorials.

[Visual Basic]

Before you can test a device, you must retrieve the device that you want to test. The following section explains how to retrieve the current display settings and how to retrieve a device reference, so that you can test the device for all of its supported display settings.

The Enumeration sample uses the DirectDraw7.GetDisplayMode method to retrieve the current display mode information in a DDSURFACEDESC2 type:

    g_dd.GetDisplayMode desc
    currMode = desc.ddpfPixelFormat.lRGBBitCount

The preceding code saves the bits per pixel setting of the current display in currMode. Then, the Enumeration sample adds the current display mode to a combo box, cmbMode, that is displayed to the user:

    cmbMode.Clear
    cmbMode.AddItem Str(currMode) + "-bit Display Window"

Now, to retrieve the device that you want to test, determine which device has been selected by the user in the combo box, cmbDevice, by using the Direct3DEnumDevices.GetDesc method:

 Call g_d3dEnumDevices.GetDesc(cmbDevice.ListIndex + 1, deviceDesc)

In the preceding code, a DDSURFACEDESC2 type, deviceDesc, is used to hold surface description information for the device that you want to test. This is the device that you will use to build a list of supported display modes. Ultimately, you will place these supported display modes into a combo box, so that the user can choose the display mode for the Enumeration application.

Note  The design and structure of the graphical user interface (GUI) of the Enumeration application is not discussed in this tutorial. To gain an understanding of how the code samples in the Using Device Enumeration tutorial interact with the GUI, you should consult the complete Enumeration application code in the SDK.

Now that you have a reference to the device that you want to test, you can test the device. This step is explained in Step 2.2: Test the Device.