I am working on a monogame project. When I started trying to test it on alternative resolutions, I encountered an odd issue. The game does not render properly to fullscreen on resolutions besides 1920 X 1080.
Here is the code I am testing with:
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, this works fine. It renders the image covering the entire screen, as expected. However, when I change the resolution to other values (I have tried 1280 X 720, 800 X 600, and 1600 X 900, for testing's sake) it renders to a rectangle in the center of the screen, rather than rendering over the entire screen. I have checked the values of Viewport.Bounds at runtime, and it is showing the same values as the resolution I set. What is going on here?