I’ve implemented MultiSampling on my XNA game, it works great on my Desktop. When I run the game in HighDefinition mode on the XBox360, I get an OOM exception. If I don’t enable MultiSampling, the game runs fine, but models are not anti-aliased and look terrible.
The following chunk of code seems to be the culprit.
void _graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e) { e.GraphicsDeviceInformation.PresentationParameters.MultiSampleType = MultiSampleType.TwoSamples; } protected override void Initialize() { // TODO: Add your initialization logic here graphics.PreferMultiSampling = true; graphics.PreferredBackBufferHeight = 720; graphics.PreferredBackBufferWidth = 1280; graphics.PreparingDeviceSettings += _graphics_PreparingDeviceSettings; graphics.ApplyChanges(); base.Initialize(); }
will cause an OOM exception.
My primary goal is to get the models to look decent (anti-aliased) and MultiSampling seems like the right approach. I’m fairly new to this, so if anyone can point me in the right direction, I would appreciate it.
I think if you just move the code from initialize into the constructor and remove the call to graphics.ApplyChanges(…) your problems should go away.
The article posted by Venesectrix states that ApplyChanges(…) is sort of a no-no for XBOX360.
Therefore you need to make all those GraphicsDevice settings before the device is ever built. This is accomplished by setting it up in the constructor. In this case, there is no need to call ApplyChanges().
By the time Initalize() is called the device has already been built. Calling ApplyChanges causes a reset and again fires the event to Prepare Device Settings. If I’m not mistaken, device resets with regard to XNA aren’t really supported on 360 and will barf.
Hope this helps, let me know.
-Jeff B.