Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on a game which consists of 3D elements and a 2D GUI. I have it working properly, but I want to enable multisampling for only the 3D parts, and not the 2D Textures. Otherwise, the GUI icons become blurred.

Here is the code for my Draw method

    protected override void Draw(GameTime gameTime)
        graphics.PreferMultiSampling = true;


        GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
        GraphicsDevice.DepthStencilState = DepthStencilState.Default;

        foreach (Element e in Elements)// 3D part
            e.Draw(GraphicsDevice, camera);

        graphics.PreferMultiSampling = false;

        UIM.Draw(GraphicsDevice, spriteBatch);


Using this code, I get an exception because all of my Texture2Ds dispose for some reason.

Is there a way to change the MultiSampling in the middle of the Draw method?

share|improve this question
Screenshots would be helpful, I think. – Andrew Russell Aug 18 '12 at 9:42
up vote 1 down vote accepted

Multisampling is a property of the backbuffer. So: no, you cannot change it mid-draw.

Where you call ApplyChanges you're causing the graphics device to get torn down - you should never call this during Draw.

One thing you could do is render your UI to a render target without multisampling. Or alternately render your 3D geometry to a render target with multisampling (and disable multisampling for your backbuffer).

Note the preferredMultiSampleCount parameter to RenderTarget2D's constructor (MSDN).

It's worth pointing out that mutlisampling (as opposed to super-sampling with a linear texture filter) shouldn't cause your sprites to become blurry - because it only affects the edges of polygons - not their textures! (details here).

It's possible that you've got a sub-pixel alignment problem. On that note, it might be interesting to pass SamplerState.PointClamp to SpriteBatch.Begin and see what happens.

share|improve this answer
Thanks for the help, I used a render target for the 3D portion of the Draw method and the multisampling only affects that, not my sprites. – annonymously Aug 18 '12 at 16:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.