top | item 6852961

Why you should use OpenGL and not DirectX

408 points| intull | 12 years ago |blog.wolfire.com | reply

175 comments

order
[+] taspeotis|12 years ago|reply

    API use was shifted in favor of DirectX
    by Microsoft's two-pronged DirectX
    campaign around the launch of XBox
    360 and Windows Vista, including the
    spread of FUD (fear, uncertainty and doubt)
    about the future of OpenGL, and wild
    exaggeration of the merits of DirectX.
I thought it was because that, at the time, the OpenGL API was shit [1].

    By the time of OpenGL 2.1, OpenGL was
    running into a problem. It had a lot of
    legacy cruft. The API wasn't easy to
    use anymore. There were 5 ways to do
    things, and no idea which was the fastest.
And really, the author of the blog post should have known this when the blog post was written...

    By David Rosen on January 8th, 2010
OpenGL 2.1 came out in 2006 [2].

[1] http://programmers.stackexchange.com/a/88055/7067

[2] http://en.wikipedia.org/wiki/OpenGL#OpenGL_2.1

[+] kbenson|12 years ago|reply
That stackexchange post is very, very good. Points just for bring that out.
[+] ekianjo|12 years ago|reply
It's also a legacy issue: once developers start using DirectX, it's harder for them to go back, and traditionally PC development has been Windows-only (more or less) for many years. Now that the market is becoming fragmented again between different platforms, there is more incentive to go for a cross-platform API than before - and that's where standards matter.
[+] noselasd|12 years ago|reply
OpenGL was not in any way shit when DirectX started overtaking OpenGL.

It became so around the time GPUs started being programmed by shaders - prior to that era OpenGL was quite pleasant compared to DirectX, yet DirectX mostly overtook OpenGL

[+] fritz_vd|12 years ago|reply
thank you.. this is awesome.
[+] pjmlp|12 years ago|reply
Again that post. Spreading the lie that all game consoles support OpenGL.

Yes, OpenGL is a great API if one cares about portability and FOSS.

Reality, the game industry cares about their IP and getting games released no matter what technology stack is used.

Many AAA studios don't even develop for all platforms, rather target a main one, leaving the port to subcontractors.

Back in the golden days of the arcades, many subcontractors were not even given source code. There are plenty of subcontractor stories about having to play through games while taking pictures or recording on tape.

When you have development processes like this in place, the gaming API doesn't matter that much.

[+] exDM69|12 years ago|reply
> Many AAA studios don't even develop for all platforms, rather target a main one, leaving the port to subcontractors.

AAAs are one thing and are mostly based on engine technology that has been in development for years. For them D3D vs. OpenGL is a non-issue that was solved a decade ago. Or they stick to being Windows only. And they have the budget to port (or hire a subcontractor to port) one way or another.

