问题
I would like to enable multisampling when drawing triangles like on the following picture:
I found a way to do with SlimDX in another question but it doesn't work in exclusive mode.
Here is my code:
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);
}
The last line alway crashs with a D3DERR_INVALIDCALL error even if the CheckDeviceMultisampleType return always true with no error and 8 for multisampleQuality.
It works if I use the windowed mode or if I remove the multisample option.
Can someone tell me what's wrong?
回答1:
Try with
presentParams.SwapEffect = SwapEffect.Discard;
来源:https://stackoverflow.com/questions/12899885/multisampling-doesnt-work-in-exclusive-mode