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've got a 2D game that I'm working on that is in a single aspect ratio. When I switch it to fullscreen mode on my widescreen monitor it stretches. I tried using two viewports to give a black background to where the game shouldn't stretch to, but that left the game in the same size as before. I couldn't get it to fill the viewport that was supposed to hold the whole game.

How can I get it to go fullscreen without stretching and without me needing to modify every position and draw statement in the game?

share|improve this question

From: (emphasis mine)

There is a very simple answer to your question: your monitor is a widescreen monitor, if you set a non-widescreen resolution to it, it will have to stretch the output to give you an image. Some graphics adapters and some screens provide a '4:3 in wide' mode which destretches for you.

However if you want your game to always look right and not be stretched you have todo the following:

  • Render to a rendertarget instead of to the screen directly
  • Get the texture from the render target
  • Clear the screen to black
  • Start a spritebatch and render your texture at the correct aspectratio on screen scale it by using an overload that uses the targetRectangle, this way you have automatic black borders either above or on the sides.

This should be be realy easy to implement :)

share|improve this answer
The problem is explained above (Monitors will generally stretch out an image to make it fit in full screen). I however think the easiest solution is to just change your rendering resolution with the adapter to a support full screen resolution. I would imagine that XNA still has the render mode enumerable that you can get that information from. – James Jan 25 '11 at 17:22
Exactly, there isn't an automatic way to do this for 2D -- you need to render on something besides the screen, then render that to the screen. – Nate Jan 27 '11 at 22:51

You can just set your ProjectionMatrix like so:

ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView( MathHelper.PiOver4,
                                                        (float)Game.Window.ClientBounds.Width / (float)Game.Window.ClientBounds.Height,
                                                        3000.0f );

This will set your aspect ratio correctly, in whatever screen you're using.

share|improve this answer
projection matrix? Isn't that just if you're using cameras? My game is only in 2D so I'm not using a camera. – user4873 Jan 25 '11 at 2:29
this answer was really helpful! thanks. – Ashley Grenon Aug 30 '11 at 15:08

Your Answer


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