Microsoft DirectX 8.0 (Visual Basic)

Direct3D8.CheckDepthStencilMatch

Determines whether a surface format is available as a specified resource type and can be used as a texture, depth-stencil buffer, or render target, or any combination of the three, on a device representing this adapter.

object.CheckDepthStencilMatch( _ 
    Adapter As Long, _ 
    DeviceType As  CONST_D3DDEVTYPE, _ 
    AdapterFormat As CONST_D3DFORMAT, _ 
    RenderTargetFormat As CONST_D3DFORMAT, _ 
    DepthStencilFormat As CONST_D3DFORMAT) As Long

Parts

object
Object expression that resolves to a Direct3D8 object.
Adapter
Ordinal number denoting the display adapter to query. D3DADAPTER_DEFAULT is always the primary display adapter.
DeviceType
Member of the CONST_D3DDEVTYPE enumeration identifying the device type.
AdapterFormat
Member of the CONST_D3DFORMAT enumeration, identifying the format of the display mode into which the adapter will be placed.
RenderTargetFormat
Member of the CONST_D3DFORMAT enumeration, identifying the format of the render target surface to be tested.
DepthStencilFormat
Member of the CONST_D3DFORMAT enumeration, identifying the format of the depth-stencil surface to be tested.

Return Values

If the depth-stencil format is compatible with the render target format in the display mode, this method returns D3D_OK.

D3DERR_INVALIDCALL can be returned if one or more of the parameters is invalid. If a depth-stencil format is not compatible with the render target in the display mode, then this method returns D3DERR_NOTAVAILABLE.

Error Codes

Err.Number is not set for this method.

Remarks

This method is provided to allow applications to work with hardware requiring that certain depth formats can only work with certain render target formats. The following code fragment shows how you could use CheckDeviceFormat to validate a depth stencil format.

Function IsDepthFormatOK( DepthFormat As CONST_D3DFORMAT, AdapterFormat As CONST_D3DFORMAT, _ 
                          BackBufferFormat As CONST_D3DFORMAT) as Boolean

      Dim check As Long

      check = d3d.CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, AdapterFormat, _ 
                                    D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, DepthFormat)
      If (check < 0) Then Exit Function   'Returns False

      check = d3d.CheckDepthStencilFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, AdapterFormat, _ 
                          RenderTargetFormat, DepthFormat)
      If (check < 0) Then
         IsDepthStencilFormatOK = False
      Else
         IsDepthStencilFormatOK = True
      End If

End function

The preceding call returns False if DepthFormat cannot be used in conjunction with AdapterFormat and BackBufferFormat.