tags:

views:

137

answers:

2

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.

+1  A: 

I would suggest you take a look at this thread on the XNA forums, especially the first post and the posts starting here. Without seeing the rest of the code you're working on I can't say for sure that this is the problem you are experiencing though, so you'll have to look it over. As the post indicates, enabling multisampling might not be causing the problem directly.

Venesectrix
Unfortunately that didn't do it for me. I created a small test app and the code I put with this post is the only stuff that wasn't created as part of the default template...I must be missing something obvious/stupid...thanks for the info though...
Kevin
I would try JeffB's answer first, but if that doesn't make a difference, which line exactly is it that throws the exception?
Venesectrix
+1  A: 

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.

JeffB
Moving all the changes and configurations to the constructor made all the problems go away! THANK YOU!
Kevin