The reasons there have been no posts lately are Hellgate London and NWN2: Mask Of the Betrayer. Don’t expect any after Mass Effect comes out either
But seriously, I’ve been keeping myself busy lately with a multiple of different things. I had another hobby coding spurt, and probably invested ~40 hours in 3 weeks refactoring and cleaning up my graphics code to add an opengl version of my hobby game to the direct x version. It basically uses an Abstract Factory to create the proper derived classes of all the graphics objects. I originally wrote it with no intention of porting it to openGL. But then I thought it would be interesting to take code that had been written with no intention of extending it like that, and add the opengl functionality. I had tried some big design up front ideas, but I couldn’t come up with anything I liked.
So I added a second project config to the visual studio solution, and added it’s own #if def, GFX_OPENGL. Then I added the GFX_DIRECTX definition to the DirectX configs. The goal with this was at any point in time, I wanted o be able to switch from the non implemented openGL version back to the direct x version and have the DirectX version still work fine.
Once I had that done, I stripped all the direct x headers from the opengl config. Then I hit compile, and presto, compile errors. So I’d tackle them one by one. The first one, IDirectDevice9 not found. Not surprising. So I’d create a new class, IDeviceManager, and derived classes DirectXDeviceManager and OpenGLDeviceManager. Then I’d do a global find and replace, and replace all the IDirectDevice9’s with IDeviceManager. Then I would slowly fill in the interface as the compiler led me to do it.
So I did that, and it took a while. It was a lot of refactoring, as I had to move a lot of directx code from inline in other methods to specific classes, such as DirectXFont, DirectXTexture, etc. But eventually, the openGL version compiled, but running produced black screen. So then i started implementing all the interfaces I had stubbed out in the previous steps. After yelling at different font libraries for a while (settled on FTGL) I finally have the two versions both running and rendering the front end almost identically. Next is the backend.
It was an interesting project, and the method I used was interesting to me, because I wasn’t sure how well it was going to work out. It turned out quite well. Theres only a few places left where the GFX_ definitions are stil used outside of the actual definitions of the type specific classes. So I’ll work on slowly getting rid of them.
Hmm. That took longer than I thought to explain. Stay tuned next week for my 1 week reviews of Hellgate London and NWN2: Mask of the Betrayer.