2

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?
Beryllium
  • 12,808
  • 10
  • 56
  • 86
Johan Svensson
  • 339
  • 5
  • 15
  • 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 Sep 06 '13 at 17:35
  • 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 Sep 06 '13 at 17:39
  • 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 Sep 06 '13 at 17:47
  • 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 Sep 06 '13 at 17:50
  • 2
    You know you can always edit your comments/posts. – naed21 Sep 06 '13 at 18:06
  • Maybe you can find useful this question: http://stackoverflow.com/questions/11283294/how-to-resize-window-using-xna – pinckerman Sep 06 '13 at 19:40

1 Answers1

0

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.

naed21
  • 147
  • 3
  • 9
  • Both 1920x1080 and 1280x720 are 16:9 ratios (multiplied with 1.5). I'm getting horizontal black bars, that takes atleast 50% of the screen. Do I need to re-set the fullscreen boolean? – Johan Svensson Sep 06 '13 at 18:18
  • Are the black bars appearing when you are not drawing anything? And are you using the default spritebatch.Begin()? – naed21 Sep 06 '13 at 19:59
  • Indeed I am using the standard spriteBatch.Begin/Draw.. To clarify, this issue occurs when the game is in FullScreen mode ONLY. `graphics.IsFullscreen` It seems the render window is stretched on it's width, and not it's height, which explains the black bars. – Johan Svensson Sep 06 '13 at 21:01
  • At this point I'm going to have to ask for a code example. Being able to run the same code you are will allow me to visual see the issue and debug the problem. If at all possible, please update your question with your code. – naed21 Sep 09 '13 at 18:26