多重采样不能在独占模式下工作

我想在绘制三角形时启用多重采样,如下图所示: 在此处输入图像描述

我在另一个问题中找到了一种与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错误。

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

有人能告诉我什么是错的吗?

试试吧

  presentParams.SwapEffect = SwapEffect.Discard;