2015-03-30 40 views
0

我想給用戶在遊戲中選擇MSAA選項。我希望能夠檢查他們的機器可以提供哪些Multisampling選項,並只顯示這些選項。我正在使用的應用程序是在WinForms中構建的;它實際上不是遊戲本身,而是該遊戲的啓動器。如何在C#中使用SlimDX獲得圖形卡的多重採樣功能?

我發現SlimDX.Direct3D11.Device.CheckMultisampleQualityLevels(),但我不知道如何在WinForms中獲得對Direct3D11設備的引用。 https://msdn.microsoft.com/en-us/library/windows/desktop/ff476499%28v=vs.85%29.aspx

回答

1

您需要遍歷所有的低谷可能樣本數量,並檢查至少一個質量等級支持(你需要做的每格式):

SlimDX.Direct3D11.Device device; //your created device 
SlimDX.DXGI.Format format = SlimDX.DXGI.Format.R8G8B8A8_Unorm; //Replace by the format you want to test, this one is very common still 
for (int samplecount = 1; samplecount < SlimDX.Device.MultisampleCountMaximum ; samplecount *= 2) 
{ 
    int levels = device.CheckMultisampleQualityLevels(format, samplecount); 
    if (levels > 0) 
    { 
     //you can use a sampledescription of 
     new SampleDescription(samplecount, /* value between 0 and levels -1 */ 
    } 
    else 
    { 
     // samplecount is not supported for this format 
    } 
}