Direct3D vs. OpenGL

The age-old argument.

Lately I’ve been working on abstracting Direct3D and OpenGL. This wasn’t actually my intended goal - my intended goal was to write a renderer in Direct3D with shader support, but it just turned out that way. I do admit that I have been concentrating on the Direct3D half of the job more than the GL half: so much so that the OpenGL half no longer works. This doesn’t bother me much. I’m sure Luke will write a version in his beloved API if he has time.

Speaking of which I have always been a firm supporter of OpenGL, but I have found myself drawn to Direct3D more and more lately. I have always thought that Direct3D was a disgusting API (particularly because of the Hungarian notation) and that it was inferior to OpenGL. I see now how disillusioned I was: Direct3D is vastly superior. OpenGL is good for prototyping small applications that require no special features, I feel. Direct3D, though much more annoying to set up, is so much better for large applications in the long run. I spoke to Jim, a tech. lead at Climax Studios Solent about this a few days ago and he agreed whole-heartedly. Having much more industry experience than I it seemed rather obvious that he’d thought this since DirectX 6.

Direct3D’s shader support is vastly superior over OpenGL’s “afterthought” version, which is the only reason I chose to use this API in the first place. However, I now see that Direct3D is superior in nearly every other way too. It is not the nicest API to look at, but then I took a new look at OpenGL and realised that it’s just as disgusting, if not more.

Despite Luke and Daniel’s push for Direct3D in our projects, they still love OpenGL. Also, at the GDCE last year Keith Ditchburn (also see Toymaker), one of my lecturers, told me that industry people prefer good Direct3D knowledge than OpenGL knowledge. Jim from Climax seemed to agree, considering he interviews people for the Solent studio this counts for a lot. Speaking of which, he also recommended PS2 vector unit code and assembly, so I should look at those in the near future.

I’ve come a fair way in my Direct3D renderer. It’s nothing special - yet - but I have got swappable render targets with render to texture happening which I have never done before. In fact, with Direct3D it’s so easy I did it while drunk - no kidding. Though I will have to look back on it soon and ensure that it’s best way that I could do it. I’m beginning to get that dirty feeling that I get when the project I’m working on seems to be held together by blubblegum in places. I think my primary concern is the private implementation of the textures. I’ve actually repeated some code (ack!), and I’ve passed my IDirect3DDevice9 pointer to sub objects like textures and targets. I’m not sure this is a good idea, but in some ways it’s necessary. I doubt the speed and efficiency of the GetDevice() function in the Direct3D objects. I’ll have to look into that a bit more.

Oh, and finally: HA! The hilarity…
LOL

2 Responses to “Direct3D vs. OpenGL”

  1. Baher Says:

    Hey, we and you have the same theme (Wuhan) that’s quite a surprise to me, especially that you’re a game programmer as I used to be.

    I’m a hardcore gamer and learned game programming for a while, for me OpenGL was the API of choice, I liked the simplicity of it and once you get the hang of using extensions, you can program some amazing shader effects, back in the early GeForce 6 days the ARB_vertex_shader_3 which allowed real displacememnt mapping was out before even the card, when it took quite a while before MS releases DX9.0c.

    The big downside of this extensions thing, is that you have to write the shaders to different extensions in order to work with different cards, when I decided to do Normal Mapping, I had to write 4 differnt code pieces in order to sclae with different cards, and that was very time consuming, but you get a very optimized performance using this approach.

    I hope they resolve this extensions thing, for the sake of OpenGL and to make it a little more appealling to others.

    Ahh you reminded me of game programming, it’s been a while now since I coded something, I have to get back to it now )

  2. Peter Lewis Says:

    You’re quite right - the extensions were a powerful asset and the only option for pre-DirectX9 applications. However, as you say they’re not very portable. It’s a pity, but with OpenGL 2.0 things should change.

    Wuhan is an awesome theme, too. D

Leave a Reply

You must be logged in to post a comment.