I’ve been trying to make it so that, in my game, the player can switch between windowed and fullscreen modes. My game has a virtual resolution of 640 x 480, and when fullscreen is activated, the graphics are stretched.
I followed the MonoGame.Extended example code for Camera2D with viewport adapter, as shown here: http://craftworkgames.github.io/MonoGame.Extended/MonoGame.Extended/Camera2D/#_viewportadapter
In my Initialize method, I have this:
In my constructor method, I have this:
graphics = new GraphicsDeviceManager(this);
// Start fullscreen graphics.PreferredBackBufferWidth = 640; // remove later graphics.PreferredBackBufferHeight = 480; // remove later graphics.IsFullScreen = true; // set true to default later graphics.ApplyChanges(); Content.RootDirectory = "Content"; }`
And in my Initialize method, this:
var viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 640, 480); camera = new Camera2D(viewportAdapter);
Then, in my Draw method:
var transformMatrix = camera.GetViewMatrix(); spriteBatch.Begin(transformMatrix: transformMatrix);
But in fullscreen mode, the graphics cover the entire screen and they stretch out.
What am I missing, or what is wrong with my implementation?