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