End of an Era, Start of a new One

Microsoft Xbox 360

It was announced that Microsoft is no longer producing the Xbox 360 console. It was a great console and still has a lot of life in it. Of course, I have two different ones, but I rarely use one and the other is so I can stream Netflix. (Not a smart TV, in fact, it is a big ole CRT thing – well big as in depth, not viewing area.)

Since many of the 360 games I bought and haven’t played yet are coming to Xbox One Backwards Compatibility list, I’ll have fewer reasons to turn on the 360. Still, there are some games, like Batman Arkham Origins and Assassins Creed Rouge that I just recently played that were only available on the 360.

The 360 will always have a special place in my heart, because that was the first console I was able to deploy (and debug) a game to. This was basically unheard of before XNA came out.

Now with MonoGame, anyone who wrote code using XNA, can have that game live on in the new world on Windows 10. This includes on HoloLens. Here Microsoft is shipping it’s first holographic computer and thanks to the open source project, and in particular, Tom Spilman, XNA code will run on the HoloLens.

 

The Xbox 360 turned 10 years old in November 2015. It still has life in it and support for the console will continue for at least another 3 years.  I loved the 360, I love my Xbox One and I know I’m going to love my HoloLens. It is supposed to arrive tomorrow!

Oh, by the way, I’m hoping to send the updated XNA Game Studio 3.0 Unleashed code to GitHub tomorrow.  Will that mean two posts in a row? Only time will tell…

Updating PixelShaders from ps_1_0 to ps_4_0 and a Warning

As I’m going through and updating the code I ran into a following snag that took me a bit to figure out. In this case, I only had a Pixel Shader and no Vertex Shader. The shader worked just fine back in the day, but during the upgrade I was told that MonoGame only supported ps_4_0 and this shader was version 1.0 (ps_1_0).  Simply changing the version number in the shader file fixed that.

But then I had a bug where the shader wasn’t giving me the results I wanted.

After poking around a little bit, I finally found out that the method signature needs to explicitly have all of the parameters.  I found this information here:

http://www.software7.com/blog/pitfalls-when-developing-hlsl-shader/

 

The way my pixel shader looked original was:

 

sampler TextureSampler;

struct PixelInput
{
    float2 TexCoord : TEXCOORD0;   
};

float4 pixelShader(PixelInput input) : COLOR
{
    float4 color = tex2D( TextureSampler, input.TexCoord);
    return( color );
}

technique Default
{
    pass P0
    {
        PixelShader = compile ps_1_1 pixelShader();
    }
}

 

And I had to change it to:

sampler TextureSampler;

struct PixelInput
{
    float4 Pos : SV_POSITION;
    float4 Color : COLOR0;
    float2 TexCoord : TEXCOORD0;
};

float4 pixelShader(PixelInput input) : SV_TARGET0
{
    float4 color = tex2D( TextureSampler, input.TexCoord);
    return( color );
}

technique Default
{
    pass P0
    {
        PixelShader = compile ps_4_0 pixelShader();
    }
}

 

Once I made that small tweak (added in the different parameters (albeit through a struct)) it worked like a charm. A struct doesn’t have to be used, but the parameters should be in the right order it seems – position, then color, then texture coordinates.

 

Note, that this pixel shader doesn’t do anything but return the pixel of the texture passed to it.  Typically you would do some math on the color before returning it. Check out Chapter 15, under SimpleGame for some different pixel shader examples when I update the code to GitHub. (Before the end of the month…)

 

So make sure that your pixel shader parameters are all present and associated with the right semantics!

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

Build 2016 and more HoloLens Goodness

Really enjoying Build 2016 so far!  The keynote yesterday was fantastic. They are SHIPPING HoloLens!

You can watch the announcement here:

https://channel9.msdn.com/Events/Build/2016/KEY01#time=1h06m39s

The Galaxy program looks like it is going to be a great app to learn from.

 

If you haven’t checked out the official HoloLens channel on YouTube, do that. In fact, here are some great videos:

 

Actiongram

 

HoloStudio

 

Fragments (a mystery game)

 

RoboRaid

 

If you can get a HoloLens, do so. I’ll be grabbing one as soon as I get an email from Microsoft saying it is ready.

 

On your mark, get set, go…