Advertisement

OpenGL vs Direct3D

Started by May 24, 2017 07:30 AM
3 comments, last by Cwhizard 7 years, 6 months ago

I'm looking for honest opinions about which would be better for developing a hobby game, not my first game but my first 3D game. I have worked a little with very basic Direct3D and OpenGL. So from a programming standpoint I don't see an issue going either route.

This is one of the big questions in life. Is there a god? Are we alone in the universe? What's the best text editor? Should I use OpenGL or Direct3D?

At least with this one there is a simple answer: You definitely want to use OpenGL, unless you want to use Direct3D.

blah :)
Advertisement
Stability / hardware portability: D3D is written once by Microsoft and they also test and validate drivers to keep the vendors in line. GL is implemented from scratch by each GPU vendor and will behave differently on different hardware, and there's no umpire like MS to keep them in line. D3D destroys GL here.

Desktop OS portability: GL is also implemented on Mac/Linux. GL wins by no contest.

Console portability: D3D runs on Microsoft consoles.

Shaders: I personally prefer HLSL (D3D) well over GLSL, but your tastes may vary.

Shader build pipeline: HLSL has an official MS compiler. GLSL forces you to ship source code and compile it on the user's PC. For consistency this means you should really compile your GLSL to custom bytecode in a custom optimizing compiler, then decompile them back into optimized GLSL to ship to your users :(

API legacy mess: D3D9/11/12 are three completely separate APIs. GL1/2/3/4 are all extensions and depreciation of the same API. If you accidentally use old GL functions, they'll often still work on some drivers even though it's technically wrong. This can make finding good tutorials quite confusing.

API simplicity: I personally find D3D11 to be much cleaner and simpler than GL3/4, but this varies person to person.
D3D9 and GL1/2 are both a complete mess so we'll ignore them. D3D12 is a competitor to Vulkan so we'll ignore that too.

Extensibility: D3D has no official extension mechanism, but the NVSDK and AGS libraries expose some extensions from each vendor. GL supports extensions as a core feature and has extensions for absolutely every bit of custom hardware out there.

Development: My favourite debugger is RenderDoc, which supports both GL and D3D. D3D also comes with an official debugging layer that is optionally emabled, which can be configured to break on any API usage errors, so that your IDE breaks into the debugger right on the incorrect line of code.

Speed: D3D11 is more efficient than GL and has less performance pitfalls (e.g. GL will sometimes emulate missing features instead of simply reporting that an operation is unsupported).

Documentation: I like MSDN's D3D documentation, and the fact that there is an official SDK containing examples. I like that GL has a very thorough specification document that says exactly how it should work.

My personal choice is that because D3D offers a more stable development environment, I prefer to primarily develop for D3D and then port to GL if/when I need Linux support.

If you have passing familiarity with both, just pick whichever seems best to you from a practical standpoint.

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

Thanks Hodgman and others who replied. I am leaning towards DirectX at this point, since I do have some experience writing commercial code for DirectShow. The books I have on graphics are sort of 50/50 DirectX and OpenGL.

This topic is closed to new replies.

Advertisement