OpenGL Or DirectX

Discussion in 'Game Development (Technical)' started by ProgrammingFreak, Feb 23, 2006.

  1. ProgrammingFreak

    Original Member

    Joined:
    Oct 22, 2005
    Messages:
    126
    Likes Received:
    0
    I have looked into OpenGL Programming and DirectX programming, I was wondering which was easier to use. I would use C++ to program in either graphics library
     
  2. digriz

    Original Member

    Joined:
    Mar 24, 2005
    Messages:
    532
    Likes Received:
    0
    Now that's a loaded question on these forums! :)

    Me, i prefer Direct3D but for no other reason than i'm comfortable with it. I've programmed with openGL for maya plugins and generally i liked it.

    Asking what's easier to use is tricky to answer, it depends on what you want to do but in general i think OpenGL might be an easier option, especially if you're new to 3d and the API's.

    Direct3D can have a lot of gotchas if your not expecting them and it's only for windows.

    OpenGL on the other hand is available on many other platforms too.
     
  3. ggambett

    Moderator Original Member Indie Author

    Joined:
    Jul 26, 2004
    Messages:
    1,982
    Likes Received:
    6
    At this point the Direct3D API is almost a verbatim copy of the OpenGL API, down to the constant and function names, so you won't notice much difference.
     
  4. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    If you're asking this question, then I'm guessing you don't know much about them beyond their interfaces. In which case ggambett is right, they will both appear basically the same to you.

    There are differences here and there in programmability and feature support, but you have to be doing pretty advanced stuff to run into that problem (and in that case, you'd probably already know which one you'd want to use).

    That said, use OpenGL if you want cross platform... DX if you are Windows only. Or, write a wrapper with both gl and dx backends.
     
  5. ProgrammingFreak

    Original Member

    Joined:
    Oct 22, 2005
    Messages:
    126
    Likes Received:
    0
    I would want cross-platform, so it would be opengl
     
  6. soniCron

    Indie Author

    Joined:
    May 4, 2005
    Messages:
    3,664
    Likes Received:
    0
    That sounds like the easy answer, but then someone (like me) says something like, "A good handful of Windows machines have broken OpenGL drivers and with no rendering context will thusly crash."
     
  7. Savant

    Original Member

    Joined:
    Feb 8, 2005
    Messages:
    1,674
    Likes Received:
    0
    Kind of irrelevant if he wants cross platform and only wants to use one API. OpenGL is the only answer.
     
  8. soniCron

    Indie Author

    Joined:
    May 4, 2005
    Messages:
    3,664
    Likes Received:
    0
    And perhaps he now understands there is no silver bullet.
     
  9. Savant

    Original Member

    Joined:
    Feb 8, 2005
    Messages:
    1,674
    Likes Received:
    0
    I don't think he ever said there was.
     
  10. Sharpfish

    Original Member

    Joined:
    Feb 25, 2005
    Messages:
    1,309
    Likes Received:
    0
    Easier to use? OpenGL because you only need to write it once (multiplatform) - better for indiegames on Windows? DX7/8 because of poor/patchy OGL support on a lot of casual gamers systems. (assuming you are aiming at the 'usual' indiegame developer's market?

    You can choose to have an "easy life" or you can try to give the player an "easy life" (while increasing your chances of success) by putting in a bit more work. For a proper answer we would need to know more than what you have given:

    .What kind of games will you develop (2D? 3D? Casual? Hardcore?)

    .How important is the X-Platform? Is it important enough to limit penatration of your main target platform (assuming Windows)?

    .How prepared are you to make 2 renderers, and are you going the extra mile to "tick as many boxes" on the checklist of trusted indie-dev wisdom collated and relayed to us by those who have learned what works best?

    .Are you just in it to make tech demos/freeware or are you running/going to run a business selling games?

    The ideal solution would be to wrap both in your own code and use OGL for mac and DX for windows (maybe with fallback to OGL on windows too but not only).

    Personally I prefer D3D but as pointed out there's very little in it now MS have improved D3D programming.
     
  11. ProgrammingFreak

    Original Member

    Joined:
    Oct 22, 2005
    Messages:
    126
    Likes Received:
    0
    So are you saying to use DirectX with windows based games and OpenGL for Linux and other Os. Instead only just using OpenGL
     
  12. digriz

    Original Member

    Joined:
    Mar 24, 2005
    Messages:
    532
    Likes Received:
    0
    Absolutely, there's just a horrible bitter aftertaste!:D

    With any api like OpenGL or DirectX there could always be potential problem with drivers installed on peoples machines. Regardless of which one you decide to use.

    From what you've said and what other people have advised on here, i'd seriously consider just using OpenGL.

    It's widely supported and on many, many platforms.

    You could support both but i reckon; maybe starting with OpenGL and add dx later if you think it's necessary. Why not download a few pc and mac games from the people on here, especially the ones who support all the platforms you want to target. See what they use.
     
    #12 digriz, Feb 25, 2006
    Last edited: Feb 25, 2006
  13. soniCron

    Indie Author

    Joined:
    May 4, 2005
    Messages:
    3,664
    Likes Received:
    0
    That's like saying you have the same vulnerability to the flu and ebola. Of course you do, but the likelihood of catching ebola is far less than the flu. Point is, DirectX isn't nearly as fragile as OpenGL on Windows.
     
  14. Rainer Deyke

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    380
    Likes Received:
    0
    Unfortunately, code written for DirectX tends to be more fragile than OpenGL code. For example:
    • DirectX code must be written for a specific version of DirectX, and just plain doesn't work on earlier versions of DirectX. This is also true of OpenGL. However, a program written for OpenGL 1.0 can take optionally take advantage of all later features of OpenGL through the extension mechanism. To optionally take advantage of later DirectX features while supporting older versions of DirectX, you basically need to write completely separate renderers and choose between them at runtime.
    • An OpenGL 1.0 driver is required to implement the full OpenGL 1.0 API. A DirectX program is expect to query the hardware/driver for its capabilities. There is guarantee that any given hardware/driver combo will implement any given feature, so you either need loads of hard-to-test fallback code or your DirectX program won't run on all DirectX implementations.
    • OpenGL provides a clear and easy to understand API. DirectX is messy and poorly documented. It is much easier to write bug-free OpenGL code than bug-free DirectX code.

    In other words, you have to choose between writing a robust program for a fragile system or and writing a fragile program for a robust system. Or just support both APIs. If you've somehow managed to write a solid renderer that works on most DirectX implementations, also writing the OpenGL renderer should be trivial.
     
  15. gmcbay

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    280
    Likes Received:
    0
    But if the OpenGL driver is broken (which is often the case if the user isn't using a fairly modern ATI or Nvidia based add-in card), the game still crashes, so that whole point is moot.

    I don't agree that this is a benefit for games. It might be a good thing for visualization software, but if a videocard doesn't support something in hardware then they are going to emulate it in software on the OpenGL driver, often in a manner that is so slow as to be unusable. I'd rather just know what the card really supports even if that means some extra branching code.

    Disagree completely. This was true in the days of DirectX 3, but hasn't been true for a long, long, time. The DirectX documentation is top notch and the API evolved to the point where it became very-OpenGL like and in fact for a while it was a lot easier to do many things (like VBOs and shaders) under DirectX. Things have been equalling out again thanks to some advances in OpenGL 2.0, but relying on OpenGL 2.0 makes your driver mess situation even worse than it already was.

    I'm certainly not anti-OpenGL, because I'm a big Mac fan and DirectX code is just never going to run (without weird emulation) on the Mac, but the only REAL drawback of Direct3D as an API is that it isn't cross-platform. It is otherwise a fantastic API. And there is a LOT of truth to the common wisdom that OpenGL is broken on a lot of Windows machines that might be used for "casual" gaming.

    Anyway, my advice to anyone in this situation would be to write their game with OpenGL to take advantage of the crossplatform abilities, but abstract everything so they can write a DirectX renderer when they get enough complaints from users that the game crashes on their Windows install that runs other casual games just fine. Or save yourself a lot of effort and use Ogre3D or some other existing engine which already supports both APIs on multiple platforms.
     
  16. soniCron

    Indie Author

    Joined:
    May 4, 2005
    Messages:
    3,664
    Likes Received:
    0
    See, my problem with this is that everyone says they want cross platform, but how many actually have Mac or Linux versions available? It's "cool" to be cross-platform, but most simply don't actually go through with it. And unless he's got a Mac, the chances of seeing Mac support are extremely slim. In that essense, I think it's important he does something similar to what you're suggesting, but instead of build an OpenGL framework, he do the same with DirectX, leaving the option open for cross-platform OpenGL development in the future.
     
  17. Sybixsus

    Original Member

    Joined:
    Aug 2, 2004
    Messages:
    959
    Likes Received:
    0
    Of course, you could always just use a 3d engine which has already seen all these problems and offered some kind of solution. Such as Irrlicht which has Windows and Mac versions, so you can have DX on Windows and OGL on Mac without much effort. Assuming that a full 3d engine isn't overkill for what you have in mind, of course. You don't actually say. But I guess PTK does the same thing in 2d, doesn't it?
     
  18. ProgrammingFreak

    Original Member

    Joined:
    Oct 22, 2005
    Messages:
    126
    Likes Received:
    0
    Well I have looked into 3D Engines, and I will probably use one when I am ready for such a big project
     
  19. vjvj

    Indie Author

    Joined:
    Sep 25, 2004
    Messages:
    1,732
    Likes Received:
    0
    Agreed on pretty much everything. I was a big OpenGL guy for years while MS took forever to get the API right. However, these days I definitely prefer DX to GL from a pure API standpoint. Being ARB-run and having an extension system, two of its greatest advantages in the old days, are now huge drawbacks for GL. MS has been doing a great job communicating with developers and IHVs to make the right design choices quickly for each successive version, while GL ARB members bicker over stupid shit and never get anything done. VBO and FBO are great examples of this... Plus look at how GLSL turned out (crap).

    That said, I'm actually using GL right now because I'm very serious about shipping a Mac version. Eventually I might have to write a wrapper with a GL backend, because I've got my eye on PSP as well... But for now, I'll just be using GL.

    Again if this is just a small project, the only thing that should be influencing your decision is the target platform.
     
  20. soniCron

    Indie Author

    Joined:
    May 4, 2005
    Messages:
    3,664
    Likes Received:
    0
    I've been hearing a lot about how Microsoft fixed the DirectX API. From someone who didn't dare touch Direct3D because of the nightmares involved and chose to learn OpenGL instead, I'm curious when this change was? I assume it wasn't all at once, but at what point did the API become friendly? Which version? I'm more than happy to switch to DirectX from OpenGL if it's truly better (simply because OpenGL support is so spotty in Windows), but I'm not willing to make the transition if I have to alienate nine tenths of my customer base by requiring DirectX 9. What is the earliest "good" version?
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer