Microsoft DirectX 8.0 (Visual Basic)

Detecting Support for Bump Mapping

A Microsoft® Direct3D® device can perform bump mapping if it supports either the D3DTOP_BUMPENVMAP or D3DTOP_BUMPENVMAPLUMINANCE texture blending operation. Additionally, applications should check the device capabilities to make sure the device supports an appropriate number of blending stages, usually at least three, and exposes at least one bump mapping pixel format.

The following code checks device capabilities to detect support for bump mapping in the current device, using the given criteria.

Function SupportsBumpMapping As Bool
{
    Dim d3dCaps As D3DCAPS8

    m_D3DDevice.GetDeviceCaps d3dCaps

    ' Does this device support the two bump mapping blend operations?
    If ( d3dCaps.TextureOpsCaps And _
         ( D3DTEXOPCAPS_BUMPENVMAP Or D3DTEXOPCAPS_BUMPENVMAPLUMINANCE ) = 0) Then
         SupportBumpMapping = FALSE
    End If

    // Does this device support up to three blending stages?
    If d3dCaps.MaxTextureBlendStages < 3 Then
        SupportBumpMapping = FALSE
    End If

    SupportBumpMapping = TRUE
}