Tuesday, October 26, 2010

In Support Of SlimDX

With the massive new 4.0 version of AI War hitting tomorrow, one of the big bullet points from that release is a wholesale platform shift: moving to Unity 3D, away from SlimDX / .NET.  In the past, I wrote about why I chose SlimDX, and why I felt it was the best DirectX interface available in C#.  Searching for "C# directx" on Google, I see that's still one of the very top results.

It's been over a year since I wrote that article -- so, what's changed in that year regarding my feelings for SlimDX?  The short answer: nothing.  It's still the best .NET wrapper available for DirectX, bar none.  My beef was with the .NET 3.5 runtime and DirectX themselves: their lack of cross-platform support, and the terrible and massive installer for .NET 3.5, were the two big issues for us.  Unity 3D paved a way for us to have no prerequisites for installation, and to have Mac OSX support as well as potential support for phones and other small devices.  That was really important to us, but it hasn't changed the fact that SlimDX remains the best at what it does.

I've lately also been talking a lot about things that we can do in the Unity engine that we couldn't do with the SlimDX version of AI War.  That's a good shorthand for me to use (much quicker than saying "version 3.189 and before of AI War, on the old engine"), but it really has very little to do with SlimDX.  The limitations in the old engine came from our use of GDI+ as a windowing system, from our use of the Direct3DX extensions as wrappered by SlimDX, and the general fact that DirectX is a multimedia API and NOT a fully-fledged game system.

So for anyone who is looking for a way to use DirectX in .NET applications, I can definitely recommend SlimDX to you.  Look no further, it beats the pants off its competition.  We left that arena, but that should have no bearing on what other programmers might choose to do when looking for a solution in that environment.  I don't want anyone to get the impression that SlimDX is old, outdated, or inferior -- it's not.  The "SlimDX version" of AI War was, compared to the "Unity version" of AI War.  But that's more to do with us than the SlimDX folks.

You'll notice that the SlimDX team are still thanked in the special thanks section of our credits -- we might not directly use the API any longer, but their API allowed us to launch ourselves in a way we never could have otherwise (I came to SlimDX from MDX, and it was like a dream after MDX).  My best wishes go with the SlimDX team, and I'll keep an eye on them and their project as it develops over hopefully years to come.  Cheers!

8 comments:

Anonymous said...

Hey, thanks for the shout out! We're sorry to hear you leave our API behind, but we're glad it's because you've been so successful.

Unknown said...

Interesting, could you share something on how you went and ported the game (and engine?) to unity?

Christopher M. Park said...

My pleasure, jpetrie! You guys do great work, and I wanted to make sure I didn't give the impression that we left because of anything to do with you. :)

Christopher M. Park said...

Hessel -- Heh, that's a pretty huge topic there. The game engine was already in C#, so the transition to Unity was easier than it could have been, but translating hundreds of thousands of lines of code is never easy.

We'd had experience porting Tidalis from its beta in SlimDX over to the Unity 3D, and that process took a month initially and then was an ongoing sticky issue for the remaining four months of development on that game.

Then with AI War, we spent a solid month just doing porting to get the Unity version to the point of first public beta, and then that was pretty horribly broken right at the start, and it took our army of just under a hundred volunteer testers to help us find all the major issues and resolve them. In all, we wound up rewriting a good 40% of the game from scratch (or using parts we'd done for Tidalis), and I had to rewrite the graphics layer two separate times on TOP of all the work I'd done on that for Tidalis.

The short answer: it took a massive amount of work, and over 800 bug reports from players, and a lot lot lot of overtime to get it done in that timeframe. Both Keith and I (We're the only two programmers) have been through various software porting projects before, even prior to Tidalis, so we knew what we were in for. It's just a lot of hard work, and a lot of making square pegs fit into round holes until those pegs finally get a bit rounder. ;)

Not the answer you were looking for, perhaps, but the main thing is that there isn't really a magic bullet or anything easy about a port like that. Not with a large established game, anyway. But both SlimDX and Unity are very good APIs and well organized, so that helped out a lot.

Anonymous said...

Hey,

Are you aware of Alexandres work?

http://code4k.blogspot.com/2010/10/managed-netc-direct3d-11-api-generated.html

Unknown said...

That's actually sort of the answer I was going for. I never expected the port from SlimDX to Unity to be easy, I was mostly wondering about the compatibility of the c# code in both projects (which, apparently, was around 60% :P)

I myself am dabbling a bit with XNA and became a little Unity-curious since the release of 3. So I'm looking forward to seeing Unity related posts ;)

Christopher M. Park said...

Hey zproxy,

I'm actually not familiar with that, but I never used DX11, I was always on DX9. Shutting out all XP customers was never something that was going to be viable for us, so a wrapper that's even platform WITHIN windows was right out of the question for us, heh. Then again, we aren't creating Crysis-style games.

Looks like that guy is doing some really cool stuff, it's just not up my alley. But neat!

Christopher M. Park said...

Hessel:

I should have clarified that the 60% of the code that remained was the portion that was non-platform-specific, and was just... C# logic. The two APIs are utterly and completely incompatible, they couldn't be more different. Even the fundamental premesis are different (Unity has persistent GameObjects, and an abstracted layer over top of DX OR OpenGL, SlimDX gives you raw access to the DX libraries.

So basically 100% the platform-specific code had to be redone completely. I'd definitely recommend Unity or SlimDX over XNA, unless your target is the 360.

Anyway, glad that was of interest, hopefully I'll be able to do some Unity-related posts in the next while. We've definitely picked up some tips and tricks to get a game like AI War to run on it!