Upgrading My Old XNA Game Studio 3.0 Unleashed Code to run under MonoGame 3.5.1 (using XNA GS 4 APIs)

I’ve started working on upgrading my old XNA Game Studio 3.0 Unleashed book’s code so it will run on the Universal Windows Platform (UWP). I haven’t touched this code since it was created back in 2008/2009, but with the HoloLens coming, I thought it would be good to dust off the code and see what it would take to upgrade.

The reason for doing this is because of a .NET Rocks! podcast.  Richard and Carl interviewed Tom Spilman.  I heard Tom speak at a .NET usergroup in Seattle when I was in town for a conference a few years back. I’ve been impressed with the amount of work he has put into the MonoGame open source project to make it work on Windows.

Still, when I’ve tried to get into MonoGame for Windows 8 I had issue. It wasn’t ready yet, and I didn’t have time to try and fix it, so I went on to use Unity. I don’t regret that decision as Unity is a fantastic tool.

Still, I wanted to go back and look at my XNA code and see if I could get this to run in Windows 10.

Based off my initial results, I’m expecting I’ll have the updated code on GitHub by end of the month…

If you are interested in the original XNA GS 3.0 code, it is hosted on codeplex at:

https://xnags30unleashed.codeplex.com/

 

I’ll create another post when I get it put onto GitHub. I’ll be starting a fresh repo as I don’t believe there would be any benefit of starting with the 3.0 code.

 

Before I started, I had to install MonoGame. You can get the latest from here:

http://www.monogame.net/downloads/

I downloaded MonoGame 3.5.1 for Visual Studio

Here is the steps I am taking to upgrade my old XNA 3.1 code to use the XNA 4.0 API inside of MonoGame 3.5.1

  • Installed MonoGame
  • Create New MonoGame app – picking Windows Universal. I do want this to run on HoloLens after all. 😀
  • Restored NuGet Packages
  • Copy over my content to the Content folder. (including the .contentproj file) (through explorer, if through VS, I don’t include them in the project)
  • Double click on the MonoGame content.mgcb content pipeline file.
  • This brings up the pipeline tool. I then import the .contentproj file.
  • I build and fix any issues. Some .fx files needed to be updated in my case as I was using vs_1_0 and ps_1_0 and MonoGame requires it to be 4_0 and above for both the vertex and pixel shaders.
  • If my Game class (not filename) was called something other than Game1, I opened the Game1 that loaded in the project and renamed it to the name of the game I was converting. I made sure to let Visual Studio do the renaming, so it renamed all the backend code correctly.
  • I then copied all my .cs files from my original project into Visual Studio.
  • If the Game file name was different than Game1.cs, then I deleted Game1.cs – otherwise, I just overwrote it.
  • I then went through the process of updating the XNA 3.1 API to XNA 4.0 API.

I remember there being a cheatsheet for this. Unfortunately, that page no longer works, but thanks to the Way Back Machine, we can still get to it:

http://web.archive.org/web/20130721142204/http://nelxon.com/resources/xna-3-1-to-xna-4-0-cheatsheet.php

 

Also, as usual, Shawn Hargreave’s blog was very helpful in overcoming any API difficulties:

https://blogs.msdn.microsoft.com/shawnhar/2010/04/02/state-objects-in-xna-game-studio-4-0/

 

In fact, here is a video of me upgrading one of the demos here:

Again, I’ll create a post when I actually get done and upload the code to GitHub. Can’t wait for my HoloLens to get here.

 

If you haven’t grabbed the HoloLens tools, make sure you get them:

https://developer.microsoft.com/en-us/windows/holographic/install_the_tools