{"id":385,"date":"2014-07-31T15:34:27","date_gmt":"2014-07-31T15:34:27","guid":{"rendered":"http:\/\/www.coolbasic.com\/blog\/?p=385"},"modified":"2014-07-31T15:34:27","modified_gmt":"2014-07-31T15:34:27","slug":"thoughts-about-monogame","status":"publish","type":"post","link":"https:\/\/www.coolbasic.com\/blog\/2014\/07\/31\/thoughts-about-monogame\/","title":{"rendered":"Thoughts about MonoGame"},"content":{"rendered":"<p>I\u2019ve been toying with this idea of using <a href=\"http:\/\/www.monogame.net\" title=\"MonoGame\">MonoGame<\/a> 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\u2019s based on XNA\u2019s design there\u2019s a lot of material already on the web so it has the potential to boost development productivity a great deal. Sounds good, right?<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.coolbasic.com\/common\/images\/archives\/2014\/07\/MonoGameLogo100px.png\" alt=\"MonoGame logo\" \/><\/p>\n<p>I\u2019m 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\u2019d create a cross-platform solution with OS specific setup code. For the most part, the only thing that\u2019s 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.<\/p>\n<p>So how to get started with this cross-platform project? It turns out that the MonoGame dev team have some plans for <a href=\"https:\/\/github.com\/Mono-Game\/MonoGame.Samples\" title=\"MonoGame.Samples - GitHub\">providing a set of official samples<\/a> 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\u2026<\/p>\n<p>First of all, the Nuget package configuration is broken due to some versioning issues. I couldn\u2019t solve this with the graphical Nuget package manager in Visual Studio, and had to manually install the package from the PM command line instead.<\/p>\n<p>Secondly, the Visual Studio solution doesn\u2019t 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\u2019s present in the downloadable though, but when I attempted to add it to the solution it\u2019d just fail at loading because of an \u201cunknown project type\u201d. After some googling I learn that apparently MonoGame doesn\u2019t have the <em>Content pipeline<\/em> 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\u2019t create them without the real XNA1. This gave me an important clue &#8211; could the unrecognized Content project type be the real XNA content project\u2026<\/p>\n<p>XNA cannot be installed into Visual Studio 2013 directly, but luckily there\u2019s a <a href=\"https:\/\/msxna.codeplex.com\/releases\/view\/117230\" title=\"XNA 4.0 Refresh (Visual Studio 2013)\">workaround<\/a>. Once installed, indeed I was able to add the Content project to the solution (you\u2019ll have to manually create a solution folder named \u201cContent\u201d and import it there). I now have 1) the game project, 2) the game\u2019s content project, and 3) the XNA content builder project. Then you can compile and run the example!<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.coolbasic.com\/common\/images\/archives\/2014\/07\/MonoGame_Platformer2D_Sample.png\" alt=\"MonoGame sample game - Platformer 2D\" \/><\/p>\n<p>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\u2019t 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\u2026 moreover why is it even using OpenAL on Windows where DirectSound is available? <\/p>\n<p>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 <code>DivideByZeroException<\/code> 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.<\/p>\n<p>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 <a href=\"http:\/\/www.monogame.net\/documentation\/?page=Pipeline\" title=\"MonoGame Content pipeline tool\">standalone application<\/a>. The documentation states that it should come with the SDK, but it\u2019s 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\u2019t contain the full source code for it (for example, there\u2019s no project file). <\/p>\n<p>Finally I found the pipeline tool by installing the latest daily build from their <a href=\"http:\/\/teamcity.monogame.net\/viewLog.html?buildTypeId=MonoGame_DevelopWin&#038;buildId=lastSuccessful&#038;tab=artifacts&#038;buildBranch=%3Cdefault%3E\" title=\"MonoGame TeamCity\">TeamCity site<\/a> (login as quest to view it). For whatever reason it\u2019s installed into MSBuild under Program Files.<\/p>\n<p>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\u2019t 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 &#8211; who knows how many other issues like these there will be &#8211; especially when Linux or OSX enters the picture.<\/p>\n<p>I\u2019m not so sure anymore about the idea of enhanced productivity when working with MonoGame if I\u2019m 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\u2019m not really confident about its reliability and fitness for serious production use. For Windows I can always build the engine (more optimized even) with <a href=\"http:\/\/sharpdx.org\/\" title=\"SharpDX\">SharpDX<\/a>. Maybe for other OS\u2019 I\u2019d fall back to MonoGame, when it\u2019s hopefully in a more polished state.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ve 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\u2019s based on XNA\u2019s design there\u2019s a lot of material already on the web so [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/posts\/385"}],"collection":[{"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":2,"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"predecessor-version":[{"id":387,"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/posts\/385\/revisions\/387"}],"wp:attachment":[{"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coolbasic.com\/blog\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}