views:

388

answers:

10

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

+2  A: 

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.

Jerry Coffin
> The fact that there was no fast OpenGL software renderer was more an artifact of history than of API design, even though we game graphics people thought it was fundamentally broken, since it didn't match up with our notions of how 3D graphics should work. SGI eventually released a competitive software OpenGL just to fight the FUD coming out of Redmond. http://chrishecker.com/OpenGL
Arthur Kalliokoski
+2  A: 

See some related questions -

http://stackoverflow.com/questions/124851/opengl-still-better-than-direct3d-for-non-games

http://stackoverflow.com/questions/39092/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.

tathagata
Not going to downvote, but what advanced shaders can be written in D3D that cannot be written using OGL? Please name just one.
Sorry, didn't mean that it cannot be written in OpenGL. What I wanted to say was that the default drivers that Microsoft ships for Intel cards support only upto OpenGL 1.2/1.4, so you cannot use advanced shaders, although they are available and might be supported by the card using latest drivers.
tathagata
@tathagata: Your answer very strongly suggests that OpenGL is not capable of "advanced shaders." It most definitely *is* capable of "advanced" shaders, and most of the shader features showed up in OpenGL extensions long before they showed up in DirectX. Even DirectX's HLSL was derived from one of the shader languages used in OpenGL. (Which I think was NVIDIA's Cg, but I could be mistaken.)
greyfade
Hmm... okay I will edit the answer to clarify it further
tathagata
Cg is a 'cross-platform' shader language, which compiles to D3D/GL shaders. HLSL came in with DX9, it is very similar to Cg but I don't know which came first.
John
Keep in mind that the Intel GPU's that don't provide proper OpenGL drivers are so crippled they can't really run DirectX efficiently either.
jalf
@John: Cg came first. I know it was used as the basis for Microsoft's HLSL, and I think it influenced GLSL as well. Prior to that, GL provided extensions to more low-level shader programs.
greyfade
A: 

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.

Default
A: 

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.

Tobias Langner
A: 

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.

Goz
I don't know where your notion of buggy GL drivers on Windows comes from. In my experience, they are no better or worse than the Linux drivers -- at least for nVidia the majority of the code is the same anyways.
eile
@eile, I think Goz means compared to windows/DirectX drivers. Particularly Intel chipsets, they claim OpenGL2.1 but the one on my laptop can't even draw simple lines properly.
Martin Beckett
A: 

Answer deleted as inaccurate or irrelevant

developer
I read all of that without really knowing which side you are on. It seemed like a pro-OS tirade but then you end by staying MS. For choosing low-level graphics layer, it seems fairly minor if it's OS or not.
John
It's also not true. OpenGL isn't open source. (Although individual implementations, such as Mesa, might be)
jalf
OK I appear to have a mistake about the open GL being open source.At which point the argument becomes irrelevant. As far as being a pro-OS tirade I think that tirade is a strong term. Both open source and proprietory systems have their merits but the open source argument seems to be being forgotten. The reasons for chosing Open Source or proprietory should be looked into. It is healthy to understand the pro and con arguments. One gets better understanding of a problem if one does not ally oneself to an ideological camp at the exclusion of another.
developer
A: 

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.

John
A: 

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

DeadMG
To be fair, the evolution of OpenGL has sped up a lot in the last 2 years or so. They're much more competitive today than they've been for probably the last decade.
jalf
@Jalf: have they made up for the bitter disappointment of version 3.0 yet?
Kylotan
@Kylotan: Nope, not yet :(
Goz
+11  A: 

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.

jalf
A: 

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.

dex
Something to think about: OpenGL 3.3/3.2 allows you to use geometry shaders on WinXP. DirectX doesn't, because geometry shaders are supported only on DX10/11, which is vista or windows7. "and some of them are vital in terms of creating a flexible 3d framework." I disagree with that part. Ability to create flexible framework is matter of programming skill only. API doesn't matter, good programmer should be able to create flexible framework regardless of API. Take a look at "Blade of darkness" - they created real-time shadows, dismemberment and relatively good water on DX7 hardware...
SigTerm
yap, so why can't they achieve high quality rendering like on CPU? Only performance reasons? Certainly not. They created a flexible gaming engine framework not a general purpose rendering framework. Can't you see rt ray-tracing only becomes possible when GPGPU programity advances?I'm not arguing that how you can adapt to different platforms but the ability to rendering. This is twofold: 1.ability to allow various algorithms; 2.Good engineering.(Some coding structures heavily rely on hardware specific features. Theoretically,you can impl anything using infinite many codes but impractical)
dex