#1
  1. Permanently Banned
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2006
    Location
    In a whale
    Posts
    4,147
    Rep Power
    0

    Direct3d vs OpenGL?


    Hey everyone,

    I am planning on making a 3d game soon. But I would like to know which is better to use. OpenGL is used for most games, but d3d seems cool too. Anyone know which is better?

    BTW, I am going to be using this with C++.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Posts
    2,270
    Rep Power
    1737
    "OpenGL is used for most games, but d3d seems cool too. Anyone know which is better?"

    Neither. The question has been asked over and over and over in internet forums for a long while, and despite the endless discussion, no answer emerges. It's better to look at the facts and make a decision for yourself.

    Portability: DirectX is definitely Windows only. So for linux graphics, you must use OpenGL. Of course, a majority of apps and commercial games are made for Windows, so DirectX is incredibly popular.

    Packaging: OpenGL is graphics only. It does not come as part of a bigger system. Do you want sound? Networking? User input? You'll need to find other libraries to work with. Or frameworks or layers like SDL to work through. Direct3D on the other hand is part of DirectX. Once you want sound and all the other stuff that commonly comes with games, it's quite nice to just move over to a sibling library.

    Initial learning curve: I feel OpenGL has an edge over Direct3D for this. That's because DirectX involves COM. It's not a real pain if you're a competent C++ programmer, and if you have worked with COM before, the environment should be quite familiar. But the point is, initially OpenGL can feel a whole lot easier to start with.

    In the end, it makes no difference. Countless commercial games have been written to use OpenGL and the same for DirectX. Direct3D and OpenGL can accomplish the same things. Any game engine, framework, or something along those lines either supports both libraries or has a clone for the other one. Point is, pick one and stick with it.

    Comments on this post

    • niczak agrees
    When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

    Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
    Want better answers? Tell us what you Googled for and what steps you took to answer your own question.
  4. #3
  5. PHP Poster
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Location
    Nevada
    Posts
    252
    Rep Power
    14
    Oler1s: Great post. I agree very strongly that its important to pick one and stick with it. In making your selection it is very important to consider which platform(s) you are wanting to develop for, like Oler1s said D3D limits you to one platform, where OpenGL works on Windows, Linux and Mac 10.x platforms.

    To be completely honest I haven't worked with either one, however my colleagues that have all agree that OGL provides better documentation, better access to help and a more intuitive development environment.

    In short, if you are strictly developing for windows and you have familiarity w/ COM && || Microsoft DirectX API's in general then I would go the D3D route, if there is any chance at all that you are looking to port this to another platform in the future than I would save yourself some headache and use OpenGL from the get-go.

    -Nick
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    42
    Rep Power
    8
    DirectX is purely Windows, so if your making a game only for windows, its good

    If you don't mind, I suppose its down to personal taste.

    Sorry if I've been a bit vague in this post, but I've had absolutely no experience in openGL and only a little in DirectX. Well I am only 15!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2006
    Posts
    116
    Rep Power
    12
    Up to you, I'm planning on learning Directx but I'll definitely get around to learning openGL too, you can never know too many API's

    Anyone who says one is better than the other is just fibbing to him/herself, the only real distinct clear advantage opengl has over directx is portability, thats about it, if you are developing for windows choose the one you want to get into more for whatever reason (which is why i recommend directx, easier for newbies thanks to microsoft )
    Last edited by dynamicVoidMain; March 9th, 2007 at 03:07 AM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    134
    Rep Power
    0
    Actually... nowadays OGL support is better than D3d for the lower-end GPUs. And the plus of having multi-platform support, should give you a good idea of where to aim at.

    Thing is... D3D might become cross-platform this year or the next one. But as I said, on lower-ends you wont have good support for this (and by support I also mean performance).
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Location
    Concord, California
    Posts
    20
    Rep Power
    0
    I have a quick question. How is OpenGL pronounced?
  14. #8
  15. Psycho Canadian
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jan 2001
    Location
    Canada
    Posts
    4,846
    Rep Power
    635
    hmm not sure I always say "open" "G" "L"
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Pennsylvania, US
    Posts
    7
    Rep Power
    0
    Errr.... Okay. I dont think alot of people here have a clue about what they are talking about. The statement about OpenGL being used for more games is utterly wrong. Most games, very unfortunately, are written using DirectX... why do you think the Mac and Linux platforms have so much trouble with gaming. Its quite obvious if you ask me, because all (most) of the games use microshafts proprietary crap. Which lets them lock you into their platform.

    Now, ignoring for a minute, the whole separate problem of portability. Direct3D and OpenGL are sort of similar, but I have found that by far, Direct3D seems to be much harder to understand to less advanced users although it does also particularly have a lot of helper functions that do some extra work for you. Where as in OpenGL you may not have those. But I find that in most cases OpenGL makes for much cleaner much more understandable code and is much simpler to understand for "beginner" users.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Posts
    2,270
    Rep Power
    1737
    I dont think alot of people here have a clue about what they are talking about. The statement about OpenGL being used for more games is utterly wrong.
    Can you point this statement out?

    why do you think the Mac and Linux platforms have so much trouble with gaming.
    Well, this is a really a chicken and egg problem, isnít it? Itís not just DirectX thatís problematic. Itís the fact that non-trivial programs require OS specific code. To that end, you either write your program in an API with a cross platform layer that has OS specific implementations, or one that is directly OS specific itself.

    Its quite obvious if you ask me, because all (most) of the games use microshafts proprietary crap. Which lets them lock you into their platform.
    Unfortunate yes. But you realize, games require budgets, and companies want a return on those budgets. Preferably a big and profitable one. Just donít be so quick to criticize lock in.

    Itís important that beginners understand the philosophies of the APIs. OpenGL presents a C-ish API. It works as a state machine. You make a number of calls to this machine to achieve what you want. Itís easy for beginners because the beginning logic is obvious. Everything is laid out sequentially. In addition, OpenGL takes care of some low level issues for you, that Dx doesnít.

    DirectX involves COM. The API takes on an OO approach, or at least how COM does it. This makes it difficult initially for beginners, unless you happen to understand COM. If you donít know how to think in an OO manner, and donít understand how COM approaches it, itís very difficult initially. Couple that with the additional resource management that DirectX expects of you, and you can see why initially OpenGL seems easier than DirectX.

    So clearly, in the end, it wonít matter. Youíll get over the beginner learning curve, which leaves you with two APIs that are just as powerful as one another.
    When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

    Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
    Want better answers? Tell us what you Googled for and what steps you took to answer your own question.
  20. #11
  21. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Pennsylvania, US
    Posts
    7
    Rep Power
    0
    I dont think alot of people here have a clue about what they are talking about. The statement about OpenGL being used for more games is utterly wrong.
    Can you point this statement out?
    Certainly, the author of this topic said it in his or her initial post:
    Originally Posted by BlackNine
    Hey everyone,

    I am planning on making a 3d game soon. But I would like to know which is better to use. OpenGL is used for most games, but d3d seems cool too. Anyone know which is better?

    BTW, I am going to be using this with C++.
    Well, this is a really a chicken and egg problem, isnít it? Itís not just DirectX thatís problematic. Itís the fact that non-trivial programs require OS specific code. To that end, you either write your program in an API with a cross platform layer that has OS specific implementations, or one that is directly OS specific itself.
    Well considering the libraries that a very large majority of games use for other things, such as OpenAL and SDL which are already designed to be cross platform libraries, the ONLY thing holding them back is DirectX.
  22. #12
  23. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    258
    Rep Power
    55
    It's not that hard to do both, the api's are extremely similar (you can structure your game the same way). just create routines for each graphics library and to use a different one depending on the users settings.

    Alot of games do both, it would take a little more effort but if you build your engine with a "wrapper" which will convert your commands into the according api commands for each type it shouldnt be a problem at all.

    for example in your code you could have something like DrawRect() with could be defined as (pseudo):

    Code:
    DrawRect(x,y,attrib)
    {
           if(DirectXvar == 1)
           {
                 //DirectX routine here
           } 
           else {
                //opengl routine here
           }
    }
    }
    You get the idea, by building wrappers for each of your instructions you can build an engine which can do both.

    If you want to do just the one though i'd go with DirectX unless your using a low level language. If your coding in C or assembly then i'd use openGL as it's easier to program in a procedural environment than DirectX.
    Last edited by calpol2004; August 2nd, 2007 at 04:12 PM.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Posts
    1,014
    Rep Power
    788

    Lightbulb OpenGL


    Recently I've started to step away from DirectX simply because of the lack of cross-platform compatibility. If you have the option to exploit multiple operating systems with one single API, why not?

    GLUT and OpenGL are very powerful tools to use in game development and if a major game developer has used it successfully over the last decade, why not give it a shot?

    I'm not throwing DirectX out of the window but OpenGL seems like a wiser choice for me at the moment.

IMN logo majestic logo threadwatch logo seochat tools logo