Enabling antialising in SlimDX (D3D9)

二次信任 提交于 2019-12-08 13:43:05

问题


I would like to enable antialiasing when drawing triangles like on the following picture:

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


回答1:


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.



来源:https://stackoverflow.com/questions/12351424/enabling-antialising-in-slimdx-d3d9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!