2010-02-05 26 views
1

據我所知,撥打Manager::CheckDepthStencilMatch應該會給我一個答案,但到目前爲止,我還沒有能夠收集有效進行此呼叫所需的部分。如何使用Managed Direct3D檢查32位z緩衝區?

特別是,我需要獲得adapterFormatrenderTargetFormat參數的值。我在創建設備時沒有指定任何特定格式,所以我需要一種獲取默認/當前「格式」值的方式。

+0

是警告你不可能發現,32位深度緩衝。除非你的意思是D32F_LOCKABLE。還是D24X8/D24S8?沒有看到自薩維奇3D以來卡支持D32 ... – Goz 2010-02-05 14:32:34

+0

@Goz,DepthFormat :: D32在我的機器上正常工作。該卡是「VIA/S3G DeltaChrome IGP」。不過,我在這裏使用Managed Direct3D ...可能這是它工作的原因嗎? – 2010-02-11 09:34:20

+0

典型。它是一張「S3」卡,Savage3D是一張S3卡;)不要指望它在nVidia或ATI卡上工作...... – Goz 2010-02-11 10:42:33

回答

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; 
}