24
Feb

DirectX vs OpenGL: Why Are We Here?

Posted by Michael Simpson

Looking around this blog and its comments, I’ve noticed that the argument of DirectX vs OpenGL seems to be discussed quite regularly.  Therefore, I thought it relevant to bring up the topic a bit more formally.

For those who aren’t completely familiar, DirectX/Direct3D/D3D and OpenGL are the two most popular graphics API’s (Application Programming Interfaces) utilized in game development.  While the complete description of what a graphics API does and their history would fill quite a few blog posts, they essentially provide sets of abstracted functions designed to be used and reused in a game’s source code.  In short, they make game programmers’ lives much easier.

The Great Debate

Probably the hottest debate between the two API’s has to do with their relative performance.  I find this to be a bit misguided.  The fact of the matter is, the performance the end user witnesses isn’t going to rely just on the API used, but also things like video card drivers.  I’d like to quote Brad Oliver in his response to James found here:

James:  “But until developers code games to explicitly for OpenGL and graphics card manufacturers build their cards to utilize OpenGL, we are at a disadvantage.”

Brad:  “This is pretty much not true. In our fantasy world where Apple licenses Direct3D from Microsoft, they still have the issue of getting ATI and Nvidia to write the drivers — which is the exact situation we have now with OpenGL. The front-end API, be it OpenGL or D3D, is a non-factor for performance.”

I couldn’t agree more, Brad.  I feel as though the API is ultimately more of a choice of preference, application, and what a programmer is comfortable with than anything else.  Looking around the vast realm of The Internet, one can find numerous debates about the topic with one side (DX/OGL) being faster or offering better performance than the other.  For instance, this article outright claims OpenGL superiority.  Of course, I have a qualm immediately with the claim when the author references an NVIDIA OpenGL Update that’s around three and a half years old at the time of the blog posting.  That’s a bit outdated, especially where technology is concerned.  I also don’t like the use of Wikipedia as a reference, but that may just be my personal standard.  In any case, the post does bring up some other interesting information, which I’ll explore a bit later.  On the other side of the coin, the D3D purist can reference articles like this showing dominance of D3D 11 vs OpenGL 4.0 across several graphic cards (and this is actually fairly recent!)  I also feel the API’s were designed with different intentions in mind (OGL having a wide variety of professional uses beyond just gaming, and D3D being a game development specific API).  This could also account for some differing performances between the two.

The Greater Question

What I’m trying to convey here is that we could debate about respective performances of the API’s until we’re blue in the face and not really get anywhere.  A far more interesting topic is looking at how we’ve gotten to a point in the game industry where D3D is so dominantly used among AAA PC titles over the once “tried and true” OGL.  This is increasingly intriguing when one is to consider that greatly influential game programmers (read:  John Carmack) lambasted D3D in the late 90’s (though admittedly he’s since come around a bit on his feelings toward DirectX, though seems to still prefer OGL).  Under such scrutiny, how did DirectX become so prevalent?

Carmack is responsible for many major breakthroughs in graphics programming

Reasons

I once again reference the Wolfire Games blog vehemently supporting OpenGL; the post definitely brings up some very valid arguments about DirectX becoming the API of choice.  Microsoft has good control over the software industry.  This is undeniable.  By leaving the OpenGL Architecture Review Board followed by hinting that Vista wouldn’t natively support OpenGL, and given Microsoft’s vast majority control of the PC market, it becomes clear why gaming companies would be frightened to continue development with OpenGL.  As the blog continues to state, despite Microsoft later reneging on this decision, “the damage had already been done.”  This then begets the “vicious cycle” also mentioned in the blog, where because so many developers are using DirectX functionality to create their games, the documentation becomes better, the hardware support becomes better, and so on.  I also have to agree with the point about marketing.  Some of the marketing to hype DirectX 10 was just absurd.  It reminds me of weight loss supplement commercials where the before shot always features a person frowning and looking about as unhappy and unattractive as they can, while the after photos are often touched up.  The truth is that the largest difference between DX9 and DX10 is probably in particle effects and shadows (A good example in Bioshock).  Otherwise, the two versions offer very similar graphical detail.  DirectX 10 was not at all what Microsoft billed it to be.

These images are both from Crysis. One is running under DirectX 9, and the other is running under DirectX 10. Can you tell which is which?

What do YOU think?

I’m very curious to hear everyone’s thoughts on the API debate.  Do you feel OpenGL will be able to come back and be as widely used in the PC arena as DirectX?  Why/why not?  It’s hard for me to imagine this in the near future, given Microsoft’s ability to pour money and time into developing DirectX further and further so that it suits the needs of even the most scrupulous of developers.

  • ltcommander.data

    I often point this out, but there is a window to promote OpenGL that is rapidly closing because Apple is not keeping up with the latest OpenGL standard. According to the latest Steam survey more than 21% of DX10/DX11 GPU owners actually use Windows XP. Given that Windows XP is not widely/easily available anymore, these GPU owners are most likely tech-savvy users able to custom-build their own computers, ie. the hardware gamers developers are looking for. OpenGL’s value proposition is it’s cross-platform support and this would be an ideal time for game developers to have say an OpenGL 3.x codepath in their engine allowing them to fully utilize DX10 and DX11 GPUs not just in Vista and Windows 7, but also Windows XP and have the value add of being able to open new markets by targeting Mac OS X and Linux. However, the cross-platform vision of OpenGL only works if every platform keeps up with the standard, which in Apple’s case, OS X is not, still being left at OpenGL 2.1+extensions. This window is rapidly closing as Windows XP finally fades, which will just solidify developers on using DirectX 10 and 11. What’s more, according to the latest reports even Lion looks to only be at OpenGL 3.2, which is a big improvement, but getting to OpenGL 3.3 makes the most sense to meet the common capabilities supported by DX10 class GPUs in Windows and Linux.

    The other thing is that with many developers familiarizing themselves with OpenGL ES in order to target mobile devices, particularly iOS, Apple should really be leveraging this and encouraging developers to support OpenGL in their desktop games, which is convenient for all parties to maximize code and asset reuse. In particular, Epic reports that they worked closely with Apple to get Unreal Engine 3 up on iOS and Apple gave them a special exemption allowing them to run their own virtual machine to interpret Unreal Script. This would have been a perfect opportunity to push back on Unreal to add a fully supported OpenGL codepath to UE3, as UE2 had, and push it out to licensees which would be a big help in bringing PC games over to Mac down the road.

  • Jason Kenney

    OpenGL is a graphics library with uses outside of gaming: CAD for example. Direct3D is specifically designed for gaming. I think it will gain some return since mobile computing and Playstation 3 both can use OpenGL as do Macs and Linux. And some web browsers are starting to do OpenGL (WebGL).

    Also, there is id tech 5 to consider (RAGE). If it overtakes Unreal, this will lead to a renewed interest in OpenGL. (Source engine also uses OpenGL IIRC).

  • Michael Simpson

    @ltcommander

    “The other thing is that with many developers familiarizing themselves with OpenGL ES in order to target mobile devices, particularly iOS, Apple should really be leveraging this and encouraging developers to support OpenGL in their desktop games, which is convenient for all parties to maximize code and asset reuse.”

    I agree with this completely. I refer back to the point in my first article where I mention that Apple certainly has some potential here, but they really need to take advantage of the opportunities they are given to push OpenGL and ultimately gaming on the Mac.

    @Jason

    Indeed, OpenGL is not game dev specific as Direct3D is, so it will be around in some form or another for the foreseeable future. Hopefully consoles will continue to have some form of OpenGL support.

    Source, I believe, was built using DX9. I recall early articles detailing the Source engine and its ability (specifically with CounterStrike Source) to scale back to earlier versions of Direct X, ensuring some usability on significantly outdated hardware (something I really appreciated about it). Now of course Source is around on the Mac so they are also using OpenGL. Furthermore, the predecessor to Source (though I forget the name, but recall seeing the options in CS 1.5) was using both OpenGL and DirectX.

    Your point about id tech 5 is pretty interesting, though, and it makes me think back to Doom 3…While Doom 3 was pretty graphically impressive (especially in shadow detail), I would argue that the game play was pretty dated…especially when it’s going up against games like HL2 (HL2 using a lot of unique physics based puzzle solving and interesting vehicle sequences…Doom 3 still sort of falling back on the “find item to open door to proceed through corridor” mechanic). I think the survival and livelihood of ID’s graphics engine is going to rely heavily upon the games released under it. I think if they compare favorably to other games released using different engines, the demand for more games utilizing the engine increases, and ultimately then the use of OpenGL will follow suit.

  • http://wolfos.org Wolfos

    Well, we will get the Unreal Engine 3 for Mac. Look it up on unrealengine.com.
    One problem with OpenGL is that Microsoft doesn’t have a very good implementation of it. Applications that support both OpenGL and DirectX will have a massive increase in performance with DirectX.

  • Mikael

    In theory, both API’s are comparable in power (Direct3D 11 is not that much better than OpenGL 4.2), but OpenGL is better because of the portability. But in reality…

    Let’s just say, there’s little reason to be “portable” at all for a desktop game, unless it’s really the Mac users you’re after (Linux users are too few to matter, and seem to be forbidden to pay for software by their religion or something). Now, for some inscrutable reason, Apple really doesn’t care one bit about gaming, so the very idea of targeting mac users immediately takes any high-end graphics aspirations out of the picture.

    There are two main reasons for this:

    1. All affordable Macs have weak, non-upgradeable graphics cards.

    2. Apple can’t be bothered to support recent OpenGL standards anyway.

    The second is the final nail in the coffin here. OpenGL 4.2 is indeed a viable API to develop visually advanced games with (if we assume you’ll be creating most of your own tools from scratch, a pretty big assumption). But most mac users are stuck with OpenGL 2.1 support! Only those with the very latest OS (10.7) get anything better, and even they are stuck at OpenGL 3.2!

    In short, you can make an cutting-edge game engine with D3D 11 that runs on Windows, or you can make a horribly outdated game engine with OpenGL that runs on “anything”. For some games, the latter option is fine, for some it is not.

  • Stephen

    smart companies like id use opengl, ea… as much as i love some of their games for whatever unknown reason chose to use directx… no idea why, between dx9, 10, and 11 its going from one shade of grey to the next minor improvements from one to the next. but in these screen shots no noticeable differences.
    opengl runs more smoothly than dx11. also i’m a linux user and only use windows to run games, not because i want to but because games like Battlefield 3 won’t let me run them in linux due to dx. i hope ea fixes this and if not then in bf4, so that way i can finally rid myself of ms windows all together and be FREE!!!

  • Stephen

    directx is only around because its a ms product and ms pushes it when it can. its so sad.

  • jim

    how did DirectX become so prevalent? Easy, read the history and see for yourself http://programmers.stackexchange.com/a/88055

  • anonymous

    lol the dummies that talk about DX version giving better image quality, it doesn’t matter the only reason you should forget DX10 and DX9 is because (the last being the most horrible API out-there) they’re garbage for current GPU power, this is a topic developers should talk not crapped pants gamers that have no idea what they’re talking about.

    DX11 is well designed, low level and the overhead is minimal that’s why every developer should program with DX11 on windows no matter what is their bias, then use OpenGL4.2 (which is not bad is the same actually, it’s just an api, a little bit cumbersome but it doesn’t matter) for Linux or Mac;

    In my case i went for an abstract renderer i didn’t want to use DX11 directly even if it would of been faster to develop, i made generic Rendering Objects and Interfaces for example class Texture, Class Sampler, Class Buffer etc etc. and then implemented both version with DX11 and OpenGL3.