多重采样不以独占模式工作

时间:2012-10-15 16:26:43

标签: c# directx slimdx multisampling

我想在绘制三角形时启用多重采样,如下图所示: enter image description here

我找到了another question 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);
}

即使 CheckDeviceMultisampleType 总是返回true而没有错误,并且 multisampleQuality 返回8,最后一行仍然会出现 D3DERR_INVALIDCALL 错误。

如果我使用窗口模式或删除多重采样选项,它会起作用。

有人可以告诉我出了什么问题吗?

1 个答案:

答案 0 :(得分:1)

尝试

 presentParams.SwapEffect = SwapEffect.Discard;