DirectX SDK |
This section describes the video mode and surface format queries that can be performed on devices using the Direct3DX utility library functions.
You can query the various video modes supported by a particular device by using the following methods:
The following code cycles through the video modes supported by a device:
dwNumVidModes = D3DXGetMaxNumVideoModes( D3DX_DEFAULT, D3DX_GVM_REFRESHRATE ); D3DX_VIDMODEDESC VidMode; for( i = 0; i<dwNumVidModes; i++ ) { hr = D3DXGetVideoMode( D3DX_DEFAULT, D3DX_GVM_REFRESHRATE, i, &VidMode ); }
The preceding example uses the D3DX_GVM_REFRESHRATE flag to retrieve the refresh rates provided by the display device.
If you want to retrieve the current video mode setting, you can use the following code:
D3DX_VIDMODEDESC CurrVidMode; D3DXGetCurrentVideoMode( D3DX_DEFAULT, &CurrVidMode );
You can query the capabilities of a Direct3DX device by using the D3DXGetDeviceCaps function. The D3DXGetDeviceCaps function returns the Direct3D device capabilities as well as the DirectDraw surface capabilities. Also, the D3DXGetDeviceCaps function takes a D3DX_VIDMODEDESC structure as an input parameter, since many video cards have varying capabilities based on the video mode.
The following code retrieves the device capabilities:
DDCAPS DDHELCaps; DDCAPS DDHALCaps; D3DDEVICEDESC7 D3DCaps; hr = D3DXGetDeviceCaps( D3DX_DEFAULT, NULL, &D3DCaps, &DDHALCaps, &DDHELCaps );
In addition, you can request information about the known surface formats supported by a Direct3DX device for the various surface classes.
The following methods can be used to query the supported surface formats of a Direct3DX device:
The following code cycles through the surface formats supported by a device:
DWORD dwNumSurfaceFormats = D3DXGetMaxSurfaceFormats( D3DX_DEFAULT, NULL, D3DX_SC_COLORTEXTURE); D3DX_SURFACEFORMAT SurfaceFormat; for( i=0; i<dwNumSurfaceFormats; i++ ) { hr = D3DXGetSurfaceFormat( D3DX_DEFAULT, NULL, D3DX_SC_COLORTEXTURE, i, &SurfaceFormat ); }
The preceding example uses the D3DX_SC_COLORTEXTURE flag to specify all the surfaces that have color information in them and can be used for texturing.