Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multisampling doesn't work in exclusive mode

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

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?

like image 849
Martin Delille Avatar asked Nov 12 '22 20:11

Martin Delille


1 Answers

Try with

 presentParams.SwapEffect = SwapEffect.Discard;
like image 76
mrvux Avatar answered Nov 15 '22 09:11

mrvux