Why is OpenGL better than Direct3D?

This has been the starting point of countless flame wars on many message boards. But I have still found no answer to this very questiong.No one has given me one good reason why OpenGL is better than Direct3D.

To start off,I can honestly say that DirectX FAR surpasses OpenGL in terms of 2D graphics.That has already been established. But why is OpenGL better than Direct3D? From what I can tell,they both do the same thing on the same grphics cards and both of them have great API’s (totally based on my opinion)The only thing going for OpenGL that I see is that it is platform independant. However,to those programming their 3D applications for Windows,I can’t see why they won’t use DirectX.What better API to use for windows?

I am not trying to start a flame war mind you.I’m just seeking answers

yes, with d3d you can do as much as you can do with opengl, if not more…
but imo, opengl is better because it is:
-more elegant
-easier to learn
-more compact

when i was starting and i was wondering what api to choose, i took a look to d3d sources: a darn mess!
then i said “well, it’s such a popular API, why don’t give it a try?” so i coded my personal version of the hello world, a 3D starfield.
it took about 1 month to gather the needed knowledge, some days to code.

some time later i tried opengl with ms aux library… hey! just 3 days of reading and 1 hour of coding!

then, for me the decision was simple: stay with the opengl family, and never care about designing for d3d.

sometime, though, i have some look somewhere on the net… i see dx is constantly and fastly adding features (but it’s not improving in code quality) and that’s a thing that opengl lacks…

opengl is controlled by the arb, and any changes/addition/specs from the manufacturers has to be submitted to the arb, wich is a bit slow in approving things…

hope to have clarified thins up.

Dolo//\ighty

Well, I’d agree with dmy (once again ! I’ll end with asking you to marry me !).

First thing, I have never coded with D3D. But I had to port a program from Mac to PC. As I wanted to turn the visualization system from 2D to 3D, I had a look at the various 3D API available. As I ported FROM the Mac, I had a go with QuickDraw 3D (which at the time was supported on both PCs and Macs). Unfortunately, some days after I had completed the conversion, Apple announced they abandoned QD3D for OpenGL… So I started to have a look at OpenGL. Meanwhile, I found some code in my company : someone before me had tried to port the program using Direct3D…

As dmy said, the code was really awful (I mean, hard to read !).

One of my other objectives was to develop a version of the converted program for UNIX systems and Macs (yeah, port-back !). So I stuck with OpenGL and am very VERY happy with it…

As everybody on this board, I just hope that the ARB won’t make the mistake of not improving OpenGL constantly…

Regards.

Eric

P.S. : if I had to do Windows-Only programs, perhaps I would use D3D…

Thanx for the replies guys…I do respect your opinions of coarse,but that’s what they are…just opinions.What I was looking for was maybe some benchmark tests or something to show that OpenGL is truly better than Direct3D. What I found out from other message boards was that people hated DirectX just because it’s a Microsoft product (which,needless to say,is totally unfair)

