Thoughts about MonoGame

I’ve been toying with this idea of using MonoGame for the new CoolBasic for quite some time now. In theory it would offer many benefits such as the ability to build cross-platform game engines with minimal code changes. And since it’s based on XNA’s design there’s a lot of material already on the web so it has the potential to boost development productivity a great deal. Sounds good, right?

MonoGame logo

I’m already rather familiar with XNA so I was tempted to just get started with the default Windows project template. But I wanted to see how you’d create a cross-platform solution with OS specific setup code. For the most part, the only thing that’s different for each OS is the way you construct the game window; after that you just instantiate the game class and the rest is in common across all platforms.

So how to get started with this cross-platform project? It turns out that the MonoGame dev team have some plans for providing a set of official samples that, according to their words, should compile against all of the supported platforms (Android, Linux, OSX, Ouya, PSM, Windows, Windows Store, and Windows Phone). This should be the perfect reference material how I should build my Visual Studio solution. It even appears to be using the MonoGame Nuget package so surely I could just download it, open it, and be able to compile it with no additional setup? Well, not exactly…

First of all, the Nuget package configuration is broken due to some versioning issues. I couldn’t solve this with the graphical Nuget package manager in Visual Studio, and had to manually install the package from the PM command line instead.

Secondly, the Visual Studio solution doesn’t include all the needed projects! As it turned out, the entire Content project (where you have your assets such as textures, sounds and fonts) is missing. It’s present in the downloadable though, but when I attempted to add it to the solution it’d just fail at loading because of an “unknown project type”. After some googling I learn that apparently MonoGame doesn’t have the Content pipeline fully implemented yet. MonoGame is at version 3.2, how on earth a feature this essential is still missing? Maybe you can load compiled .xnb assets and use them in game, but you can’t create them without the real XNA1. This gave me an important clue – could the unrecognized Content project type be the real XNA content project…

XNA cannot be installed into Visual Studio 2013 directly, but luckily there’s a workaround. Once installed, indeed I was able to add the Content project to the solution (you’ll have to manually create a solution folder named “Content” and import it there). I now have 1) the game project, 2) the game’s content project, and 3) the XNA content builder project. Then you can compile and run the example!

MonoGame sample game - Platformer 2D

The sample game is a simple 2D platformer where you can move left/right and jump. Except the game crashes if you jump. The reason was that MonoGame couldn’t find OpenAl.dll that is used for playing the jumping sound. This DLL is nowhere to be found within the downloaded package. I guess someone forgot to include the dependencies… moreover why is it even using OpenAL on Windows where DirectSound is available?

So I downloaded OpenAL and put the DLL in the output directory, then ran the game again. And it still crashes at playing the jump sound, this time due to some shady DivideByZeroException that originates from deep within OpenAL, completely out of my reach to debug or fix. The problem could be literally anywhere; maybe the sound is invalid? Did the content builder generate a valid xnb file? Did MonoGame load it correctly? Does OpenTK (yes, this is also included) do something with it before it ends up to OpenAL? Do I have the right version of OpenAL (since I had to separately download it)? I ended up commenting out all code that attempted playing sound. The game worked flawlessly after that.

This content building thing concerns me. If the primary way to loading game assets is via the content pipeline then there should be a fully working *official* way to compile the files into the xnb format. There are 3rd party tools, but if I was to use this for production, I really need the officially supported one. After some digging, it appears to be that one such tool is currently in development as a standalone application. The documentation states that it should come with the SDK, but it’s not there. So I downloaded the latest MonoGame source from GitHub in the hopes of being able to execute it from Visual Studio. Except that it doesn’t contain the full source code for it (for example, there’s no project file).

Finally I found the pipeline tool by installing the latest daily build from their TeamCity site (login as quest to view it). For whatever reason it’s installed into MSBuild under Program Files.

First impressions? Not very positive. I had to manually reconstruct the Visual Studio solution, adding and configuring the missing projects. Tools are missing or incomplete. Samples don’t build due to incomplete configuration and missing dependencies. Completely broken source code. Everything just seems so unfinished and unstable at the moment. And I merely touched the surface – who knows how many other issues like these there will be – especially when Linux or OSX enters the picture.

I’m not so sure anymore about the idea of enhanced productivity when working with MonoGame if I’m encountering bugs and unimplemented things like these right at the start. It may very well be that I end up wasting more time hunting weird MonoGame specific bugs than just use the real XNA (that just works). All in all, I was surprised how immature MonoGame still is, and I’m not really confident about its reliability and fitness for serious production use. For Windows I can always build the engine (more optimized even) with SharpDX. Maybe for other OS’ I’d fall back to MonoGame, when it’s hopefully in a more polished state.

Comments are closed.

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress