Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Today I decided to check what Diablo 3 developers used to do graphics: OpenGL or Direct3D? My mind was completely blown: For Windows, they've used D3D and for OS X they've used OGL.

I did some research and found that most game developers prefer the same method. This choice doesn't make sense to me. Writing one game engine with OpenGL for OS X and then rewriting same for Windows with D3D seems a lot of unnecessary work. Wouldn't it be easier to just take OpenGL and make a game engine that works on both operating systems?

share|improve this question

closed as not constructive by Byte56, Patrick Hughes, Nicol Bolas, Tetrad Feb 10 '13 at 2:59

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
There is no Direct3D for OSX, otherwise they'd probably use that. –  snake5 Feb 9 '13 at 20:04
    
I know that, but why can't they just use OpenGL for Windows, too? –  Arnas Feb 9 '13 at 20:05
    
They might have written it first with DirectX, then made it work on OS X and replaced DirectX calls with OpenGL ones or something. I doubt they would have started with OpenGL on OS X and rewrote it with DirectX for Windows, it just wouldn't be worth the effort, they both perform similarly. –  Robert Rouhani Feb 9 '13 at 20:52
3  
In the grand scheme of cross platform engines, rendering is but a small part. In any case, this isn't really a Q&A kind of question and more of a discussion opener and therefore not wholly appropriate for the stacks. –  Patrick Hughes Feb 9 '13 at 22:01
    
@Arnas OpenGL is a simply a worse API. So why should they? Consistence? Windows has a much bigger number of users so it would make sense to start with a Windows-optimized version and port only if the game sells and brings in money. –  snake5 Feb 9 '13 at 22:16

4 Answers 4

up vote 11 down vote accepted

As others have mentioned, on OS X (and Linux), OpenGL is the only game in town for hardware-accelerated graphics. So the question really comes down to: why do developers use Direct3D instead of OpenGL on Windows?

One possible reason, as suggested in the comments, is that they started out as a Windows-only project and later decided to add OS X / Linux support, but didn't want to throw out their already-working Windows code. But another possible reason is that the developers may simply consider Direct3D to be superior to OpenGL, enough that they would rather write their rendering code twice than use OpenGL on Windows.

Part of this is clearly a "holy war" kind of issue - Direct3D and OpenGL use very different styles of interface, have different design values, and appeal to different coders' tastes. Like Mac vs PC, or Emacs vs vim, or tabs vs spaces, one can endlessly debate these things without ever convincing anyone.

Putting all that aside, though, I think it's fair to say that during the last several years, Direct3D has been objectively superior to OpenGL for Windows graphics programming, for the following reasons:

  • For a good while, OpenGL seriously lagged behind in features. Direct3D 10 and 11 added support for new GPU features like geometry shaders, tessellation and compute shaders that it took OpenGL years to catch up to. There's a good Tom's Hardware article from a few years ago that gives you a taste of how disappointed people were about the lack of OpenGL feature development during that time.
  • Direct3D has historically had much better tools: the debug runtime / debug layer, which generates warning messages about incorrect or questionable API calls you make; and PIX, the graphics profiler/debugger. For a long time, OpenGL had nothing comparable.
  • The major GPU vendors have usually made Direct3D driver support a higher priority than OpenGL driver support. As a result, bug fixes and performance improvements often come sooner to the Direct3D drivers than the OpenGL ones.
  • Console compatibility: from what I understand (not having worked with it myself), the XBox 360 graphics API is very similar, if not identical, to Direct3D 9. To whatever extent this is true, it likely means an easier time of porting games between PC and 360. It also means that if you're shipping your game on the 360, you have to write a Direct3D renderer anyway - so you might as well use it on Windows too.

By the way, our own Nicol Bolas also wrote an answer to a related question at programmers.se that goes into a lot more detail about the history of the OpenGL/Direct3D rivalry.

All that being said, there are signs that the tide is starting to turn. OpenGL developers have been working very hard to rectify the features and tools issues. OpenGL has now reached feature parity with Direct3D 11 and even gone a bit beyond. Timothy Lottes of NVIDIA wrote a blog post outlining his reasons for switching to OpenGL, with a lot of links about the new extensions and tools. Valve Software recently reported that they got an OpenGL version of Left 4 Dead 2 working and it was (slightly) faster than the Direct3D version, indicating that the driver support is there. So, it's possible we will see a swing back toward multi-platform developers using OpenGL on Windows. Or we may not.

share|improve this answer
1  
In addition to this, D3D drivers tend to be of significantly higher quality on Windows than OpenGL drivers are, so devs get to spend time fixing bugs in, and adding cool stuff to, their own code rather than implementing workarounds to stupid driver bugs that should never have happened. On Mac and Linux, where GL is the only game in town, that doesn't apply of course (there may still be driver bugs of course, but one just has to deal with them the nasty old-fashioned way). –  Darth Satan Feb 9 '13 at 23:16

DirectX is written for OS Windows with own optimizations to platform, etc. There aren't any realizations of it for another platforms. OpenGL is an open alternative which started grow when mobile and tables become more powerful to render some hard scenes.

Anyway, I'd give you and advise to write everything using OpenGL, but it's only my opinion. It's free, crossplatform, powerful and fast.

share|improve this answer

It is likely that the actual reason for it is just politics. Many experienced game developers use DirectX since ages. Thus DirectX is used. (And than OpenGL was later added by the developers that made the Mac port.)

One thing however is that people that use OSX are sure to have GPU's that have properly working OpenGL implementation. This can't be said for sure for Windows PC's, due to the long time where games on Windows were primarily DirectX. This is bound to get better in the future though, with the rise of Steam for Linux and thus cross platform game development. If you want to write OpenGL code for Windows without having to worry about the OpenGL implementation of the GPU you could try ANGLE.

share|improve this answer
    
ANGLE is OpenGL ES, not OpenGL. They aren't the same thing. –  Nicol Bolas Feb 10 '13 at 0:36
    
@Nicol Bolas They basically are (GLES2 is just missing some stuff)... sadly they didn't take the opportunity to make GLES Object Oriented in design while they had a chance. –  zezba9000 Feb 10 '13 at 1:11
    
ES2 also adds things like precision qualifiers (not core until GL 3.0) and other stuff that is not available on any OpenGL 2.x implementation. It also adds functions that weren't added to GL until ES2_compatibility. So again, it's not simply "missing some stuff". –  Nicol Bolas Feb 10 '13 at 1:15

Simply because Direct3D runs way better on Windows then OpenGL in most cases. GLSL doesn't event run on most Netbooks and OpenGL driver support is very flaky on Windows. Like vSync with OpenGL on Windows doesn't work without installing the drivers yourself manually.

For games, you rly want to use Direct3D on Windows... Other platforms only support GL in most cases. Also Windows RT and WP8 only support Direct3D.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.