5
工作,我想畫一樣的三角形上時,下面的圖片,使多重採樣: 多重採樣不以獨佔方式
我找到了一種方法做SlimDX在another question,但它不工作在獨家模式。
這裏是我的代碼:
void Form1_Load(object sender, EventArgs e)
{
Direct3D d3d = new Direct3D();
PresentParameters presentParams;
presentParams.Windowed = false;
presentParams.BackBufferFormat = Format.X8R8G8B8;
presentParams.BackBufferWidth = 800;
presentParams.BackBufferHeight = 600;
presentParams.FullScreenRefreshRateInHertz = 60;
presentParams.SwapEffect = SwapEffect.Copy;
presentParams.BackBufferCount = 1;
presentParams.PresentationInterval = PresentInterval.One;
int multisampleQuality;
Result result;
if (d3d.CheckDeviceMultisampleType(adaptor, DeviceType.Hardware, Format.X8R8G8B8, false, MultisampleType.FourSamples, out multisampleQuality, out result))
{
if(multisampleQuality > 4)
{
presentParams.Multisample = multisampleType;
presentParams.MultisampleQuality = 4;
}
}
// Device creation
Device device = new Device(d3d, adaptor, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, presentParams);
}
最後一行送花兒給人以 D3DERR_INVALIDCALL錯誤crashs即使CheckDeviceMultisampleType回報沒有錯誤multisampleQuality總是正確和8。
它適用於如果我使用窗口模式或如果我刪除multisample選項。
有人可以告訴我什麼是錯?
它的工作原理就像一個魅力!非常感謝:) –
嗨@catflier!你有解釋嗎?我意識到,實際上我確實需要將此參數設置爲* SwapEffect.Copy * ... –
@tinmaru:是的,有一些原因讓你無法做到這一點,主要是因爲swapeffect.copy需要每像素複製像素,所以它不適用於msaa(因爲你有子像素樣本)。此外,爲什麼你需要SwapEffect.Copy?放棄標準很重要 – catflier