From XNA to SlimDX ( Part 2 )
It’s a scary and yet exciting step. Leaving this whole feature-full, documented, full of examples XNA to that weird, unpopular, open-source alternative called SlimDX.
What’s the worst thing that can happen, right? Now that XNA is going more towards console/phone apps, SlimDX is the future ! People will start using it and soon a huge SlimDX community will appear, helping thousands and thousands of people !
That’s what I thought would happen, years ago.
I decided to stop waiting and port it myself.
You may think that SlimDX is completely different from XNA, but they’re pretty much the same, while XNA gives you all these high-level functions ( like Game class, SpriteFont, DrawInstanced, Ressources, etc.. ) that make things much easier and sometimes force you to use them ( Content pipeline ) , SlimDX gives you all the tools in order to make anything you want.
Porting my code was surprisingly easy, what I first did was comment out all the graphics codes. Once I was done with cleaning all the XNA code, I started implementing things one by one starting with an empty SlimDX window which was based on the sample’s code.
After that I began searching for equivalents for XNA’s functions, they were all pretty much the same, with some time I had most of the code readapted to SlimDX. Textures were kind of tricky to understand as well, instead of rendertarget, SlimDX has surface ( just like in DirectX API ) and in place of Texture2D it has a plain Texture class. In general it had almost all the functions that XNA had.
The annoying part was the lack of game specific features, such as MathHelper, BoudningFrustum, SpriteFont ( SlimDX has the normal DirectX one but it isn’t really efficient ), SpriteBatch ( same problem as for SpriteFont ) and of course the input managers. Within a few days thanks to the Internet I managed to put them all back in.
I gotta say that this was kind of hard, especially implementing the missing features. But in the end, the whole porting process was kind of interesting and I learned many things on the way.
Good thing I separated the graphics code from the game code before I started doing this =)