Fullscreen game not rendering to proper size for resolutions besides 1920 X 1080

When I started trying to test my MonoGame project on alternative resolutions, I encountered an odd issue. The game does not render properly to fullscreen on resolutions besides 1920 X 1080.

I wrote up this test code to investigate:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace MonogameResTest
{
    public class Game1 : Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        Texture2D background;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();

            graphics.PreferredBackBufferWidth = graphics.GraphicsDevice.DisplayMode.Width;
            graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height;

            graphics.IsFullScreen = true;

            graphics.ApplyChanges();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            background = Content.Load<Texture2D>("OnTheWater12");
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            spriteBatch.Draw(
                background,
                graphics.GraphicsDevice.Viewport.Bounds,
                Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}

When I set my computer’s resolution to 1920 X 1080 (native) this code works fine, the texture renders to cover the whole screen.

However, when I set my resolution to other values, the texture renders in a smaller rectangle centered on the screen, as seen here.

Any suggestions on how to solve this?

I think base.Initialize(); should be called after graphics.ApplyChanges();

There are already a lot of discussions about this. And as of now, no clear solution. :confused:

not very reassuring :slight_smile:

I can’t seem to confirm this, is it with larger resolutions (4k?)

My native is 1920x1200 and I’ve tried smaller resolutions like 1680x1050 and 1280x720, both worked.

Maybe it’s part of the other code? (Hardware mode switch)

             _graphics.HardwareModeSwitch = false;
            
            if (GameSettings.IsFullScreen)
            {
                _graphics.IsFullScreen = true;

                _graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                _graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
            }

            else
            {
                _graphics.PreferredBackBufferWidth = GameSettings.ScreenWidthDefault;
                _graphics.PreferredBackBufferHeight = GameSettings.ScreenHeightDefault;
            }

            Window.ClientSizeChanged += ClientChangedWindowSize;

            Activated += IsActivated;
            Deactivated += IsDeactivated;

            Window.AllowUserResizing = true;
            Window.IsBorderless = false;

            _graphics.ApplyChanges();

That is however with borders (not hardwaremodeswitch = true), for proper Fullscreen

public void ToggleFullscreen()
        {
            GameSettings.IsFullScreen = !GameSettings.IsFullScreen;
            if (GameSettings.IsFullScreen)
            {
                _graphics.IsFullScreen = true;

                _graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                _graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

                GameSettings.ClipMouseToScreen = true;

                UpdateMouseBounds();
            }
            else
            {
                _graphics.IsFullScreen = false;
                _graphics.PreferredBackBufferWidth = GameSettings.ScreenWidthDefault;
                _graphics.PreferredBackBufferHeight = GameSettings.ScreenHeightDefault;

                GameSettings.ClipMouseToScreen = false;
            }
            ClientChangedWindowSize(null, null);
            _graphics.ApplyChanges();
        }

I have the same issue as @iWiggins but my smaller RT is rendered top left.(with HardwareModeSwitch)
If I skip HardwareModeSwitch (ie: false), it does not stretch at all.
I have to toggle fullscreen twice to make the 1280x720 effectively fullscreen.
I keep it this way for now, too much work elsewhere on the engine ^^

I did some more tests and found that rendering works fine on the following resolutions:

1400 X 1050
1680 X 1050
1920 X 1080

However, it does not work on these resolutions:

800 X 600
1024 X 786
1152 X 864
1280 X 600
1280 X 720
1280 X 768
1280 X 800
1280 X 960
1280 X 1024
1360 X 768
1366 X 768
1440 X 900
1600 X 900

Am I missing something here? You can set your screen size, or buffer size, to anything you want, and the window will have that size…

I just did a test, again, and I can still run all sorts of resolutions… Gets grainy full-screen mode, as it should when the graphics are up-scaled…

Try fixing your code in the manner Raizam suggested, for starters…

I actually gave up on that once, and just had my game launch a separate app and then exit itself, and the other app would wait for the game to close, and then relaunch it with the new settings, and then close itself :slight_smile: