Hey, working on my time management, last day before of packing and stuff, tomorrow I am leaving on holiday, not done packing, so obviously I must find time to push out an XNA intro post. Obviously!
From now on I'll be coding in C# and will be relying on XNA (and hopefully a lot of GPU hardware based processing to compensate for the relative slowness of C# whenever possible). Of course I won't be able to just pick up the project where I left of and cut out some of the dwarf related stuff, I need to port over tons of code from C++ with Irrlicht to C# with XNA. Now while Irrlicht has quite a few problems and I have developed a personal grudge against it, that won't stop me from giving praise where praise is due: Irrlicht really does not shit around making you write glue code, lengthy resource and window setup procedures or anything. After a short setup sequence (that you may wish to rewrite and encapsulate in a more reusable component that you can use from project to project), you are free to get down and dirty immediately. And as far as I can tell, XNA maintains this "sit down and code" "no hassle" setup. DirectX, even with DXUT needs a lot of glue code to reduce the hassle. This was the primary reason I couldn't hammer out a to the point base from where to present the real shaders and code I wanted.
So while I am porting my code, I need to find time and present XNA a little for the initiated. You will need a few tools before you get started, but luckily these tools are free. First you will need Visual C# 2010 Express | Microsoft Visual Studio. The free version is not quite as feature rich as the commercial one, but unless you are a pro familiar with the full experience, you won't miss these features. Then you need Microsoft XNA Game Studio 4.0. This will install the required XNA support in Visual C# Express. There is also a Game Studio 4.0 Refresh. I don't know what this one is about and I think that it is meant to bring XNA to Windows phones. I won't be using that one for now so don't grab it. I have nothing against Windows phones and making your games more portable is always a plus, but Windows phone has like a 2% market share. Until they don't reach at least 15% I will pretentiously disregard their effort as "cute".
So after both tools (and a lot of prerequired packages which hopefully these setups have taken care of for you), you can launch Visual Studio (that's what I'll be calling C# Express from now on, VS for short) and create a new project. You should be greeted by the following dialog (with more options available if you installed more languages than C#):
You can click on the "XNA Game Studio 4.0" sub category so you can find what you are looking for more easily:
Here you will select "Windows Game" as a project type (don't worry, I'm sure the Mono guys are hard at work porting Mono over to Linux so you can run your game there once Linux gets proper and rock-solid hardware support for your GPU (and resurrected female clone Hitler saves us from the flying shark attack apocalypse using a fire hose, duck tape an a a few million hamsters interested in philosophy) lisp).
I renamed the "Game1" class to "Game" (VS will prompt you if you want to replace all references, click "yes") and after you can run the project and almost instantly the game window should appear. Alternatively, if you are running on a very old or budget integrated GPU, you might be greeted by this window:
XNA has two profiles to tackle the challenge of a very diverse landscape of PCs out there and let me tell you: two is not enough! It is very easy to wind up in between the two. If this is the case, you need to go to project options:
The two profiles are HiDef and Reach. HiDef is default and if your machine can't handle that, you can switch to Reach:
In case you are curious, here is the breakdown of the differences between the two profiles, using a link that will surely never go away. Translating that into things you might care about, using Reach you are stuck with pixel shader 2.0, which means no pretty shadow mapping (basic one should work fine), just a few lights, no multiple lights normal/parallax mapping (you may be able to cheat this with leeloo multipass) and a few more main limitations, like 16 bit index buffers and no multiple render targets. And combining multiple techniques that work fine on their own with PS2.0 becomes a lot harder.
And finally, here we see the game window:
Glorious, just glorious!