我想在绘制三角形时启用多重采样,如下图所示:
我在另一个问题中找到了一种使用SlimDX的方法,但它在独占模式下不起作用。
这是我的代码:
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错误而崩溃,即使CheckDeviceMultisampleType始终返回 true 且没有错误并且multisampleQuality返回 8 。
如果我使用窗口模式或删除多重采样选项,它会起作用。
有人可以告诉我有什么问题吗?