Changing multisampling within the MDX frameworkHi,

Hi,

I'm using C# and the Managed DirectX framework for a 3D graphics engine. Now I want to give the user the option to change the multisampling of the rendering while the program is running. So when a key is pressed, the following code is executed in the key event handler:


DeviceSettings oldDeviceSettings = framework.DeviceSettings.Clone();
DeviceSettings newDeviceSettings = framework.DeviceSettings.Clone();
try
{
newDeviceSettings.presentParams.MultiSampleType = MultiSampleType.TwoSamples;
newDeviceSettings.presentParams.SwapEffect = SwapEffect.Discard;
framework.CreateDeviceFromSettings(newDeviceSettings);
}
catch (Exception e)
{
framework.CreateDeviceFromSettings(oldDeviceSettings);
}

Now imagine the following scenario: In windowed mode, the main form is at a small size. The user switches multisampling on, the device will be created and everything works fine... until the user decides to resize manually the form. If the form becomes too large then, an OutOfVideoMemoryException occurs and the program terminates. It seems that after a resize of the window, the framework tries to recreate a device with the current settings and terminates with an exception if that does not work. The problem is that, since multisampling worked before (when the window was at a smaller size), the framework does not attempt to create a device from other settings. I noticed the same kind of behaviour when running the 'AnitAlias' sample from the DirectX SDK.

My question now is: Is it possible to tell the framework that - if a setting that has been working before and does not work anymore - it should try other settings, e.g. switch from multisampling automatically to no multisampling Or is this a limitation of the framework

Thanks in advance,
Christopher


Answer this question

Changing multisampling within the MDX frameworkHi,

  • Changing multisampling within the MDX frameworkHi,