Quest for the Lost Device

· by Steve · Read in about 3 min · (443 Words)

I managed to polish off a loading screen example at the weekend, Demo_BSP now reports progress as it loads (which is good, because if you hook it up to Quake3Arena’s pak0.pk3, parsing all those shader scripts can take a little while!). It’s wrapped up in a little ExampleLoadingBar class that people can re-use relatively easily in their own apps, or of course simply rip off - like the rest of the example code it’s written under a a very lenient license.

I also managed to update my work-in-progress XSI exporter to the Azathoth branch, and fix a couple of bugs with it on the way. I’d made a silly indexing error so that any meshes which had discontinuities (in vertex normal because of a ‘hard’ edge, or in texture coordinates because of a UV seam) would result in freakish face inversions, turning an otherwise sensible mesh into a contorted Dali-esque sculpture.

Right now, I’m working on recovering from lost devices in D3D, something I guess I should have resolved a while ago, but I was just hoping Microsoft would see sense and get rid of the whole pointless procedure. If GL can recover automatically, why can’t D3D? It’s the same hardware after all, thus the same memory deallocation conditions apply. But no, there it is, still yet another boil on the hideously disfigured API design that is Direct3D. Perhaps MS presented an API design course to their employees once that went something like this:

  • “Reference counting - let’s make it manual so it’s easy to keep on leaking!”

  • “Forget the ‘const’ keyword - we control the world anyway, so let’s threaten to modify any structures the user will pass to us”

  • “Passing pointers to pointers instead of returning structured types is really user friendly”

  • “Exceptions don’t exist”

  • “Requiring users to populate a ‘size’ parameter of our own interface structs should be good for a giggle”

  • “Using lengthy, all uppercase typedefs makes for good readability”

.. and other such classics. Yeah, I know some of that is because they wanted to maintain basic C compatibility instead of C++, but God, I think I’d have to try really hard to design an API as ugly as D3D without getting the urge to stab myself with a fork every 20 minutes. Then again, when you look at their other attempts (MFC, Win32), it’s clear that MS has never been the sharpest knife in the drawer when it comes to good interface design.

Wow, that turned into a rant pretty quickly. Well, I just hate wasting my time on basic housekeeping tasks enforced on me by an API. I don’t enforce it on my users, after all.