如何使用Managed Direct3D检查32位z缓冲区?

时间:2010-02-05 10:53:14

标签: .net directx c++-cli direct3d managed-directx

我理解拨打Manager::CheckDepthStencilMatch的电话会给我一个答案,但到目前为止,我还是无法收集有效拨打电话所需的电话。

特别是,我需要获取adapterFormatrenderTargetFormat参数的值。我没有在创建设备时指定任何特定格式,因此我需要一种方法来获取默认/当前“格式”值。

1 个答案:

答案 0 :(得分:1)

-

D3D::DepthFormat GetDepthFormat(){
    D3D::AdapterInformation ^adapter = D3D::Manager::Adapters->Default;
    D3D::DepthFormat depthFormat = D3D::DepthFormat::D32;
    if(!D3D::Manager::CheckDepthStencilMatch(0,
        D3D::DeviceType::Hardware, adapter->CurrentDisplayMode.Format,
        adapter->CurrentDisplayMode.Format, depthFormat)){

        depthFormat = D3D::DepthFormat::D16;
        if(!D3D::Manager::CheckDepthStencilMatch(0,
            D3D::DeviceType::Hardware, adapter->CurrentDisplayMode.Format,
            adapter->CurrentDisplayMode.Format, depthFormat)){

            throw gcnew Exception(L"Your hardware needs to be upgraded.");
        }
    }

    return depthFormat;
}