2
votes

I'm a bit new to XNA, but I'll try and explain my issue as best as I can.

I want to change resolution in-game, by setting the graphics.PreferredBackBufferHeight and graphics.PreferredBackBufferWidth.

By starting off with graphics.PreferredBackBufferWidth set to 1920, and graphics.PreferredBackBufferHeight set to 1080, the game initializes fine.

However, by the press of a button, I want graphics.PreferredBackBufferWidth set to 1280, and graphics.PreferredBackBufferHeight set to 720. (Both resolutions are 16:9)

However, initializing graphics.PreferredBackBufferWidth and graphics.PreferredBackBufferHeight in the Initialize method works fine, as you'd expect. But by changing both values, followed by graphics.ApplyChanges(), OUTSIDE Initialize, the screen either stretches in weird ways, or do not display properly at all.

  • How can I change the BackBuffer Width/Height outside Initialize?
  • Why does it not go the same, if I set these in the Initialize?
  • Do I have to call Initialize again?
1
Can you give more detail on exactly what it's doing? Or even some code for where and how you're doing the change. A screenshot or two would be nice as well. It may not be the change itself but how your drawing your objects - naed21
It really sounds like you are missing a step somewhere, or maybe missing a ApplyChanges. If you can, post some code (I know it's hard to trim down xna code, but please don't post all your code). - gunr2171
Unfortunately my code of use is hard to understand, due to my use of many enums, classes, etc. In the Initialize(), I basically set the graphics.IsFullscreen = true. Later on, in the Update event, it would set the - Johan Svensson
Sorry - I'm a bit new to StackExchange, so apology if I'm hitting Enter, to make a new line, not post the comment. In the Update(), it would re-set the PreferredBackBuffer Width, and Height. Followed by graphics.ApplyChanges(). - Johan Svensson
You know you can always edit your comments/posts. - naed21

1 Answers

0
votes

Based on the conversation with the OP in comments section, it would appear the issue is with setting the graphics to full screen in that it is stretching the screen in order to handle a smaller resolution.