Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Direct3D be used over OpenGL in Windows?

Since Microsoft is generally a bit bias toward Direct3D, would a scene using VBO's in Direct3D be faster than the same scene using VBO's in OpenGL, or would it be the same since it's up to the Graphics Card driver? Thanks

like image 598
jmasterx Avatar asked Jun 30 '10 04:06

jmasterx


3 Answers

Performance-wise, and assuming decent GPU drivers, there is no difference overall.

Some operations are inherently faster in OpenGL than in DirectX9, although DX10 remedied that.

But a good rule of thumb when working with external hardware is that it's not the API you're using that determines performance.

When writing network code, the bottleneck is the network adapter, and it doesn't matter if your socket code is written in .NET, plain Berkeley sockets in C, or perhaps using some Python library.

When writing code to use the GPU, the GPU is the limiting factor. The biggest difference between DirectX and OpenGL is that one might require a function call or two more than the other to achieve certain tasks -- and the performance cost of that is pretty much nonexistent. What happens on the GPU is the same in either case, because that's determined by your GPU driver, and because both OpenGL and DirectX try to be as efficient as possible.

There are valid reasons to prefer either API though.

DirectX has much better tool support. Microsoft does an extremely good job of that. Debugging and optimizing DirectX code is much easier with tools such as PIX. And Microsoft also provides the helper library D3DX which provides efficient implementations of a lot of commonly used functionality.

OpenGL has the advantage that it's not tied to a specific OS. DirectX9 only works on Windows. DX10 and above only works on Vista and above.

OpenGL works on any OS where an OpenGL driver has been written.

On Windows, the situation is sometimes a bit awkward though. Windows itself only comes with ancient implementations of OpenGL. (XP with v1.1, I believe, and Vista/7 with 1.5).

So OpenGL apps on Windows rely on the GPU vendor to provide an updated implementation with their drivers. ATI and NVidia do provide very good implementations, so it's not that much of a problem. Intel's OpenGL drivers are generally lagging behind, both in quality and in supported features.

like image 121
jalf Avatar answered Oct 07 '22 15:10

jalf


See some related questions -

OpenGL still better than Direct3D for non-games?

OpenGL or Direct3D for a new Windows game project? Or something else?

Microsoft is right now hugely biased towards Direct3D. Many low-end Intel integrated cards don't ship with OpenGL drivers by default, or if they do they only support older versions/specs of OpenGL like 1.2/1.4. If you are targeting such machines (Intel has a 50% graphics market share), it will be difficult to take advantage of the more advanced features like shaders (which became available in OpenGL 1.5). Whereas, you will be able to use similar shaders in Direct3D, because of the availability of better drivers for these low-end cards. Of course, with Direct3D works only on Windows.

If on the other hand you don't really need to use shaders you may go with either Direct3D or OpenGL. Although I would tend a bit more towards OpenGL. It is cross-platform and everyone supports it apart from Microsoft. Some things, like drawing lines (of various widths) are also much easier in OpenGL. OpenGL also has a picking mode built into it which is far more robust than ray picking (especially if you want to pick points and lines).

A third option is to use an abstract API or an existing engine which can render to both OpenGL and Direct3D.

like image 45
tathagata Avatar answered Oct 07 '22 16:10

tathagata


It would generally be about the same. There was a time that DirectX had a distinct speed advantage over OpenGL, but for most practical purposes, that's ancient history.

like image 23
Jerry Coffin Avatar answered Oct 07 '22 15:10

Jerry Coffin