Direct3D vs. OpenGL: From a Developer's Perspective
richcoder writes: "GameDev.net has posted an informed article discussing the benefits and drawbacks to using either Direct3D or OpenGL in a game. I've already made the decision to go with OpenGL for my next project, but it looks like Direct3D is gaining ground. Especially in the area of making it simpler to code support for new video card features."
The author seems to be somewhat biased towards OpenGL. This is fine, OpenGL is a good API, but it's starting to show it's age. Here are some points that I don't really agree with:
- He poses the question as to whether low level access and flexibility is worth it (for D3D). He argues that the more simple OpenGL system is sufficient. That is not the case for most game developers. To get the same performance from OGL as you get from D3D, you really need to use extensions from Nvidia or ATI to get to the same level of flexibility that D3D already offers. Things like Nvidia's vertex array range (with NVFence), or ATI's vertex array objects are very, very useful, and a pain to use since developers need to use both to accomplish the same thing.
- OpenGL on Windows does not support multiple monitors (or, I should say multiple video cards). Some drivers do relatively well here, but the WGL layer binding OpenGL to windows is severly crippled, and some dual monitor machines will blue screen just by trying to initialize OpenGL on a single monitor. D3D (since version 5) has no problems with multiple monitors.
- COM is hard to use: probably true, but DX hides as much COM as you possibly can. The result are C++ interfaces that make using DX without directly linking to it much easier. Writing apps that load the underlying rendering libraries (instead of linking with them) will be much easier with D3D than OpenGL. D3D requires 1 function to be queried for (Direct3DCreate), OpenGL requires dozens.
- D3D requires more code: Possibly true, but not for window initialization, more for texture and vertex buffer initialization. Actual setting up of texture state and render state are nearly identical. In any case, the code size difference is negligible.
- OpenGL is cross platform: But support on the Mac SUCKS!! Apple, in their infinite stupidity, decided that extensions that don't work on the Rage 128 wouldn't be supported. So, people buying those $4000 macs with GeForce4 TI cards can be happy with the fact games that are written to use new fangled features like vertex and pixel shaders will never work on the Mac. This may change when DOOM III is released, but I doubt before then. Even support for anti-aliasing would be nice.
I've written low level application rendering code in DX5, DX7, DX8, and OpenGL. There are areas of each that I like more than the others. In the end, I would probably pick DX8 over the rest, although OpenGL and DX7 are probably neck and neck for second.
Dan
OpenGL 2.0 is years away from exposing the hardware to the level DirectX has. The ARB is slow, but hopeful in getting the extensions mess cleaned up.
Microsoft Research has some heavy hitting names in graphics who are paid to do PURE research. This is a pretty formidable resource for Microsoft to leverage into making D3D indispensable to developers. Not every garage game hacker can whip out mesh skinning algorithms.
On the Mac OpenGL side... The Mac OpenGL games have a few titles out now with full screen anti aliasing. One is the Spiderman 1.0.1 Patch just this month for ATI cards.
The challenge with Mac/OpenGL support is developing a good relationship with ATI/Nvidia. Try getting into the community more. Not everyone has the connections Carmack has. The Mac Games Dev list (mac-games-dev@lists.apple.com) is very active.
Mindshare.
If I want to start developing games, I'm going to be looking around to see what I need to learn. DirectX reference material creeps up more often than not. Games that use DirectX are more numerous. Teams need to be built around a common skillset.
It's a chicken-and-egg problem, but it's there nonetheless.
--------
Bleah! Heh heh heh... BLEAH BLEAH!!! Ha ha ha ha...
At one point, the major weakness of D3D is that it has no future largely because it is not cross-platform capable, but when he gets to OpenGL, he states that OpenGL's cross-platform capabilities are irrelevant anyway. So which is it?
OpenGL vs DX is like Vi vs emacs, Linux vs Windows, and Capitalism Vs Communism. They are based on different foundations of viewpoint. With this in mind, I think he did admirably for staying neutral.
I would sum this article up by saying, what most of us have heard already, if you want to do game programming professionally, start with DX. For most other graphics stuff, for windows use either. For graphics stuff not on windows, use OpenGL.
I assume that games developers targeting the consoles (Nintendo, Sony, Sega etc.) They have their own APIs. anyone outh there care to give insight? Which API is closest in Style to Sony's graphics APIs?
Seems to me that Game programming should be done in a higher levl language for most things, and only optimize those things that are slow, but maybe in games, that turns out to be everything....Tell me people wouldn't flock to a Python game API
Open Source Identity Management: FreeIPA.org
I use GCC despite it being a slower compiler. I use XFree86 despite it being a slower windowing system. I use Mozilla despite it being a slower browser. Freedom is more important than speed.
In this case, instead of paying with your pocket book, you pay with your pocket watch. While your "freedom" might be the only quality you care for, that hardly makes it the only one that matters, as you don't buy all the software. I, and many others, are as uncomfortable with your trade-offs as, you must be with ours.
--Jimmy has fancy plans; and pants to match.
These two graphics accelerators happen to fall into a very broad category. OpenGL has a lot of things that Direct3D doesn't. A lot of games that run on Linux support OpenGL and not Direct3D. Direct3D is also created and used mostly by Windows users. I'm not going to be a hypocrite and say that I don't like Windows and use it anyways, but I am a long-time Linux user and I like being able to play several games and do some hardware acceleration. Direct3D drivers do not even exist on my RedHat and Slackware Linux machines. OpenGL will always prevail, whether on Mac, Linux, or even Windows. OpenGL is more versatile and can do a lot more for the future of gaming than DirectX and Direct3D can. I give it 1 1/2 years before Windows' main competitor is Linux and UNIX. Then again, I'm not going to be a hypocrite and say that I hate DirectX and then use it on some of my games, I don't hate DirectX, but I do believe that OpenGL is the future of high-performace gaming. MS will always beg to differ though.
I personally have no experience with OpenGL (except playing games that utilize it), but I have found that DirectX is very logical [modular], and there are some excellent reference out there for it. For beginners who have experience in basic c/c++ and a good start in win32 API, I suggest Tricks of the Windows Game Programming Gurus written by Andre Lamothe. While my boss has a personal vendetta against the man, I like his clear writing style, and he put in just the right amount of detail! (amusing/witty comments are also scattered throught he book). Even if you are a bit shaky on the win32 api's or the math behind the algorithms, he makes sure to touch on everything that you could be shaky on.
It comes at a reasonable price on www.amazon.com and covers most of the major DirectX features to create a good two dimensional game. You can also buy the second volume of the series in which he covers three dimensional graphics.
With such excellent reference books, who can go wrong?
http://www.pygame.org/
Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
OpenGL 2.0 will doubtfully ever take a major stake of the market, since DirectX/Wintel clusters are marketed as "cheaper." There's a giant rendering farm at LLNL that is all DirectX, mainly because of the lack of availability of Linux/Unix Nvidia stereoscopic rendering drivers. They've been sitting on them for a while, but as you know, Nvidia is in bed w/ micro$oft (Xbox). It sucks when a great os such as Linux can't get decent drivers. Shame on you Nvidia!
My school's CIPIC lab has a immersive workbench, but requires proprietary OpenGL hooks for syncing w/ the shutter glasses.
The biggest trick the devil pulled was letting lawyers become politicians so they can write the laws.