Open GL vs DirectX

Discussion in 'Backers Lounge (Read-only)' started by doud, July 1, 2013.

  1. doud

    doud Well-Known Member

    Messages:
    922
    Likes Received:
    568
    Here is a technical question :

    I know that for multi cross platform purpose open gl is used instead of DirectX.

    Is which areas Open GL is better than DX ?
    From a technical perspective, is Open GL able to reach same performance as Direct X, considering that today Direct X is most prefered API among developpers (since obviously most of the games come out on PC) ?
  2. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    DirectX support is effectly zip on Linux* and Mac.

    Nobody in their right mind would spend time and money writing DirectX for Windows, then not use it elsewhere.

    If you have to use OpenGL somewhere, you may as well be as cost-effective as possible and use it everywhere possible.

    *WINE does not count.
  3. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    First you need to correct question: DirectX is bunch of different technologies, so right topic name is "OpenGL vs Direct3D".

    It's very holy war topic, it's like asking: what better Android or iOS. :D
    These two APIs just two different, it's really hard to compare technical advantages with openness or one architecture with another.
    Nvidia got good drivers so with their cards you have get equal performance of D3D/OpenGL. Situation a bit worse with AMD, but 80-90% performance is here. It's far far worse with old Intel iGPU, but they doing better each time.

    But for sure performance of games isn't usually depends much on API used, it's more important how professional programmers are, renderer it's usually less than 20% of graphics engine code.

    Most developers use D3D not because it's just "better", but because most of AAA games made for Windows and both consoles. Xbox360 have it's own specific and there is place for low-level optimizations, but there is mostly same D3D as on Windows.
    So everybody choose D3D because they use it for 2/3 platforms, no need to do same job twice.

    PS3 haven't real OpenGL support, and mostly every developer use low-level API named LibGCM.
  4. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    Also you might check this link for example:
    http://blogs.valvesoftware.com/linux/faster-zombies/
    You know that all Valve games are extremely optimized and even work on very low-end PCs.

    It's not mean that OpenGL any better than D3D, just an example of how good software engineers can use advantages of it.
  5. bgolus

    bgolus Uber Alumni

    Messages:
    1,481
    Likes Received:
    2,299
    I'll add a little here. We use OpenGL because we are supporting multiple platforms and only one supports Direct3D. We could support two render paths, but we don't have enough man hours as it is.

    Basically OpenGL is both faster and slower than Direct3D, depending on the application and hardware. OpenGL often supports advanced features way ahead of Direct3D, but the nature of OpenGL is it is a base set of simple functionality with many layers of extensions that video cards and drivers may or may not support at the whim of the vendor. Direct3D is a set of features that are required to be supported. So often a feature will show up in OpenGL years ahead of Direct3D, but only supported by a small handful of cards. Eventually that feature gets added to Direct3D and now almost everything supports it ... at least in Direct3D. Frequently in the past the OpenGL drivers for consumer grade hardware lagged behind by quite a bit, even if the hardware supported it. Usually it took the release of an id game sporting a feature before any vendor would bother getting the OpenGL driver up to snuff.

    Now with AMD and NVidia taking renewed interest in Mac and Linux gaming, OpenGL support seems to be getting a little more love than it used to. It may also be in part due to the popularity of iOS and Android devices, both of which use OpenGL ES, but that is just conjecture on my part.

    The little asterisk on Linux support of Direct3D is an interesting note; Wine supports Direct3D by translating Direct3D API calls into OpenGL calls. In a way it shows the flexibility of OpenGL that it can still remain performant as the two APIs can be very, very different. Though to be fair to Direct3D, many web browsers on Windows platforms translate WebGL into Direct3d in a similar fashion.
  6. comham

    comham Active Member

    Messages:
    651
    Likes Received:
    123
    Presumably you'll be avoiding using those particular, widely-unsupported features. I hope there's a well-agreed-upon list.
  7. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    OpenGL based on extensions. E.g if your card support some feature game can use it, if it's not supported it's can be just ignored.
  8. doud

    doud Well-Known Member

    Messages:
    922
    Likes Received:
    568
    Thanks for the answers.
    I had this concern, because I often see articles about Nvidia/Ati not allways optimizing their drivers, and frequently they deliver drivers that will for an unknown reason, dramatically improve FPS for a specific game.

    I'm just wondering if the optimizations they bring are also helping for opengl performance, or if it's only related to Direct3D implementation.

    I'm also wondering how it's possible to improve FPS that much and speak about optimization : Isn't it much more about lazyness to provide drivers that provide the best possible performance ?

    And graphic issues : How is it possible to have graphic bugs requiring fixes from developpers while an API should only be used the way it's supposed to be used. I mean, you execute a call with required parameters, how does it come that it will work for one graphic card, and not for the other one ?

    Let's take the example of textures over the moon. Why isn't this working from scatch on all graphic devices ? (I'm not blaming anyone, just trying to figure out why graphic drivers are obviously such a nightmare)
  9. bgolus

    bgolus Uber Alumni

    Messages:
    1,481
    Likes Received:
    2,299
    There is no explicit well agreed upon list, and usually identical features that are widely supported actually end up being completely different extensions and implementations depending on the video card vendor. There are a number of projects out there that try to compile these common-but-different features into libs so it can be safely ignored.

    Frequently if an extension or feature doesn't exist there's a slower alternative that you can fall back to that otherwise behaves nearly identically.

    These days older Intel integrated graphics chips and open source Linux drivers are really the only place where you'll run afoul of major missing features. It's one of the reasons why old Intel Graphics Media Accelerators aren't really something we have much hope of supporting, often features they say on paper (or in driver!) they support aren't actually supported at all and will cause crashes or falls back to software emulation!
  10. doud

    doud Well-Known Member

    Messages:
    922
    Likes Received:
    568
    Thanks a lot for answering my questions that probably reflect how newb i'm in this field of knownledge ;) Much appreciated, and by the way, whatever the final game look like, i allready feel so much satisfied with the gaming experience i had so far with alpha. It's something which is unlikely to occure with other Devs, and i will not forget it when Uber work on another title. I can't list all kuddos you deserve for all the stuff achieved so far, with a true respect of people who have pledged this project. thx !
  11. neutrino

    neutrino low mass particle Uber Employee

    Messages:
    3,123
    Likes Received:
    2,687
    One area where OpenGL is far superior is that it's an open standard managed by industry. Directx is a proprietary technology.

    I think with the next console generation you are going to see more emphasis on GL because it will run PS4/PC/iOS etc.

    In almost all cases I would prefer to use the open standard instead of the custom whackiness. Of course this isn't new for me. For example http://chrishecker.com/OpenGL/Press_Release and note the date.
  12. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    There's a lot of big names in there.
  13. paprototype

    paprototype Member

    Messages:
    138
    Likes Received:
    1
    For me, directx is what MS made up to make sure games were made for windows.
    Games used to run just fine on opengl before dx even existed.
  14. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Well, Microsoft had the manpower to define a whole set of APIs (not only Direct3D, but also the sound libs, input, etc.) to provide a solid package and the availability of all those features was guaranteed on any platform which claimed to support the corresponding version of DirectX.

    Also note that OpenGL wasn't always as polished as it is now. While it is used a lot for professional software (which needed flawless, accurate implementations, bleeding edge technology and backwards compatibility by transparent software emulation), the implementations on consumer hardware were always lacking.

    Also note that until OpenGL 2.0 (which was released as late as 2004!!!), there wasn't even support for pixel and vertex shader in OpenGL, essential techniques for fancy graphics and complex lighting models. Microsofts DirectX 8.0 did already provide access to those features since 2000, which means over 4 years in which OpenGL became useless for fancy consumer graphics.
    Although it was still the first choice for professional applications, since there were quite a few manufacturers of OpenGL accelerators which provided hardware which was designed to be used for CAD, that means being capable to handle rather large models and being 100% accurate, but in return being less flexible than DirectX compatible consumer hardware.

    Well, since 2004, the OpenGL development sped up, not only up to the point where it provided all Direct3D features of the current version, but even providing bleeding edge features in form of extensions a few months to years before they became part of the Direct3D API.

    But it wasn't until iOS/Android that OpenGL was actively used for consumer graphics again. Sure, there were quite a few developers who developed "games" for OSX or Linux earlier, but neither did they make use of all the OpenGL features, nor became any of those games really successful. Big studios would only use DirectX until 2008/2009 because the developers got used to DirectX (remember, OpenGL was completely unusable from 2000 to 2004, even longer if you consider how long it took before proper drivers with support for newer OpenGL versions got released) and neither Nvidia nor ATI deemed it necessary to maintain their OpenGL implementations in the consumer driver.

    One of the most impressive things happening lately to OpenGL, was Valves attempt to port the Source engine to OpenGL - and achieving higher frame rates (almost) right away.
    The bad thing about Direct3D is: It has grown into a monolithic monster. You won't notice it so much as a developer, since the API stays rather clean, but it suffers from quite a few internal design flaws which cause a significant performance penalty. This does not affect all applications of course, since many are limited by raw GPU performance, but quite a few are slowed down from the overhead of the API (or design flaws where the API is blocking, although it wasn't really necessary).
  15. paprototype

    paprototype Member

    Messages:
    138
    Likes Received:
    1
    Interesting read.
    It seems to me though that since developers were solely using dx, the development of opengl got slowed down significantly.
    If for instance MS never introduced dx but kept using opengl, companies like nvidia and amd would have had perfectly up to date drivers for opengl in 2000-2004.

    I am glad that linux/unix based OS's are so much more used nowadays.
    Hopefully Valve will be able to get the steambox popular.
    Especially now MS has introduced windows 8(.1), forcing an notebook interface on a desktop, and welcome to the cloud (yeey why not share all my digital data, blergh)
    Makes me want to get rid of windows completely.
  16. AusSkiller

    AusSkiller Member

    Messages:
    218
    Likes Received:
    0
    What the hell are you talking about? Shaders were accessible in OpenGL 1.2.1 via extensions shortly after the GeForce3 release, OpenGL 2.0 was just when they were adopted into the standard. And technically nVidia's register combiners were the first programmable "shaders" and they were available in OpenGL before the release of DirectX 8. Granted that as always ATi were slow at adding support for similar features, especially when it came to their OpenGL drivers so they weren't actually used much (AFAIK), but that's a failing of ATi not OpenGL. OpenGL supported shaders before DirectX, and technically OpenGL actually supports any feature before DirectX, you can use the hardware tessellation unit of DX11 video cards with OpenGL 1.3 (and perhaps even earlier versions), though exposing such features via the driver might be done later, but that's the beauty of OpenGL's extensions, they can support any new features as soon as the manufacturer releases drivers to do so, they don't need a new API revision to use them.

    All the Quake games, all the Unreal games and the many, MANY games based on their engines including Half-Life run on OpenGL (though many of the Unreal games also run on D3D), the newer Blizzard games like Warcraft 3 and World of Warcraft also run on OpenGL. Saying "Big studios would only use DirectX until 2008/2009" is just flat out wrong. The reason many big name games primarily support D3D on PC is because it was easier to port a Xbox/360 game to PC than it was to port a PS2/PS3 game due to the unique hardware in the Playstation consoles, but now that the PS4 architecture is going to be much more like a PC and uses OpenGL, as neutrino said it's likely that everyone will switch to using OpenGL for PC ports since that will also give them easier access to Linux, OSX and other ports that were previously just ignored due to low demand.

    It's not that impressive, Direct3D has a lot of overhead and is typically slower than OpenGL, but for games that support both graphics APIs on Windows an identical interface is needed and Direct3D is inflexible so you have to make OpenGL do a heap of extra work to behave like Direct3D because it is impossible to make Direct3D behave like OpenGL (you have to LOL at Microsofts poorly named "flixible vertex format" when compared to OpenGL). So Windows users tend to see a slight performance benefit from Direct3D over OpenGL because in games where you can compare them OpenGL is frequently not being used as it was designed to be used, but had such games been designed to use OpenGL as it was intended then the performance difference would be negligible if not in OpenGL's favor.

    Exactly.

    In the interest of fairness though OpenGL has it's downsides too, OpenGL is just a graphics API and that's all it is, it is very minimal with few ancillary functions that would commonly be used by games and that Direct3D has in-built (so you need to write such functions yourself, or use a library like GLUT) and it's not object oriented either so it's a little harder to learn and use especially since it doesn't even come with basic 3D math classes like vectors, quaternions and matrices. So it is a fair bit more work to use OpenGL in the long run and the benefits to the end user are rather minimal (unless you want DX10/11 features like hardware tessellation on Windows XP) making Direct3D certainly look much more appealing for a Windows only game. Also dealing ATi cards in OpenGL can be a serious pain in the *** at times, ATi's support of OpenGL has been less than stellar but it seems things are changing now (no doubt in part thanks to the PS4 using an ATi card with OpenGL).
  17. BulletMagnet

    BulletMagnet Post Master General

    Messages:
    3,263
    Likes Received:
    591
    How much overhead would you add by making an OO wrapper for OpenGL? Bit of academic curiosity here.
  18. SXX

    SXX Post Master General

    Messages:
    6,896
    Likes Received:
    1,812
    I doubt it will be appreciable overhead. Even D3D->OGL wrappers can be really fast with nearly ~1-2% overhead.

    It's only mater that for D3D 10/11 it's already here. It's like very popular newbie questiion "Where to download opengl sdk?", you just need to "think less" when you using D3D, and it's why for some people it's more easy to learn.
  19. dfanz0r

    dfanz0r Active Member

    Messages:
    150
    Likes Received:
    47
    All of what ben says is true, there are also some other things though.

    DirectX has basically everything you need to do graphics development with, matrix math functions etc. Where as on opengl you either have to do that stuff for yourself, or find an external library for it.

    Yes OpenGL is cross platform and the architecture of it makes it faster but the drivers arnt as optimized, which makes around the same or slower in some cases.
  20. neutrino

    neutrino low mass particle Uber Employee

    Messages:
    3,123
    Likes Received:
    2,687
    While this is true most commercial games end up having to roll their own math libraries etc anyway. D3DX does help with some stuff though.

    Personally I would be fine with either API but one of them is cross platform and the other isn't.

Share This Page