Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Games Entertainment

Direct3D vs. OpenGL: From a Developer's Perspective 25

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."
This discussion has been archived. No new comments can be posted.

Direct3D vs. OpenGL: From a Developer's Perspective

Comments Filter:
  • by djohnsto ( 133220 ) <dan.e.johnston@g ... inus threevowels> on Tuesday February 26, 2002 @04:31PM (#3072752) Homepage
    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.
    • Some minor points (Score:3, Insightful)

      by inah ( 82745 )
      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 [utterer.com] 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.
    • 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.

      You probably understand this point, but your post might confuse others. OpenGL itself doesn't care about the windowing environment. It doesn't know about monitors or windows. The deficiency with multiple monitors is with WGL, not with OpenGL. Other environments won't have any trouble with OpenGL on multiple monitors (eg, X11 + GLX).

      D3D requires more code: Possibly true, but not for window initialization,

      Once again, OpenGL doesn't do any window initialisation at all.

      As far as I'm concerned the arguments about speed and features are irrelevant. The only argument that matters is "Direct3D is a proprietary Windows API and OpenGL is not". 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.

      • by Kibo ( 256105 )
        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.
        • by nathanh ( 1214 )
          In this case, instead of paying with your pocket book, you pay with your pocket watch.

          This is the same false thinking that leads people to buy faster computers because "3x faster means 3x as productive!". It's a lie. People are slow. Computers are fast. Software needs to be fast enough, and no faster. This applies to desktop applications just as much as server applications.

          For all the increases in computing power and speed, is the NT fileserver with 1Gbps fibre any more productive than the Netware server with 10Mbps ethernet? It should be clear that the increases in speed have not led to productivity increases nor cost reductions. The real cost reductions would have been achieved if the Novell server had been replaced with Linux + Samba in the first place. That would have broken the hapless administrator out of the proprietary lock-in that both Novell and Microsoft are trying to achieve. The minor decrease in functionality/quality at the time would have been long-term offset by the huge increase in freedom. That's a freedom that the administrator would have forever.

          The same argument applies here for Direct3D vs OpenGL. The short-term benefit of increased speed with Direct3D in low-importance applications(ie, games only) is long-term offset by the huge increase in freedom for developers and users with OpenGL. On the list of "features to compare" the feature of freedom should be given a high weighting value. In the long-term the cost of freedom is greater than any minor increase in speed.

          While your "freedom" might be the only quality you care for

          It isn't. Cost, quality, reliability and fitness for task are all important decisions when purchasing hardware and/or software. The cost of freedom is not equal to the cost of money.

          as you don't buy all the software.

          I'm sure you don't either, but I do buy some software. When there is a decision to be made then sometimes the proprietary software wins out. In the case of Direct3D vs OpenGL the cost of freedom greatly outweighs the minor advantages of 5% greater speed for a video game (the only 3D field where Direct3D has any true relevance).

          • by Kibo ( 256105 )
            It is what it is. 3x faster isn't always 3x times more productive, or 3x whatever. While people are slow giving computers tasks, sometimes those tasks can be enourmously complex and take the computer a while to accomplish. Hybrid radiosity solutions and volumetric redering come to mind. In fact, my brain can figure out what it should look like in seconds, it might take me a week to tell the computer how to do it, and it might take day for the computer to actually accomplish the task I set before it. My record is 48 hrs to render a single frame. Do I do it profesionally? No, I can't texture or light a scene to save my life. But, for whatever reason, I enjoy it. However, I do not find it enjoyable to wait 2 days, for a frame. In this case, processing power directly, and linearly affects my "productivity". But that's one of a billion instances.

            While there is a certain charm to the marxist simplicity you seem determined to frame the problem in, yet if it were accurate the market really would reflect this. It's not just doomed dot coms that had the gig ethernet. If a P90 with 16 MB ram, a 528 MB hd, and a 10 Mb card really did the same job as an array of xeon web servers, no one would ever use anything else.

            The people have voted, they've decided not every problem looks like a nail. They've decided they need a wide variety of unix varients. They've decided they need some things that are free, and some things that require spot inspections from microsoft, and help desk contracts from sun. They decided against one kind of shoe, no matter how efficently produced, for all the people.

            But it doesn't apply to games anymore than it applies to shoes, or any other good. Games are important, many billions of dollars important. They cut into TV ad revenues, they cut into school for some (I used to know a guy who had to take a quarter off school because of Quake I), they entertain, and sometimes train. If they truly were superfluous, they would be treated as such. They're not.

            You may not think much of them. But that is your individual subjective experience. While that is representative of some segment of the population, you cannot say it is a feature that is true for a large fraction, let alone a majority of the population. More over, I mostly encounter the choice when I putter around in trueSpace 5 since I have the choice of OpenGL or D3D enviroments. When I first got trueSpace 4, OpenGL was a better choice, now, in trueSpace 5, D3D seems more responsive. And contrary to what you find, I happen to prefer a responsive user interface. But in my defence there was a time when I considered lynx to be the best web browser, and emacs the best text editor and with bbdb the best contact management software anyone would need. Obviously I was an idiot. But, it certainly was responsive.

            What's important is the only opinions that count are the one people are willing to spend resources on. Since you're not the only person spending resources, your's is not the only opinion of worth. In the end, the cost of everything is measured in dollars, or whatever the local currency might be. In fact, the only thing one cannot really buy is time. We've only got about a billion heart beats each, if you choose to spend some waiting, I choose to spend some making accurate 3d models that look butt ugly, and someone else chooses to spend some fraggin people he doesn't know in 1920x1600 photo real glory, to each their own. That's really what freedom is after all.
            • Direct3D and OpenGL have nothing to do with 48 hour rendering times for a single still frame.

              Interactive subjective performance of a single Windows application has nothing to do with the relative merits of OpenGL vs Direct3D.

              In fact, you should have easily spotted that Microsoft's destruction of your freedom for 3D APIs has directly led to OpenGL no longer being a viable option. You should be hopping mad. Instead you've fooled yourself into thinking you have freedom of choice.

              Freedom is not about being able to choose how you waste time. Freedom is about being able to do what you want without being controlled by somebody else. Choosing Direct3D might be more convenient but it does not increase your freedom.

              My argument was that giving up freedom will cost you more in the long-term. You haven't argued against this. Instead you've rambled off into a discussion of how your way of wasting time is different to my way of wasting time. You don't know what freedom is and you haven't understood my argument.

              Minor short-term gain, huge long-term loss. This is the argument. Please argue against it, not around it.

              • No they have to do with the responsive user interface. You broadend the discussion to include hardware. In my case, the 48 hour frames are pretty much just a factor of the chip. Which of course would have a linear relationship with my render times.

                And the results of a single application are important. In fact, to me that's all that's important as when it comes to games I favor Bandit Kings of Ancient China in all its EGA glory, Stars!, and curse the fact that Stars! Supernova will never be.

                Microsoft didn't destroy OpenGL. It just languished while D3D grew. Will OpenGL v 2 be better? Maybe. Will trueSpace support it? One assumes so. Will it be better? Probably initially. But Microsoft will catch up again. Fortunately, when that time comes, I'll have the choice of which enviroment I wish to use.

                I would argue I have more freedom. I can choose. Within a single application, I can use OpenGL or D3D as I see fit. An freedom you have forsaken for something akin to a religion. Your choice. And you pay for it in your own way. I pay in mine. You've even admitted as much. Now you seem to be saying the price I'm paying is too high. And I'm sure to you it seems that way. But you may rest assured I find your limited options an equally extravagent choice. But unlike you, I know that's *MY* perception, which I don't pretend is the objective truth.

                In the end, freedom is the ability to choose. We are both equally free, as we both enjoy the same options. But based on our individual needs, and desires, we made individual choices. Not exactly surprising. While I might have rambled on about how the only thing you can't really buy more of is time. You've rambled on about how microsoft is destroying the world, despite the fact that I chose trueSpace, not microsoft. And as nice as the idea of a free software commune in a virtual marxist society might be, I've long since abandond such notions.

                You dream of a world where there is one API to rule them all. I favor one where people choose what works best for them. And your argument, is no argument at all, it your opinion. To which you're entitled. But the fact remains, your choices have consequenses, and as such are not free of cost.
                • Marxist? Religion? Limited? Extravagent? And what's with quotes like these...

                  ... unlike you, I know that's *MY* perception

                  Attacking me won't make you look intelligent. It makes you look foolish.

                  Once again you've skirted around the argument instead of answering it. The argument has always been that giving up freedom will cost you a bundle in the long-term which will negate the short-term gains. You seem to feign surprise that this is the argument. You even dare to suggest that this is a new argument that was never mentioned before. You say:

                  Now you seem to be saying the price I'm paying is too high.

                  Read what I write, not what you imagine that I'm saying. You characterise me as a Marxist fool who never buys software. You suggest that I'd sellout king and country for "extravagences" like freedom. Whether you're lying or simply ignorant, I cannot tell. I wrote earlier:

                  I do buy some software. When there is a decision to be made then sometimes the proprietary software wins out.

                  ... and...

                  Cost, quality, reliability and fitness for task are all important decisions when purchasing hardware and/or software.

                  ... and...

                  On the list of "features to compare" the feature of freedom should be given a high weighting value. In the long-term the cost of freedom is greater than any minor increase in speed.

                  This was always the argument. It has always been there. You can feign surprise if you like, but the record is clear.

                  Now you can choose to ignore the argument. You can scoff that I'm just a nutter that never pays for software. You can call me "Marxist" and "Religious" if that makes you feel better. I pointed out that there is a very real cost - sometimes even a monetary cost - in giving up long-term freedom for short-term gain. You choose to wallow in your own self-gratification and pretend that this is nonsense and attack me for going down an uncomfortable (for you) line of thought. Fine. Your loss. Enjoy your shiny toys.

    • I would have said the OpenGL non-support issues under windows were more of an anti-competitive move by microsoft, if they offer the features people want in direct3d but cripple the opengl interface, well what would you rather use?
  • by wrinkledshirt ( 228541 ) on Tuesday February 26, 2002 @05:59PM (#3073591) Homepage
    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.
  • 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

    • Comment removed based on user account deletion
      • yeah, cheesy sarcasm aside, capitalism is so bad - go live in N. Korea...

        please.

      • I agree somewhat... Communism is cool in all, but I like the thought that a college education will in the long run net me about 20 grand more a year, that would be why I am here now.
        And DX would be really cool... IF M$ would, or someone like ximian would, port a useable version to other platforms / make it open source. If someone could make something like the cross over plugin that works with windows media and quicktime for linux, I would be in paradice.
        The only games I can really play on linux well, are those with OpenGL support, I am not complaining, cause RTCW kicks butt, but I wouldn't mind being able to play the Tom Clancy games or some other stuff based on DX.
        Although communism is in theory the best, it is not the one the everyone choses to live under, the same way with winblows and DX, not the best way, but everyone's doin it.
  • 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?
  • 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 [ucdavis.edu] lab has a immersive workbench, but requires proprietary OpenGL hooks for syncing w/ the shutter glasses.

Kleeneness is next to Godelness.

Working...