我想画的三角形就像在下面的图片时启用多重采样:
我找到了一种方法做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);
}
最后一行送花儿给人以错误crashs即使CheckDeviceMultisampleType总是返回真值与multisampleQuality没有错误和8。
它的工作原理,如果我使用窗口模式,或者如果我删除多重采样选项。
谁能告诉我有什么不对?