开发者

Should Direct3D be used over OpenGL in Windows?

Since Micr开发者_JS百科osoft 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


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.


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.


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.


You can try it out for yourself if you'd like. Ogre3D is a great 3D library where, when you start, you can choose if you want to use DirectX or OpenGL. If I remember correctly (it was 3-4 years since I used it) they had frame rate and other data even in their examples, where you can see which one is faster.


Actually, this really depends on the type of project you are doing.

If you ever want to port it to a different platform - don't use DirectX. If you want total control and a fast developing library on Windows, DirectX is the way to go. If you find a graphics engine with all the functionality you need - use it. It's easier than using plain DX or OpenGL, especially if it supports a tool chain (level editor, import of models from 3d modelers, ...).

If you want to learn DX, go for DX or SlimDX. If you want to learn OpenGL, go for OpenGL.


Use middleware. Ogre is good if you want something with a lot of features (loading 3D models and animations, etc). SDL is good if you just want a simple wrapper.

In answer to your actual question, it comes down totally to the drivers. And that varies between manufacturers. My understanding is that right now, GL is not well-supported by all the main companies (nVidia, ATI, Intel) which is a big issue.

Personally I'd use middleware, but lean on testing/developing mainly for D3D.


I would choose DirectX. It's improving and evolving rapidly- much faster than the OGL committee can move. Extension hell anyone?


Be warned GL drivers on Windows are generally pretty flakey and buggy. OEMs generally do very little work with GL driver under windows. Just enough to keep the latest id game working well. Which is a pain if you do things differently.

What you should do is write an abstratction layer between the 2 and implement both back ends. This gives you the best of both worlds. The stability of DirectX under windows and the cross platform-ness of OpenGL. It also gives you the huge advantage of being able to add some future rendering back end in there if you want.

Its also worth noting that X-Box and DirectX are different enough to mean you'd need a seperate back end for both platforms were you to attempt such a thing anyway.

Personally my engine supports DX9, DX10, Open GL3, OpenGL ES2.1 and I'm far happier to have the abstraction layer :)

Edit: As per the comments I would point out that the nVidia drivers ARE the least flakey windows OpenGL drivers. Pretty much every other manufacturer has problems. Even nVidia has a lot of problems. A lot of the time, in my experience, you end up battling against a driver where things "just work"(tm) with DirectX.


I used to use OpenGL, but for now im interested in exploring the world of DirectX. The cause is the release of DX11 which ends the long protracted war on Windows.

The Khronos Group soon released OpenGL 4 to fight back; sadly OGL4 still has half amount of new features missing or lagged behind; and some of them are vital in terms of creating a flexible 3d framework.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