OpenGL

Me and OpenGL

I used to be pretty passionate about the OpenGL graphics API, and I spent a fair amount of my time working to make it successful on the PC for games. I still use it regularly and think it's a pretty well designed API, and it's certainly still much more pleasant to program with than Direct3D, even after all of these years and versions, but the heat has gone out of the issue for me. Direct3D won the war. SGI is basically dead, the OpenGL Architecture Review Board is mostly reactive instead of proactive, and Direct3D is the stable and mature platform that drives the features for each generation.

OpenGL still has some advantages, like vendor extensions that allow IHVs to expose custom features in a standardized way, the relative niceness of most of its programming interface, and the fact that it's cross platform. However, there are really wonky and byzantine parts of the OpenGL API, one must admit, and the XBox makes it so Direct3D is actually somewhat usefully cross platform on two platforms on which you can actually sell lots of copies of your games. So, if you want to make a 3D game on the PC and you want to have stable access to the latest 3D features, you should use...well, actually, you're just screwed. Yes, after 10 years of effort, the 3D graphics situation on the PC is still pretty laughable. You can, without trying very hard, find a serious 3D driver bug within minutes of sitting down to write code with either API, which is just pathetic.

However, finally getting to the actual advice, if you want a better chance of getting your code to work using "mainstream cutting edge features" (say, lots of render-to-texture, deep render target pixel formats, etc.), and you don't want to fight a battle with your publisher, you're probably better off using Direct3D. If you only need to use a safe subset of features that lags the cutting edge by a year or so, and you want the nicer programming experience, or if you want to use the most bleeding edge stuff that's only available in vendor extensions, then you should use OpenGL.

Ironically, the collapse of the PC 3D market down to NVidia, ATI, and Intel has actually helped OpenGL be competitive, driver- and coverage-wise, since those vendors tend to update their OpenGL drivers about as frequently as their Direct3D drivers. The chance for OpenGL to "win" is long past, though. Direct3D is easily a good enough API now.

Personally, I write all of my prototypes, tools, and indie games in OpenGL, because it's just more agile and toolkit-y. And fun. Don't underestimate the motivational power of having fun while you program. The games I work on for big companies are almost all written in Direct3D.

At the end of the day, for most games, which API you choose probably doesn't matter one bit. There are more interesting problems than 3D graphics to solve in games anyway.

What If?

People occasionally talk about what the PC 3D situation would be if it wasn't for Direct3D. Some people claim that without Direct3D, OpenGL would still be at 1.0, and there would have been no innovation. This is pretty naive, I think. The thing that spurred innovation in the market was the commoditization of good 3D hardware, and the outflow of SGI hardware designers starting companies to make 3D chips on the cheap, not any design decisions made in Direct3D or OpenGL. It was just time. Microsoft could have easily embraced OpenGL to provide the API for this new generation of hardware, and I think the industry would have been much better off because it would have started out with a good, solid, proven design, rather than having to go through years and 5 API iterations to get to something that actually worked.

When I was at Microsoft, I originally thought OpenGL was a poorly designed 3D API, and I actually fought against it in meetings, but I was just clueless and wrong. The fact that there was no fast OpenGL software renderer was more an artifact of history than of API design, even though we game graphics people thought it was fundamentally broken, since it didn't match up with our notions of how 3D graphics should work. SGI eventually released a competitive software OpenGL just to fight the FUD coming out of Redmond. And, of course, no one cares about software rendering performance anymore anyway, and even at the time, no one wanted to use an API for their software renderer, because there's just too much domain-knowledge you can take advantage of by doing it yourself, so the whole question was a waste of time and a diversion.

It's painful for me to look back on that time, because it was the tail wagging the dog in so many ways. Even incredibly brilliant, thoughtful, experienced, and well-meaning people like John Carmack were giving the completely wrong advice to PC 3D hardware companies about how their chips should work (Carmack readily admits this, by the way). 3Dfx was the one company that ignored all the game developers and Microsoft; Tarolli et al. just made an architecture that was based on their hardware experience at SGI, and they wiped the floor with everybody else[1].

There were certainly plenty of changes that needed to be made to OpenGL to make it fit commodity hardware truly well, and to take it past 1.0, but those could have been made with far less disruption and churning than dragging everyone through so many bad and limited API iterations. It was just a giant waste of industry resources—Microsoft's resources, IHV resources, and most importantly, a lot of game developers' resources—and all just so Microsoft could control the API absolutely. I don't blame Microsoft for this, I actually blame game developers, including myself.

So, yes, Direct3D spurred OpenGL to improve in the sense that people at the time were scrambling to do anything to enable 3D hardware and Direct3D was Microsoft's answer to that question, so it was in the mix. And, it is definitely true that SGI should have had a clue and kept ahead of the curve and figured out the commodity 3D hardware thing themselves rather than being reactionary, bleeding their engineers to startups, and eventually dying. But, no, Direct3D was a huge loss to the industry in terms of resources wasted compared to the alternative of just starting with OpenGL, understanding why it was designed the way it was, and iterating from there.

Blasts From the Past

Here are some old writings about OpenGL and related topics:

  • An Open Letter to Microsoft: Do the Right Thing for the 3D Game Industry
    This was the first article I wrote about the issue. It is a highly technical article about the ways in which OpenGL was better designed than Direct3D, once I finally got that clue. It is now completely out of date, as almost everything has changed about Direct3D since this article was published. At the time when this article was written, Microsoft could have thrown out Direct3D, embraced and extended OpenGL, and I think the industry would be much better off now. Much more frustrating to me than Microsoft behaving this way was that game developers just sat there and complained about it but did nothing, for the most part, where I believe we could have banded together and changed the situation over night. See below.
  • Developer Power and the U Word
    This is a link to a speech I gave at the Seattle CGDC. It's about how we can prevent this kind of thing from happening again.
  • GLSetup
    I spent a few years working on a project called GLSetup, which tried to eliminate the driver install problem for updating OpenGL drivers.
  1. Dropping memory prices had a lot to do with the commercial success of the Voodoo, but I'm talking about performance and programming model here
This page was last edited on 16 November 2011, at 19:55.