Why you should use OpenGL and not DirectX : article

Hmm. When I went and looked, what I found suggested the Wii used OpenGL. I guess it's not. Stupid interweb. What the PS3's extensions to OpenGL ES are like, I don't know, but it's still fundamentally GL ES. According to wikipedia it's "OpenGL ES 2.0 compliant except for the use of Cg instead of GLSL."

Of course there are differences between ES and desktop GL, but they're virtually identical compared to D3D vs GL which was my main point.

Indie games are a completely different case than AAA titles, though. Indie games tend to be much more word-of-mouth driven, while AAA titles sink a large part of their huge budget into marketing. An indie game might be considered quite successful for selling a few thousand copies, but for the high budget titles you need to sell millions to break even.

The fact that indie games do so well on the Mac, or rather, so badly on Windows, is, and this is the funny part, because the Windows market is too damn large and saturated, and the consumers end up having to look for the needle in the haystack.

DirectX is bad for the whole industry. Unfortunately the reality is it's also a much cleaner API than OpenGL (as of DirectX 10), is more efficient by design, and has the best support on Windows, the market that matters to most game developers. I like OpenGL and open standards, but that's just the truth.

First, I'll clarify some things about the consoles, since I've worked on all 3 current generation consoles. As mentioned, the Wii doesn't use OpenGL. Some of the functions "feel" like OpenGL, but it requires a lot of manual management of graphics resources, unlike OpenGL. It's also completely fixed function, but you can configure the fixed function pipeline a lot more than OpenGL. On the PS3, OpenGL is an option, however it is a lot slower than using the native graphics API, and is therefore not used by any studios that require any heavy-duty graphics.

There is one thing that all the console APIs, and to some extent DirectX, have that OpenGL doesn't, and that is direct control over the resources. With the PS3 and Wii's APIs, you pretty much have to control the memory resources for stuff like textures, vertex buffers, etc. directly. With DirectX you can specify if a graphics resource only resides in graphics memory all the time or is managed by the API, which means it is in main memory always and can get put in graphics memory when needed.

OpenGL gives you little control over memory resources like that. AFAIK, the only control OpenGL gives you is telling if vertex buffers are dynamic or static, and even that is just a hint. Extra control can give you an edge for resources that you know will be drawn very often, or pre-load resources that you know will be needed shortly. Giving too much control to the driver can also put you more at the mercy to how the driver makes its decisions. For example, OpenGL drivers had to be heavily modified in order to make Doom 3 run acceptably. Right around that time, driver updates made one level of Knights of the Old Republic become unplayable.

Additionally, OpenGL's support for vertex compression is laughable. They just added official support for half floats for vertex buffers in OpenGL 3.0. On top of that, DirectX and the PS3's API support a vertex format that fits 3 component normalized vectors (such as normals, tangents, and bitangents) in 32 bits. The consoles have even more options. Having more compact vertex buffers not only improves memory usage, but it also allows for more effective use of the vertex cache, which speeds up drawing.

Another issue with OpenGL is, from what I can tell, you can't pre-compile shaders. (at least GLSL shaders) If you use a lot of different shaders, having to compile them at run-time can greatly impact load times.

Though many people make the point that with extensions, OpenGL can get features faster, it's not that simple. For one, you are very dependent on when the drivers actually implement those extensions. For example, the ability for extensions doesn't keep Apple from being behind in features. Additionally, as mentioned, they can be a very large pain to use since you have to get the values of enums and load function pointers yourself. Loading one extension may not be enough, either, as sometimes there are multiple extensions that do the same thing that have been used at different periods, some of which are vender-specific. Many extensions eventually get pushed into the core, but that happens at a glacial pace and has been falling farther and farther behind compared to DirectX.

That said, OpenGL is hardly worthless. It's still useful for non-game applications, and is more robust in many areas in DirectX. For example, it's possible to use OpenGL over remote desktop (though I think with DirectX 10 that was fixed), and I don't think you ever have to worry about suddenly losing your device. It's also more multi-platform, in that it works on all 3 major computer platforms, and is more open than DirectX. However, for games, I think the lack of extra control over resources and lack of some key features make it difficult to choose. For games without heavy graphics requirements it's perfectly fine, but with cutting-edge graphics the extra boost you can give yourself with DirectX makes a difference.

In the end, I'd say that it's not just marketing or "because everybody's doing it" that makes people choose DirectX, it truly is superior for making games. While the article is somewhat correct in that it's a positive feedback loop where more people giving support to DirectX makes it better, which causes more people to support it. However, from a game developer's standpoint, you aren't likely going to willingly choose the API that makes you scale back your graphics due to its limitations. And not everybody has the weight of John Carmack to "Ask the ARB to change it" (or Kronos these days), or have special driver patches specifically to get your game to run smoothly.

I would also have to disagree with some conclusions of the article. If you abstract the graphics API in your engine, you should be more willing to use DirectX as your main rendering API, because you can take full advantage of the extra control you have in DirectX, then scale back some things in OpenGL if you port to other platforms. I do want to see OpenGL prosper, but I think that proponents for OpenGL are doing themselves a disservice if they ignore the problem by denying any advantages of DirectX instead of identifying and fixing the problems.