DirectX SDK |
The information in this section pertains only to applications written in C and C++. See Direct3D Immediate Mode Visual Basic Tutorials.
The IDirectDraw7::EnumDisplayModes method enumerates all of the display modes that the hardware exposes through the DirectDraw object. The Enumeration application calls the EnumDisplayModes function with the following parameters:
// Enumerate the fullscreen display modes. pDD->EnumDisplayModes( 0, NULL, &d3dDeviceInfo, ModeEnumCallback );
The NULL argument specifies that all modes should be enumerated. The third parameter, &d3dDeviceInfo, is the address of the D3DDEVICEINFO structure containing driver information, which is passed to each enumeration member. The fourth parameter is the address of an EnumModesCallback2 callback function, ModeEnumCallback, that the enumeration procedure will call for every mode that the hardware exposes:
static HRESULT WINAPI ModeEnumCallback( DDSURFACEDESC2* pddsd, VOID* pParentInfo ) { // Copy the mode into the driver's list of supported modes D3DDEVICEINFO* pDriverInfo = (D3DDEVICEINFO*)pParentInfo; pDriverInfo->ddsdModes[pDriverInfo->dwNumModes++] = (*pddsd); return DDENUMRET_OK; }
In the preceding code, the first parameter, pddsd, is a read-only DDSURFACEDESC2 structure that contains information on the display mode that can be created. The pParentInfo parameter (application-defined data representing the display driver) is cast to a D3DDEVICEINFO structure, so that it can be safely referenced. After all of the display modes have been enumerated, you are ready to enumerate the Direct3D devices. This step is explained in Step 1.3: Enumerate Device Information.