New GraphicsEngine

Aug 8, 2008 at 2:02 PM
I'm just in the midst of fixing the graphics problems. Originally the system was built for DirectX 7 (using a COM interop wrapper). You can get the system to work on Vista (copy assemblies, use regsvr32.exe on them) but that's a bit of a hack and not a good position going forward.

I made a couple of attempts a doing a bit of a "quick fix" to this, namely ripping out the COM interop and replacing all the COM code with calls to Managed DirectX (MDX) which works on Vista. While it works (sorta) it's not right. It's a bit of a hack for a couple of reasons. First, MDX is actually a deprecated product. Microsoft started down the path of writing their own wrappers to their own COM code but they're not mature and the product was shelved prior to a release of the 2.0 version (2.0 was out there, but it was time-bombed).

Managed DirectX paved the way for XNA so right now you really only have two options for writing any DirectX programs. Write C++ going directly against the DirectX API or use XNA (Managed DirectX is still there but who knows how long it will last or what issues there are with it for future releases of Windows).

To take Terrarium to the true next level I decided to abstract the graphics engine away completely. It's a single interface published by the Renderer project now and implemented using a variety of concrete classes. This provides two features. First, I can test IGraphicsEngine. No longer does it have dependencies on DirectX or COM or whatever, it's just interfaces and native classes. Second, I can dynamically swap out the graphics engine if I want.

So for users in XP, you can continue to use the engine that is there today (DirectX7). For Vista users you can leverage DirectX 10, or swap out to run XNA.

Here's a peek at the update to the Renderer project:

For the "Vista Compatibility Release" (2.1) I'm only implementing the DirectX7GraphicsEngine (for existing XP users) and DirectX9GraphicsEngine (for Vista users). Later the other implementations will come along. I have some placeholders in there as ideas, but who knows if a GdiPlusGraphicsEngine will be performant or not.
Aug 8, 2008 at 8:39 PM
Very nice!  Thanks again for donating your time to the project.  Will you be committing your changes to SVN anytime soon (even partial changes would be great)? 


Aug 11, 2008 at 9:52 AM
When I get the DX7 version of the abstraction done and working I'll check it into SVN. Trying to get that done over the next few days but I've been stalled at getting it started this weekend.