One enterprising programmer came into possession of some classic windows games, the original 4-part Wing Commander saga, but found himself unable to play them as they were all based on the (now deprecated) DirectDraw API. While many would whine about the dangers of proprietary API’s (I would be one of them), he took it upon himself to resolve the problem.

It all started about a month ago, when one friend of mine had decided to follow his dreams and was moving to the states, and he had to get rid of a lot of stuff. Among his discard pile was a bunch of Wing Commander games, which I bought off him, figuring they might be interesting research material, as I’m planning on a game with similar game play structure (as in story combined with game play, not a 3d space shooter).

So, I found myself in the possession of Wing Commanders 1, 2, 3 and 4, all Windows versions – the Kilrathi Saga and WC4CD to be specific. I installed the first and tried it out. My Win7 switched to 256 colors at a 640×480 resolution, but the game ran.. with completely wrong palette.

His solution was to completely re-implement the DirectDraw DLL (ddraw.dll) with OpenGL calls, turning it into a simple translation layer, with remarkable results.  His source code and binaries are available for download (and extension), along with a list of features to add next:

Next up would have been WC4DVD version, but that adds MCI, DirectShow, mpeg2, DirectDraw7, and all sorts of headaches to the mix, so I figured it’s time for this project to end. I’m releasing the sources, so anyone who wants to pick them up and continue hacking can feel free to do so; with Wing Commanders or other old DirectDraw games.

I love how he’s managed to “fix” some of the ugliness of DirectDraw and adding in improved antialiasing and sync technologies to his implementation.  The fact that on Windows7, OpenGL is actually a translation layer to DirectX, isn’t lost on him either.

Yes, I know, I’m using OpenGL to fix a DirectX problem. Some find this rather ironic. To make things even more fun, vista and Win7 solve OpenGL problems by rendering OpenGL with DirectX. That is, if you’re not using ATI or Nvidia drivers..

via www.iki.fi/sol – Code – DirectDraw Hack.