Question

I would like to enable antialiasing when drawing triangles like on the following picture: enter image description here

I found a way to do it with XNA on this page but I want to do the same with SlimDX.

Was it helpful?

Solution

On SlimDX/Directx9, when you create your swapchain, use this in PresentParameters:

Multisample = MultisampleType.FourSamples,
MultisampleQuality = 4

Also make sure that the multisample state is on (By default it is, but never sure):

device.SetRenderState(RenderState.MultisampleAntialias, true);

There's of course different type of samples, to find quality/samples, use the following method:

new Direct3D().CheckDeviceMultisampleType

On dx10+ device, when you create your swapchain, you have a SampleDescription parameter,

so set samples count/quality accordingly

SampleDescription samdesc = new SampleDescription(4, 4);

To enumerate allowed samplecount/quality combinations:

int maxsamplecount = Device.MultisampleCountMaximum

Then iterate for sample count using:

int maxquality = device.CheckMultisampleQualityLevels(format, sampleCount);

It will return 0 if sample count is not supported.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top