Anyone else think Direct X is just plain awkward? (Yes I know this is a Mac forum :P)

Discussion in 'Mac Programming' started by chrono1081, Jan 26, 2011.

  1. chrono1081 macrumors 604


    Jan 26, 2008
    Isla Nublar
    So for my 3D programming class, we have to build our projects in both OpenGL and DirectX. For some reason my school thinks its a good idea to teach both at the same time :eek:

    Anyway I can't help notice that OpenGL seems so much more elegant, faster (comparing the two identical programs), and much easier to read through. The difference is night and day. Granted part of it is the MFC code but still.

    Why do people still use DirectX? Correct me if I'm wrong but everything I've tried and read about points to OpenGL as being superior right now (I know this flip flops).
  2. SmokeyRobinson macrumors regular

    Dec 11, 2010
    Why do we use calculus when arithmetic is so much easier?

    Because we can make nice looking games that run well on Direct X or we can make games that run poorly in OpenGL.
  3. TheStrudel macrumors 65816


    Jan 5, 2008
    Tell that to Sony...they seem to be getting their implementation of OpenGL to do some pretty nice work for them.

    Blizzard seems to be doing all right with it, too.

    Poor artist blames his tools...
  4. kainjow Moderator emeritus


    Jun 15, 2000
    I always thought it was the opposite although I've never done any DirectX development.

    Care to give some examples?
  5. Sander macrumors 6502

    Apr 24, 2008
    DirectX is COM-based and quite nicely OO. I wouldn't normally defend anything Microsoft has made, but DirectX is not their worst job.
  6. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Poor logic there. Just because a game runs poorly and uses OpenGL, it is not necessarily true that the reason it runs poorly is because of OpenGL.
  7. Ainze macrumors regular


    Feb 28, 2010
    Pros and cons aside, people use DirectX primarily because it's the dominant 3D API on the dominant platform (Windows).

    Yes, many other reason on both sides, but that's the simple main answer.
  8. holmesf, Jan 27, 2011
    Last edited: Jan 27, 2011

    holmesf macrumors 6502a

    Sep 30, 2001
    DirectX 10+ is actually a much better thought out API than OpenGL 3. OpenGL suffers from a lot of bloat in the form of official and vendor specific extensions and two decades of legacy support. In OpenGL there tends to be about 10 different ways to accomplish any given task, but only 2 of them are best practices. Take a look at OpenGL ES 2.0 compared to the desktop OpenGL and you will realize how bloated the desktop version is. Regrettably, OpenGL is way behind DirectX at this point.

    Why use DirectX? Well, for one thing DirectX drivers on Windows tend to be far superior to the OpenGL ones and so performance is better. Secondly DirectX is is your only option for XBox 360, and the DirectX clone is the best option when programming the PS3 (the OpenGL layer is just built on top of it). Secondly DirectX 11 is the only API that currently exposes certain features such as domain and hull shaders, and MSAA'd textures for render targets.

    The reasons for using OpenGL include better cross platform compatibility, as it's available on more platforms. It's also pretty much your only option if you are targeting the Mac, Linux, iPhone, or Android (OpenGL ES in the latter two cases). Also, if you're a fan of open standards, OpenGL is for you.
  9. holmesf macrumors 6502a

    Sep 30, 2001
    Contrary to common belief, the PS3 does not use OpenGL. It has OpenGL ES available, but this is built on top of their DirectX clone library. For that reason nobody really uses it because performance is poor.
  10. chrono1081 thread starter macrumors 604


    Jan 26, 2008
    Isla Nublar
    In everything I've done so far OpenGL has been faster then Direct X. Each week we have to make projects (the same project) in both OpenGL and Direct X and have a frame rate count.

    Obviously this may change when I get into more advanced things. We are just beginning with textures, lighting, fonts, cameras, device polling, etc.

    DirectX is just such a hassle and its very hard to read through since it uses Microsofts completely awful syntax. (I have yet to meet anyone who likes it). I prefer readable function names and parameters to crap like:

    HRESULT WINAPI DirectInput8Create(

    HINSTANCE hinst,
    DWORD dwVersion,
    REFIID riidltf, //What the hell?
    LPVOID *ppvOut, // ???
    LPUNKOWN pUnkOuter //Eh????
  11. holmesf macrumors 6502a

    Sep 30, 2001
    I'm not sure why that is, but the fact is that DirectX tends to have better drivers, and it has a whole host of optimizations that make for less overhead. I can't comment on the ugliness of the code, because I'm familiar with Mac OS X and OpenGL, which makes me instantly biased in that direction.
  12. Sander macrumors 6502

    Apr 24, 2008
    Microsoft's insistance on using Hungarian notation is a bit of a drag. But most of the stuff you're asking questions about here are plain COM, and not specific to DirectX. After you created the main interface using this plain C API call, the rest is relatively nicely object-oriented.
  13. junkster macrumors regular

    Nov 6, 2006
    You can't judge an API by what you use in a programming class. The bottom line is that you use what's supported on the hardware you're targeting. (The only platform that has more than one option is Windows.)

    Modern 3D programming is all about data organization and writing shaders to operate on said data. The "API" turns into a single call of "process this batch of vertices and associated data, please."

    If you want to see a horrific API, try Core Audio :)

Share This Page