OpenGL vs DirectX

Started by
14 comments, last by 21st Century Moose 11 years, 7 months ago
It sounds that you perceive these APIs as completely different beasts. Actually, these are very, very similar. In the end both need to access the gfx card drivers that do the real work. There are differences, but these can be named best as "slightly". DX is considered slightly faster, slightly harder to learn, has slightly less problems with outdated drivers (and all of these points are contested by numerous people, so even at these you won't get a 100% agreement). I again stress the word "slightly". In the end it's mostly about convenience and personal taste of the coder...

The only big difference I can think of is that OpenGL is extremely crossplatform while DX is tied to MS platforms.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement

Well, here is an example of the kind of contradiction that I read: Sources are publishing that DirectX is more software involved than hardware accellerated compared to OpenGL, but some such as yourself are not making the distinction, with all respect.


Clinton


Direct3D has a larger official support library(D3DX) Which is software only ofcourse but the hardware accelerated features are pretty much equivalent. (OpenGL doesn't have any official software support library anymore, (glu and glaux are software support libraries for OpenGL but both are deprecated and horribly out of date) There are tons of third party support libraries to choose from though if you want and Microsoft is deprecating most of its support library for DX with Windows 8, (Pretty much noone uses it for professional games anyway and since the two APIs have become so similar most of the third party support libraries work just fine with both APIs)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
I'll preface this by saying I am (almost) exclusively an OpenGL user. I found DirectX cumbersome, as I tried to learn it simultaneously with C++ - this was out of a 10 year old book, so I imagine it was something like DX7 and a lot less streamlined. OpenGL automagically worked for me at the time, so I never honestly looked back. I still kept up with research, however. Ironically, this automagic property of OpenGL has almost universally been deprecated, but I digress.
The reason why I am opening this discussion is because the information about these issues is so spread and muddled with opinions. My goal is to more centralize the subject of OpenGL and DirectX for convenience. Also given the blistering fast pace of both OpenGL and DirectX changes in games, I want the latest perspectives.
Besides choosing one API over the other due to being unable to use the other (say, D3D for working with your favorite engine, or OpenGL for a wii game) there is no objective means of choosing one or the other, and so all you can ever hope to get is a wide spread and opinion muddled set of responses. I can say that most major game developers favor D3D because it's the traditional API that has been in use for quite some time. Familiarizing yourself with it from a professional game development standpoint is a wise decision... but OpenGL targets dozens of platforms, whereas D3D is quite limited. If you care at all about portability, D3D becomes a very poor choice.

Is OpenGL going to involve more advanced work for the game developer, yet greater flexibility in the long term?
Arguably. OpenGL is very minimalist, especially since 3.1. There are several "handy dandy" things that it simply does not do for you the way D3D does. It's still just as capable of doing them, but OpenGL does not define a default way of doing it (copying a texture to a texture, for instance, requires you to use framebuffers or pixelbuffers - the closest thing, glCopyTexImage2D, draws from the bound buffer) nor is the ARB interested in adding many convenience features. The difference in difficulty between D3D and OpenGL in this regard boils down to an occasional dozen or so lines of code. Not much, but "arguably" more.

It is also arguably more flexible, but only in that it is significantly more portable. Writing linux or mac games in D3D instantly makes WINE necessary at a cost to FPS (as WINE must redirect D3D calls to OpenGL), and I'm not sure if the Wii and PS3 support D3D at all. But while they had significant differences in the past, now they're both effectively equivalent in features. Games using one API do not suffer graphically over another - however, some designers may prefer the "style" or "approach" one API uses over the other, and like me, find it annoying to use the conflicting style.

Doesn't the hardware accelerated 3D nature of OpenGL offer more potential for game features because software processing could be run simultaneously with hardware acceleration to broaden the game engine base - so to speak? Isn't hardware acceleration offering the most potential for game performance and more 3D objects and 2D textures allowable?
They're both hardware accelerated, and most often have very close benchmarks. One might outperform the other at some specific operation or other, but overall there is no speed advantage to either. This is not an advantage for OpenGL.

Three questions answer which API to use:
--Looking to be familiar with rendering schemes of major AAA titles ? DirectX : Either //neither is better, but traditionally D3D is used. OpenGL is also used, but much less.
--portability matters ? OpenGL : Either //DirectX has no portability
--Prefer OpenGL Style ? OpenGL : DirectX //Purely your opinion

Remember, however, that DirectX is more than D3D. If for whatever reason you hate all DirectSound alternatives (FMOD, OpenAL, ect) or DirectInput alternatives, then DirectX trumps OpenGL by virtue of your project already using it elsewhere.

It is also arguably more flexible, but only in that it is significantly more portable. Writing linux or mac games in D3D instantly makes WINE necessary at a cost to FPS (as WINE must redirect D3D calls to OpenGL), and I'm not sure if the Wii and PS3 support D3D at all.
Wii uses a proprietary API (similarly designed to GL) called GX, and the PS3 has a proprietary API called GCM, which is much more low level than GL or D3D. The PS3 also has a wrapper called PSGL, but this is different to "Desktop GL" and is a translation layer (like Wine's D3D->GL layer). The 360 has a proprietary API that's quite similar to D3D9.

IMHO, the portability of OpenGL is a bit of a red herring.
On Windows/Linux, the OpenGL runtime is almost entierly implemented by your graphics driver, and there is no governing authority to ensure standards compliance -- it's industry self policing only. This means that vendors can and do violate the standard in ways to hurt each other -- e.g. nVidia drivers accept HLSL syntax in GLSL shaders, with the hopes that developers may ship such shaders, which will appear broken on ATI/Intel GPUs...
On the other hand, Apple keeps a much tighter grip on things (like Microsoft does with D3D), so OpenGL on Apple OS's is going to be a lot more reliable.
So the 3 platforms that GL gives you portability to -- Linux/Windows and Apple -- all actually may behave slightly differently. You still need to test your renderer separately on each platform, and on Windows/Linux, you also need to test your renderer on GPUs from each manufacturer, as each of these tests is against a completely different implementation of the OpenGL runtimes.

Also, if you want to support the latest SM5 GPU features, but also support scaled-down versions of your renderer for SM4 and SM3 GPUs, then you've still got to "port" a lot of your rendering code no matter the API.
On Windows with D3D, you'd have to maintain a D3D11, D3D11_feature_level_10 and a D3D9 version of your renderer.
With GL, you'd have to maintain a GL2, GL3 and GL4 version of your renderer.

So a "cross platform" renderer has to maintain and test code for:
Consoles: GX + GCM + "D3D360" + any other consoles
Mac: GL2 + GL3 [s]+ GL4[/s] [edit]SM5 level GPUs not supported by apple[/edit]
Linux: GL2 + GL3 + GL4 multiplied with ATI + nVidia + Intel
Windows plan A: GL2 + GL3 + GL4 multiplied with ATI + nVidia + Intel
Windows plan B: D3D9, D3D11_10, D3D11
Mobile Phone: GLES1 + GLES2 multiplied with each Android + iOS device

Yes, sharing common GL code paths might be able to save you some time, but no matter which APIs you use, it's going to be a hell of a lot of work.

glu and glaux are software support libraries for OpenGL but both are deprecated and horribly out of date.

Yeah, that's true, and sure they're not officially supported but freeglut and glee are nice extensions.
I use them both everyday, and they're updated quite often...

So a "cross platform" renderer has to maintain and test code for:
Consoles: GX + GCM + "D3D360" + any other consoles
Mac: GL2 + GL3 + GL4
Linux: GL2 + GL3 + GL4 multiplied with ATI + nVidia + Intel
Windows plan A: GL2 + GL3 + GL4 multiplied with ATI + nVidia + Intel
Windows plan B: D3D9, D3D11_10, D3D11
Mobile Phone: GLES1 + GLES2 multiplied with each Android + iOS device

Yes, sharing common GL code paths might be able to save you some time, but no matter which APIs you use, it's going to be a hell of a lot of work.


When did Apple add OpenGL4 support ? (Last time i checked they had just added OpenGL 3.2 in Lion and i don't think Mountain Lion added anything new in that area). (Apples tight grip might keep things consistent but they do lag behind quite a bit when it comes to supporting new features)
[size="1"]I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!
Neither are bad and both have matured well enough, appropriately and look to be continuing to do that. If the platforms you're targeting don't force the decision somewhat, then I'd look into both and make a personal decision based on preference. I'd also say that if you have the time, consider doing both anyway...your own software architecture will be much stronger when based on concepts supportive of both targets.

So...find a reason to rule one or the other out (such as platforms) and make the decision easy for yourself if possible, if that's not an option try both and make a personal decision and if you can afford the time and effort, do both, or at least do one in full and keep your hand in the other anyway.

Either way, never say never. I did that and was never a fan of Mac's, so if five years ago someone was to suggest to me that I'd have spent last year on Open GL ES doing mobile and this year on Open GL 3.2 and Mac, I'd have thought they were on crack yet it's been surprisingly good fun. The Mac is a fairly decent platform for OpenGL development actually.

Direct3D or OpenGL...you'll have good fun on either or both paths regardless.
They both work, they're both good, they're both fun to use, so choose either but in the longer term aim to learn both.


Doesn't the hardware accelerated 3D nature of OpenGL offer more potential for game features because software processing could be run simultaneously with hardware acceleration to broaden the game engine base - so to speak? Isn't hardware acceleration offering the most potential for game performance and more 3D objects and 2D textures allowable?


Okay, but isn't OpenGL more low level programming compared to DirectX? Isn't DirectX more friendly to scripting languages?


You seem to have some very suspect sources here. As pointed out above, both are hardware accelerated, and both are very low-level (OpenGL is actually a little higher-level than D3D as it abstracts some hardware concepts a little more; I suspect that whatever sources you're using may not have updated their info since sometime around 1996 or 97...)

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement