Why D3DX is evil


In case any DirectX programmers happen to spot this, I wanted to share a warning about using the D3DX library. It's evil, and I'm going to stay away from it!

D3DX is a helper library for DirectX, it's got math helper functions, functions to start up Direct3D, text rendering functions, and perhaps the most widely used is the method to load textures from a file.

Several years ago Microsoft made the D3DX library a DLL that's distributed with the DirectX. Here's something you may not be aware of, they make several versions of DirectX each year. Each comes with it's own version of the D3DX library, and doesn't work with the previous versions. Say, I download the June 2010 DirectX SDK. Then Driftmoon will require at least the June 2010 version on each computer to play the game. Pretty nasty, isn't it?

What Microsoft wants us developers to do is make our game installers also install the new DirectX. It's easy to cram it onto a DVD, but not so in a downloadable game. For downloadable games you can even try installing just the bits your game needs, but I've never got it working reliably on all computers. And what if I don't want to include an installer?

Since I want Driftmoon to run as reliably as possible, I decided to ditch the D3DX library completely. In a week I remade the text rendering functions using regular Windows GDI text rendering, and I remade the texture loading function using the LibPNG and IJG libraries to uncompress png and jpg files. It was a pretty simple matter - and now I've got the code where I can see it.

blog comments powered by Disqus