Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chrono1081

macrumors G3
Original poster
Jan 26, 2008
8,927
6,644
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).
 
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.
 
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...
 
I always thought it was the opposite although I've never done any DirectX development.

Care to give some examples?
 
DirectX is COM-based and quite nicely OO. I wouldn't normally defend anything Microsoft has made, but DirectX is not their worst job.
 
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.
 
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).

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.
 
Last edited:
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...

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.
 
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????
}
 
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????
}

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.
 
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????
}

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.
 
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 :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.