A bit of a disclaimer first: I’ve been waiting for version 3.2 first before attempting to really start dabbling in it on account of the introduction of its cross platform content pipeline. I am also the monogame and opentk packages maintainer for Arch Linux, if by chance I’ve built either package incorrectly and that is causing the problem.
I first tested the waters of MG 3.2 by making a simple application that loads an XNB file of a 640x480 graphic into what’s supposed to be window of the same resolution. However, upon running it, the program seems to resize the window’s width and have a big blank space to the right of the graphic. I disabled full screen, set the preferred backbuffer properties in Initialize(), but to no avail. Console.WriteLine() statements for both the preferred backbuffer width/height and GameWindow client bounds width/height both show 640x480. Additionally, if I go ahead and change preferred backbuffer to something like 1024x768, that works just fine. It just seems like MG despises 640x480 resolution somehow.
Tested/compiled on Arch Linux 64-bit with Mono 3.2.8, OpenTK 1.1.1 and MonoGame 3.2 with MonoDevelop 4.2.2. Here is a code snippet of my Game1.cs:
#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Input;
#endregion
namespace test
{
/// <summary>
/// This is the main type for your game
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D logo;
public Game1 ()
{
graphics = new GraphicsDeviceManager (this);
Content.RootDirectory = "Content";
graphics.IsFullScreen = false;
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize ()
{
graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 480;
graphics.ApplyChanges ();
// TODO: Add your initialization logic here
base.Initialize ();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent ()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch (GraphicsDevice);
//TODO: use this.Content to load your game content here
logo = Content.Load<Texture2D> ("ROTPLogo");
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update (GameTime gameTime)
{
// For Mobile devices, this logic will close the Game when the Back button is pressed
if (GamePad.GetState (PlayerIndex.One).Buttons.Back == ButtonState.Pressed) {
Exit ();
}
// TODO: Add your update logic here
base.Update (gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw (GameTime gameTime)
{
graphics.GraphicsDevice.Clear (Color.White);
//TODO: Add your drawing code here
spriteBatch.Begin ();
spriteBatch.Draw (logo, Vector2.Zero, Color.White);
spriteBatch.End ();
base.Draw (gameTime);
}
}
}