As I said,I looked at both API’s and in my opinion I liked the both of them (I made a particle system in both OpenGL and Direct3D and they both turned out fine.Then again,I love programming in MFC so I prolly like messy API’s

Well, I don’t have a real benchmark but Tim Sweeny(Unreal) is saying everywhere that Direct3d is faster than opengl on windows.

I believe him, because the Unreal Engine is fast like hell and has a bunch of nice features.

But, you have to think that the code will be as fast as the programmer can make it!. If you worked with opengl all your life and try direct3d, well, the direct3d code will probably be slower than the opengl code.

You should also consider that how fast an OpenGL app or Direct3D app runs depends a lot of how well the drivers are written for each API. Some graphic board are better performers in OpenGL and some in Direct3D depending on which API the developer team had most in mind while developing it, and a lot of which drivers they prioritize to optimize.

I’ve tried both Direct3D and OpenGL, beginning with D3D.
I agree with all.

I want to point out, that if you think microsoft is having a monopole, and that you don’t want it to continue having one, you mustn’t only support MS OS.

Because OpenGL is platform indepent, you might want to use it.

About benchmarks, I can tell you for sure that OpenGL is more friendly to non standard architecture than D3D.
D3D devellopers don’t follow all the directives (late directives) from MS about the begin and end, killing rendering on scene captures cards like PowerVR.

Because the scene captures/tile rendering cards are really nice (see the Dreamcast) and more efficient than traditional architecture, you might prefer to use OpenGL to use them efficiently.

With nVidia pushing OpenGL features, I think OpenGL could/would stay a really good API.
Until now no fx can be achieved in D3D than can’t in OpenGL.

One other thing I want to point out, is that the OpenGL state machine has a scheme, while MS Direct3D looks like a black box in which you don’t know what happens, making it harder for you to speed up your engine.

This is not only an opinion.

Gecko, no benchmark will prove that OpenGL is better than D3D, or vice versa. OpenGL and D3D are specifications for INTERFACES, not implementations. Benchmark performance will depend on a combination of hardware, application design and (ESPECIALLY) driver.

My 2 cents:

  1. OpenGL is extremely portable. D3D isn’t.

  2. OpenGL has conformance specs. D3D doesn’t.

  3. OpenGL is stable - most functions will do nothing if an error occurs. D3D can do ANYTHING if an error occurs.

  4. OpenGL is well-behaved. D3D isn’t. When I was using it (around DX5), it didn’t allow any GDI call while the drawing surface was locked. So if you hit a debugger breakpoint inside drawing code, your machine did an immediate hard reboot. Nice.

  5. OpenGL code is small, readable, consistent, clean, easy to learn and just very nice to work with. DirectX is the ugliest interface I have ever seen in around 10 years of programming. Okay, this is just an “opinion”, but to me it’s an order of magnitude more important than any slight benchmark differences. I program graphics for fun, and at the end of the day OpenGL is fun and DirectX is not.

Couple of other points:

About Tim Sweeney’s comments - the performance difference for Unreal was, AFAIK, largely due to some texture management issues. Unreal did a fair amount of procedural texture generation, so the DX ability to directly access texture surfaces made a sizeable difference. Fair enough - I’m looking at procedural textures a lot myself - but this isn’t a typical app, and there were good reasons why OpenGL doesn’t allow direct access to texture mem. (It places major constraints on drivers/hardware; optimizations such as 3Dlabs’ virtual texture management just wouldn’t be possible.)

I’d add more, but this has all been said before and will all be said again, and I really doubt that it’s going to change anybody’s mind.

Closing thought. I know lots of people who use OpenGL and like it, and lots of people who use D3D and like it. I don’t know ANYONE who has used both APIs and prefers D3D.

Microsoft is illegal against the anti-trust-law, and has very high risk about its future. How can we use API of such a company? Due to illegal Microsoft, any additional function to its OS can be illegal.

Using such API implies the death of your project.

In fact, many companies cancelled the order of Office2000 since its arogant and illegal anti-competition methods.

OpenGL is much faster than Direct3D if the video board supports Transform & Lightning.

Most video cards will support Transform & Lightning in about 6 months, and they will support more OpenGL hardware specs.

OpenGL is the future.

Originally posted by skdir:
OpenGL is much faster than Direct3D if the video board supports Transform & Lightning.

How can you say that? Directx 7 support hardware T&L.

OpenGL is the future.

hmm… if only the ARB would be little more faster and flexible…

Hey skdir,

As for your first post,you’re stating that Microsoft will fall.Regardless to what you have set,this is not going to happen anytime soon.(actually,not for a long time) So whether Microsoft will be split up or whatever,there will always be a Microsoft.
(And ,no,using the Microsoft API is not illegal.And if you think Microsoft is dying then why are they still selling Windows2000 which is as stable as linux?)

As for your second post,DirectX 7 supports T&L so this basically destroys your second argument.

And OpenGL is the future to those who like OpenGL and DirectX is the future to those who like DirectX.This is ,once again,a totally opinion based statement.

[This message has been edited by TheGecko (edited 04-12-2000).]

>Regardless to what you have set,this is not going to happen anytime soon.(actually,not for a long time)

Wow, that is your illusion. How can a company survive violating the law?

Did you read the conclusion of the law? No one can criticize the logic and evidences of the conclusion, while Microsoft still insisted on innocent holding its illusion. Microsoft behaves as if it is the owner of the country.

More than 100 law suits are waiting. Not only in USA. There will be a big anti-trust-law suit in Europe, soon.

Unless Microsoft will seriously make plans to follow the law, it is surely dying.

>And ,no,using the Microsoft API is not illegal.

But good supports are not expected. Microsoft is now a certified monopoly. Any additional functions can be considered as illegal for a monopoly. No way for a monopoly to support an illegal business.

>As for your second post,DirectX 7 supports T&L so this basically destroys your second argument.

You did not read my sentence? I did not wrote Direct3D does not support Transforming & Lightning.

>they still selling Windows2000

Many dying companies are still doing business.

skdir is, I think, massively overoptimistic. Microsoft is not going to go away any time soon, and the antitrust proceedings don’t really have any relevance to DirectX. It’s not an illegal API, it’s just a bad one.

I’d also agree with Gecko that T&L isn’t a deciding issue. Although the fact that hardware T&L could be done in OpenGL right from the start, whereas in DX it had to wait for Microsoft to explicitly add it as a feature, might suggest something about the relative merits of the two architectures.

Also, remember that DX doesn’t have conformance specs, so the fact that DX “supports” a feature doesn’t mean you can actually use it. I think the D3D API advertised the Phong lighting model as far back as DX3, but last time I looked it still wasn’t implemented.

Lastly, although MS isn’t going to go away, their stranglehold on the desktop is starting to crack. You might write everything else off as “opinion” (what do you want, divine judgement?), but if you want to maximise your potential user base then a platform-independent API that works on Linux, Mac, BeOS, Solaris, Amiga, PS2 etc etc is a very real and very concrete benefit.

Yeah, i agree, we are probably not going to get rid of microsoft (but i surely want it to happend) …
However, about T&L and such things … the main difference here between OpenGL and Direct3D is that OpenGL was formed without thinking to much about what was actually in hardware. D3D is revised with every new generation of hardware to better suite the current situation, while OpenGL is a general solution of 3D grahics. OpenGL was done with the developer in mind, while D3D was done with the hardware in mind … that is, the current hardware, not the future hardware. That mean like now that the T&L unit was implemented in the GeForce, OpenGL as a general solution to 3D graphics could imediatly use it, while D3D had to be revised to be able to use. This is only because Microsoft had presupposed that the CPU should do the transforming and lighting. SGI didn’t make such assumptions, they thought of what kind of tools do the developer need to make powerful graphics easy and efficient. No thoughts about what was in hardware at the moment. This made OpenGL very complete all from the start and it has now gone from version 1.0 to 1.2 in almost 10 years. DirectX is soon coming in version 8, and it is still a much younger API!
This is the main reason why OpenGL rocks and D3D sucks. OpenGL is done with the developer in mind, D3D is done with the hardware in mind. This of course might make give D3D a slight edge over OpenGL in performance some times since it done to fit the current hardware. But i makes D3D programming a pain in the ass. It’s like you get best performance of programming in assembler, but 99% of the people out there prefer something like C/C++ because it gives you much simplier tools for the developer to do powerful applications. And since C/C++ like OpenGL is a general solution, it doesn’t lock you to a certain environment.

I also want to add my own experience:
Like 2 years ago when i first began to do to some 3d programs i looked for an API. First i considered DirectX, but it seamed rather complex. But then 3dfx was king of the hill so i check about there homesite so see if there was any information about programming for 3dfx. I found the Glide SDK and checked some info about it. It looked rather easy to use so i bought a Voodoo2, downloaded the Glide SDK at a couple of megabytes and started to code. I was up and running my first hardware accelerated program in an hour. And i liked it. But there were the problem that it would of course only run at 3dfx hardware, that was bad. But i sticked to Glide as long as kept had my Voodoo2. Later on when i thought about upgrading, the Voodoo3 spec was rather dissappointing, so i thought about buying an non-3dfx card, and last summer i bought me an G400. This made me again look for a API, and my thought was that i might be time to learn D3D. So i downloaded the DirectX 7 API at some 128 Megabytes (yes, i am a lucky guy with 10 Mbit/s Ethernet connection …) and started to read some documentation. After reading x^18 pages of docs i still didn’t have o clue how to get a triangle on the screen. So i searched the web for some simple example programs, but they seamed to be hard to find. So i read more docs and after x^18 more docs, lots of crasches and onehundredandfiftyeleven reboots my first DirectX app saw the light of the day. It changed the resolution to 640x480x32 … but i still wasn’t able to draw! I checked the examples included in the SDK and found out that the simpliest app was at 2500 lines of code, and it did only draw a rotating green triangle. But i thought “hey, this is microsoft code … let’s clean the mess”. So i started to clean up all i found unnecessary. I was able to reduce it to 1800 lines, but that was still far to much for me to get an survey of. So i gave up …
After some time i thought … hmm, what about OpenGL then? So, i started to read the documentation of OpenGL functions which came with VC++ 6.0. It seamed a little hard at the beginning … but after finding some examples on the net i was up and running a simple app, but i got into a lot of problems now and then. But, later on i found out that this wasn’t because OpenGL was badly designed, it was because the microsofts documentation included in VC++ 6.0 was badly designed. So i bought the “OpenGL SuperBible” book and made fast moving progress and i took me only a couple of days to solve all my problems a had earlier and have now progressed to creating advanced effects like reflection, shadows and such … just in a few weeks!

So, finally, my choice is easy, OpenGL is heaven. I hope DirectX suffers when it burns in hell.

Thank you for the word.

/Humus, happily married to a wonderful API.

Wow…some good replies here.

OK to start,sorry skdir…I misinterpreted your sentence.I thought you meant that there was no T&L in DirectX.My bad.

Now,as for DirectX being a good or bad API,that is all just what your experience was and I do respect all your opinions.I’ve tried both API’s and I love both of them to death.Yes,DirectX might be a bit of a mess (I admit it) but once I sorted through all that,I am now able to write 3D programs easily with both APIs.

I’m not going to be one sided here.I know that I’m prolly digging my own grave ranting about how good DirectX is on an OpenGL message board . I for one do not take sides in such matters since BOTH API’s have their ups and downs.

One more thing you all overlook is that DirectX is going through constant revisions all the time is because there are alot of stuff that needs to be upgraded all the time. DirectX does not mean Direct3D and DirectDraw only.Miscrosoft has to worry about DirectSound , DirectInput,DirectMusic,DirectVoice etc. This is prolly one of the main reasons why DirectX is messy.The DirectX team have too many things to worry about.

Off topic,I don’t understand the hatred towards Microsoft on this board (and many others) This is just one of the many things that happen in the USA.When a company grows big,they tend to get sued alot more.It’s a natural thing.(Look at AT&T and some other gas company,I forgot the name) They grew big,they got sued.Just another life cycle. Am I saying Microsoft is innocent? I don’t know.I haven’t heard their side of the story.I for one am a big Microsoft supporter.I enjoy programming for Windows. That’s just me. I also like Linux but to be honest,I don’t see Linux distributions being an everyday operating system in an average American family’s home anytime soon.It’s too high tech and there are not enought drivers for certain hardware.

(Once again,I am not trying to start an OS flame war here! I was just making an observation that there is this Anti-Microsoft atmosphere going on here.)

The reason DirectX is going to constant revisions is because it is based on the current hardware situation, and not based on what kinda tools the developers would like to have to make powerful graphics. But i agree that DirectX is better in the way that you have everything in it, not only the graphics part. But i saw a headline here at opengl.org lately which said the was some sort of “OpenML” API comming which should if i understanded it right include OpenGL but also have audio/input and such that DirectX has but not OpenGL. That would really be great.
About the Microsoft hate … yes, i don’t like Microsofts behavour against other companies and against customers. But i don’t say that everything they do is wrong and awful. I run Win 98SE/2000 dualbooted and i write all my docs in Word, since windows got the best user interface (but could be more stable and have an better system architecture) and word is the best wordprocessor out there. I do surf the web with explorer too, and write my mail in Outlook. But, microsoft has to think more about security and less about functionality (it’s like 99% of all computerviruses is because of security issues in microsofts products), more about future possibilities and less about current situations, and espescially more about customers and less about profit. And it would have been nice if they played a fair game too. They should compete with competetitive products and pricing and not with monopoly, power, money, doubt and uncertainty, breach of law and lies.

Gecko, you’re arguing that DX is necessarily messy and unstable because it includes Direct3D, DirectSound, DirectMusic, DirectInput, DirectKitchenSink etc etc. I don’t think that holds water. Remember, DX is essentially a hardware abstraction, and (aside for some grouping, such as DDraw/D3D and DSound/DMusic), these APIs are dealing with physically separate bits of hardware. So if DirectSound is getting broken or messy because of DirectDraw changes, their architecture and/or implementation is seriously screwed up. The whole POINT of COM is that implementation is supposed to be modular and transparent.

As to the anti-Microsoft sentiment on these boards… when programmers want to use a mature, scalable, portable industry-standard technology, and Microsoft does its level best to stop them and force them into using its own messy, limited, badly-designed, proprietary technology, said programmers tend to get a tad annoyed. We want to use the best tools for the job, they want to make as much money as possible out of us and everything we do. There’s a direct conflict of interest here. Until MS starts giving people what they want, rather than what MS wants us to have, there’s going to be hostility.

(see http://www.vcnet.com/bms/features/3d.html for some slightly biased background)

As for the whole monopoly thing, personally I think they’re a bunch of crooks, but that’s getting WAY off topic for this forum. Let’s not go there.

Hey MikeC, in you list of OS you forgot GEM that still runs perfectly on my Atari Falcon 030…

Well, OK, I have nothing to say…

Eric

Thanx again for all your replies.

MikeC,I did admit that DirectX is messy but I never did say it was unstable.Perhaps the programmers are more prone to error because it is messy.That might be it.I’m not sure.I certainly had my share of problems with bot API’s and I can’t really say one is better than the other.
And you misunderstood what I was trying to say.I know that all the DirectX components focus on separate bits of hardware.What I meant to say was that the Microsoft DirectX TEAM had to worry about all different parts of the API.They’ve got alot of work on thier hands and the ARB will too pretty soon because they are going to be creating the OpenML.Now if this task was left to just one company it will prolly be a messy API too.But because 5 or 6 different companies are in this together it will prolly be as “clean” as OpenGL.

Now,a question to all of you.If you had a corporation,wouldn’t you be doing ALL that you can to see to it that you remain on top? (I don’t want to carry this conversation on because I’ve already heard all the arguments from both sides,the Linux comunity and the Windows comunity,and I’m telling you both sides had really good arguments.But no side did win.I just wanted you guys to answer this little question so you can see it from a software corporation’s side that relies on it’s OS as it’s source of income and not from a free OS)