For indies, on the other hand, the most money these days is (probably, don't have any stats at hand) coming from Android and iOS, which both use OpenGL (ES). Using off the shelf game engines is a very popular option but a lot of developers roll their own tech.

[+] jheriko|12 years ago|reply
At the time this was accurate, that generation all supported OpenGL in some form...
[+] AshleysBrain|12 years ago|reply
Isn't mobile and the web the decider these days? Article is from 2010, but consider if you want to develop 3D on any of these platforms:

iOS - OpenGL ES

Android - OpenGL ES

Mac - OpenGL

Linux - OpenGL

HTML5 - WebGL (based on OpenGL ES) - even in IE!

Emerging platforms like Tizen, Firefox OS - OpenGL ES/WebGL

DirectX is just for Windows and Windows Phone. Isn't it getting to the point where the bother of having to write a DirectX port might cause developers to skip the Windows platforms, or stick to OpenGL on Windows desktop? Windows isn't as overwhelmingly important as it used to be, and couldn't the fact that DirectX is different start to work against MS? Imagine if Blackberry came out with their own custom 3D API - wouldn't that only serve to hurt them?

[+] moep|12 years ago|reply
My hope is that the SteamOS/Steam Machines movement will finally tip the scales in favor of OpenGL. A "killer app" that is fully OpenGL optimised with a delayed or worse performing DirectX port would seal the deal. If only Valve had more franchis3s...
[+] pjmlp|12 years ago|reply
Game consoles - proprietary 3D APIs

OpenGL != OpenGL ES != WebGL, yes they are all based on the same concepts, but require separate code paths and different shader versions.

[+] EpicEng|12 years ago|reply
Yeah, if all you care about is candy crush and the random pay to win adventure game. No one is playing "real" games on tablets or phones, nor will they be anytime in the foreseeable future.
[+] rpedela|12 years ago|reply
Isn't PS4 OpenGL as well?
[+] kayoone|12 years ago|reply
Isn't this more or less a problem of the past?

Today with tools like Unity3d, UDK, CryEngine, Shiva Engine, MonoGame etc, game developers are at a point where they can pretty much stop worrying about the OpenGL/DirectX layer beneath their engines. Those Engines have become so powerful and affordable that it hardly makes any sense to roll your own. In fact, imo you would need a very strong reason to build your own engine these days instead of focusing on your product.

Soon all of these will support WebGL/HTML5 as a target and even render most of the (still very basic) WebGL engines obsolete.

Now if you were in the business of creating your own tools or engine, you would need to support both of OpenGL and DirectX to be able to support all the major platforms anyway.

[+] exDM69|12 years ago|reply
> Isn't this more or less a problem of the past?

Yes and no.

If you want to be writing a typical 3d game like an FPS, and RTS or 3rd person platformer, you can and probably should use an off the shelf 3d engine and stay away from the lower level APIs, OpenGL and d3d.

However, if you want to do something more exotic, say processing your webcam input stream with your GPU, or write a space scale render of the solar system or do anything that diverges from the use cases you typically use 3d engines for, you might still be better off using D3D or OpenGL directly.

Then there are aspiring future game engine programmers and hobbyists who want to use OpenGL directly. It's arguably more interesting than paying for a 3d engine but it's more work of course.

So most people do not need to touch D3D and OpenGL, in the same way that most people do not need to write C. But some people must and some people want to.

[+] dualogy|12 years ago|reply
> Soon all of these will support WebGL/HTML5 as a target and even render most of the (still very basic) WebGL engines obsolete

Uh, most of those have their core runtime engine written in C++ and are probably not itching to port their CPU-side code to JavaScript.. Porting to WebGL is only trivial for the GLSL shaders, nothing else. If anything, these companies are waiting and holding out for either PNaCl/ASM.js/Emscripten to be able to generate fast fully-working web-compatible engine code.

And those engines aren't just loading 3D models and blit them to the screen, at least that's not their selling point. They have their occlusion culling system .. particle systems .. animations .. hardware audio .. fake wind simulation .. rudimentary pathfinding .. a reasonably fast terrain renderer .. some physics engine intimately integrated into the whole thing.

You wanna port all that to JS? Go right ahead!

[+] hpcorona|12 years ago|reply
> Isn't this more or less a problem of the past?

You are using Unity 3D, so NO, it's not a problem of the past. You have multiplatform because Unity developers decided to go with OpenGL.

[+] frik|12 years ago|reply
This articles is from 2010 and is really dated.

Even Microsoft supports WebGL (based OpenGL ES 2) in Internet Explorer 11.

Beside that the article doesn't mention that OpenGL 2 came late (and 1.x is way outdated). And to bootstrap OpenGL 2+ on Windows you still need a OpenGL 1.4 context to create an OpenGL 2+ context. So not so trivial at all :/

As the article is pre-smartphone era: the future for OpenGL/WebGL is very good now. You can run WebGL on every device/OS (beside Windows, OpenGL 2/3 but no ES driver).

[+] gtirloni|12 years ago|reply
It's funny how many old stuff (that is supposed to rely on current data) is posted on HN. I am still getting used to this.

I was reading the article and he mentions WinXP is half of all gamers.. I couldn't believe my eyes. These things should come with a disclaimer here like "really really old stuff, i just want to pick a few points from it which are this and this. ignore the rest".

[+] jheriko|12 years ago|reply
this is old, its also wrong in many ways. i keep hearing 'OpenGL' is cross platform.

This is a quantifiable lie. I have written cross platform rendering engines and worked with many, I can tell you right now that platform and vendor specific hacks for OpenGL are a necessary evil if you want your stuff to work properly.

If you are working in a cross platform environment you abstract away rendering then whether you are using DX or OpenGL (or anything else - RSX, or whatever...) is not really important.

The question I always wonder is why OpenGL isn't this... if I can make it so can anyone else, absolutely. Its not hard or especially time consuming and gives you the power of actually being cross platform.

This is a constantly improving situation though... for example I no longer need to tell a large number of Intel graphics cards that clockwise is infact counter-clockwise for face winding - because they are obsolete and the drivers have improved. There are still many problems of that nature though... you might not realise that the driver is processing your vertex shader on the CPU for instance which makes for a significantly different performance profile to similar hardware in that class...

[+] Tloewald|12 years ago|reply
The big problem for OpenGL was (a) Windows platform dominance, particularly in gaming, and (b) weak support for rapidly improving 3D hardware (but that was largely a case of already in progress network effects -- OpenGL drivers suck because very few people care, so even fewer people use OpenGL).

OpenGL was kept on life support in the aughts by high-end 3D products which are often cross-platform (e.g. Maya), and Apple (which switched to OpenGL from QuickDraw 3D after the spectacular failure of the latter -- incidentally OpenGL being "open" was SGI's proactive defense against QuickDraw 3D), and then rebuilt the entire Mac UI architecture on top of it.

OpenGL ES and iPhone have completely revived OpenGL's fortunes -- there's nothing much to worry about now unless Android and iOS both fail in the marketplace.

(It's entertaining that the Stackexchange post linked elsewhere was written more-or-less as a final "this is why OpenGL died" -- it's not dead yet... getting better...)

[+] treeform|12 years ago|reply
It feels like a lot and nothing has changed since that 3.9 year old blog post. On one had webGL, steamOS, Mac games, iOS games, and Android Games. On the other hand gaming PC is still a windows PC. What are your thoughts?
[+] acgourley|12 years ago|reply
Most importantly tools like Unreal / Unity3D are so good you almost stop caring if you're running onOpenGL or Direct3D. And this of course is very bad news for windows as the only PC gaming option.
[+] EpicEng|12 years ago|reply
I don't write games, but I certainly do play games. Cross platform titles always run better on my Windows install. Always. So, yeah, Windows for games, I don't really care about the politics.
[+] goldenkey|12 years ago|reply
DirectX has a way better API which might be why. DirectX has been COM oriented, OOP design, for years. While OpenGL was handle-based, purely procedural.
[+] Shish2k|12 years ago|reply
A series of relevant tweets from https://twitter.com/wolfire :

My old OpenGL vs Direct3D post is #1 on hacker news! https://news.ycombinator.com/item?id=6852961 Maybe time for a 2013 update -- a lot has changed since then.

1. D3D 11.1+ only supports Windows 8, which only 20% of Steam users have. OpenGL 4.4 works on all versions of Windows.

2. NVIDIA and ATI both now have good profiling and debugging tools for OpenGL that were formerly only available for DirectX

3. OpenGL Core is now lean and mean, making it easier for hardware vendors to create efficient and correct drivers.

4. Valve now strongly supports OpenGL with their own games and with SteamOS -- helps ensure the future of OpenGL itself, and vendor support.

5. Humble Indie Bundle creates an extra commercial incentive for indies to support Mac and Linux, which is much easier if you use OpenGL.

6. All the old points still stand -- OpenGL works on Mac, Windows, Linux, Web, iOS and Android. Direct3D only works on Windows and XBox.

[+] info128|12 years ago|reply
These are all good points, however, another very important point is driver quality / vendor support. For non-hardcore gamers, it is not uncommon to run Windows default drivers, which often have very poor OpenGL support and/or performance. I would love to see the Steam hardware survey list vendor provided vs driver support for OpenGL.

I think developers may be driven away from using OpenGL at least partially based on worry about driver support. Using Windows this is a non-issue if you stay within DX10 and Windows 7/8. According to Steam Survey, this accounts for 81.61% of users. This drops down to 56.2% for DX11.

In short, until vendor OpenGL driver support is a given, many developers will stick with Windows and Direct3D.

Another note, this one on cross platform compatibility - the limitations of OpenGL ES2.0 are problematic for anything beyond rudimentary shaders. The primary limitation right now in my mind is a shortage of uniform vectors, and the wide variance in size for different android hardware. For instance, a smooth skinning (matrix pallet) shader for skeleton-based deformation will be limited to 5 or 6 joints per mesh on most android/OpenGL ES devices, whereas most x86/OpenGL systems allow for hundreds of joints. Similar limitations apply to pixel shaders as well - post processing such as blur, bloom, dof, and SSAO are not feasible on current generations of android devices for production use.

Of course android device GPUs are getting much more powerful with each iteration, and eventually will provide a good hardware base for advanced graphics engines.

For now, though, the idea of porting a full OpenGL graphics engine with advanced shaders to OpenGL ES2.0 is pretty much a re-write of the engine. This, combined with limited CPU and memory performance, is the primary reason we don't see AAA titles showing up on Android devices yet.

A lot is coming down the pipe in terms of hardware advances, though - I'm excited to see OpenGL support grow in parallel.

[+] be5invis|12 years ago|reply
One of my friend, a game developer, said that, once you get familiar with the DirectX 11, you will not want to use any other APIs. They look outdated.

And seriously, the GNMX API (a high level wrapper of GNM) of PS4 has more similarity to DirectX than OpenGL.

[+] girvo|12 years ago|reply
Game developer, or engine developer?
[+] girvo|12 years ago|reply
I'm amazed at the comments here on this thread... Personally OpenGL is strictly superior to DirectX, solely due to being cross platform. With the release of the Steam Box and a push from Valve to look at Linux as a first class target for games, hopefully we'll see development proceed to create better tooling to rival that and exceed DX.

This is good for all of us consumers, as the lock in inherent to the technology choices made my game devs will be diminished. I can only see that as a good thing.

And besides, middleware is getting so good, how many of us really need to hack on an engine anyway. My games logic is done in Lua, not C/OpenGL :)

[+] Narishma|12 years ago|reply
I don't know of anyone who does game logic in OpenGL.
[+] ewzimm|12 years ago|reply
For a 4-year-old post about the progress of Overgrowth, it doesn't really convince me to use OpenGL, considering that Overgrowth is still in alpha. It's a 4-person team and an ambitious game, so I'm sure it's not related to OpenGL use, but it's still kind of funny.
[+] jasin|12 years ago|reply
Portability etc notwithstanding and purely from an API point of view, there's no question that DirectX is superior to OpenGL. There are lots of examples, but the mere fact that you need _another_ 3rd party API such as GLEW even to be able to use OpenGL's latest features in the first place should speak volumes.
[+] vetinari|12 years ago|reply
You don't _need_ GLEW, it is just convenience library.
[+] romanovcode|12 years ago|reply
>However, there's one big problem: they don't work on Windows XP! Half of PC gamers still use XP, so using DirectX 10 or 11 is not really a viable option.

This problem does not exist anymore.

[+] spikels|12 years ago|reply
And since this article was written Microsoft has pretty much admitted defeat by incorporating WebGL (a simplified version of OpenGL) in IE11.
[+] davexunit|12 years ago|reply
You should use OpenGL because DirectX is proprietary and only available on proprietary operating systems. Simple as that.
[+] GnarfGnarf|12 years ago|reply
Why does Unity use DirectX on Windows, and OpenGL elsewhere?

You'd think once they went to the expense of porting to OpenGL, they'd re-use that code on Windows? Or is it because they get better performance with DirectX on Windows?

[+] pjmlp|12 years ago|reply
They get better performance and more stable drivers.

Many cheap computers have GPUs with shitty or non-existent OpenGL drivers.

[+] JimmaDaRustla|12 years ago|reply
Microsoft use to be on the OpenGL board (I believe in the 90s?). OpenGL was geared towards scientific development, and we know Bill Gates wanted PC to be gaming platform. OpenGL at the time wasn't good enough, nor were they willing to make the necessary changes to meet Microsoft's goals.

DirectX was born out of necessity, not proprietary greed.

Edit: Maybe its time to take another look at OpenGL - open is better than closed, especially for the multi-platform aspect. But does it have the same features as DirecX? Tesselation, shader programming, etc.