views:

905

answers:

4

Hi there,

I'm trying to work out whether to learn DirectX or to continue on with OpenGL...

I dev mainly games, and I know enough of OGL to get by, nothing more. I know that DirectX and D3D are popular amongst professional games developers, is there any reason behind this?

Which API is easier to learn and use? Is there any difference in quality (in a gaming world for example).

I like to use Linux as well as Windoze, and like to make cross platform apps, so OGL seems a sensible choice, however I'm trying to get into professional games developing and I'm wondering if I would stand a better chance with DirextX and D3D under my belt, I also only really run Linux on my laptop, which is for work and not for play, my PC is a gaming powerhouse ;)

If I continued learning OGL would it be relatively easy to learn D3D and DX, or would it be like learning all over again? If I learned DX to a high level, would it be easier to get along with OGL? Is the theory interchangable between the languages or is there significant differences?

Basically, I'm at a loss as to which API to use, I'm working on my first full featured 3D demo game, I'm going to need to learn a fair bit of OGL to get it up and running how I want, so if using DX and D3D is better now would be the best time to make the switch in my opinion.

What I've read on the net is overwhelming, so many different opinions, lots of outdated information, so I want to ask now where I know its going to be relevent to what I want, and when I want.

So, taking that all into consideration, which would be the best API for ME to learn and dev with?

+2  A: 

D3D used to be horrible but I have to say it's getting better now. Since DX9c (I think) it has got utility libraries (much like GLU & GLUT), which dramatically reduced amount of code required to produce a 3D app.

I think the main reason why most Windows games uses D3D these days is mainly because

  1. DX is a complete package while OGL is just a graphics library
  2. DX tend to adopt new features faster but OGL is certainly catching up since OGL 2.0
  3. DX has got mighty Microsoft behind it so graphics card companies are more willing to implement new API features

Having say that I'll probably keep using OGL since

  1. that's the only multiplatform 3D graphics API.
  2. Wii, PS3 & iPhone are all using OGL-like API.
  3. Blender, which is a very nice 3D modelling tool which has integrated support for GLSL
oykuo
OpenGL often picks up features before DirectX can, due to its extensions framework and DirectX' lack of one. NVIDIA and ATi are both very good about adding new GL_ names for new features.
greyfade
And it's also worth pointing out that most PS3 developers don't actually use the OpenGL ES API that's provided. They tend to prefer the lower-level graphics API the Sony libraries expose.
greyfade
+1  A: 

The two APIs are converging, the difference hardly matters. Both are just ways to send stuff to shaders nowadays. As a professional programmer you'll end up knowing both anyway.

So I would first learn the one that is going to ground you in the basics of 3D APIs, and be cross platform (if this a requirement).

GL still has the slight edge by being less "crufty", so I'd go with that.

Justicle
+13  A: 

There are a few reasons that DirectX is more popular than OpenGL for games:

  • DirectX drivers are generally better optimized and less buggy.

  • DirectX periodically revises the API to better reflect the current state of graphics hardware and breaks backwards compatibility. OpenGL retains compatibility for outdated functionality which makes the API a bit cluttered.

  • There's generally only one way to do things in DirectX. OpenGL's extension mechanism means that a feature may be exposed in different ways by different hardware vendors which again clutters the API and makes things more complex than necessary.

  • Self-reinforcing popularity: DirectX is more popular so there is more example code and there are more DirectX focused articles and presentations. This is a virtuous circle. Microsoft reinforces this by releasing lots of games-focused material at developer conferences like GDC and Gamefest.

  • More game focused: Microsoft listens to game developer input and the needs of game developers largely drive DirectX development. OpenGL also caters to other groups and their needs sometimes conflict with what game developers want (see the controversy around OpenGL 3 for example).

  • More cross platform where it counts: most game developers are targeting PC, Xbox 360 and PS3 these days. Of those, DirectX runs on PC and Xbox 360, OpenGL only really runs on PC (few developers use PSGL on the PS3, most prefer libgcm which is a lower level API that exposes the RSX hardware directly).

  • Better developer support: PIX on its own is enough reason to prefer DirectX for development on the PC.

Most of the core concepts of graphics programming are common across both APIs but there are lots of subtleties that mean it's not totally straightforward to move between them. I'd advise someone getting into 3D programming for games now to start with DirectX 10, that way you don't have to deal with any of the legacy cruft like fixed function support that still exists in DirectX 9 (and OpenGL). DirectX 10 is a better match to the underlying hardware as well which is helpful for learning what your code is really doing. The downside of learning DX 10 over DX 9 is that there is less tutorial material available as it is a much newer API.

mattnewport
Ok, if I coded with DX10 would I be able to run that application under XP? I have both XP and Vista installed on my PC but my preference lies with XP as its more stable.
Auraomega
No, DX10 only runs on Vista and up. If you need to run on XP then you'll have to stick with DX9.
mattnewport
A: 

If you already know ogl stick with it, they (used to be) the same thing, you're better off spending your time on getting better at that, it's better in the long run (btw I use directx, but realistically you only need 1 unless you have a bad employer).

DX would be advisable for you if it didn't alienate XP and had noticably more features than ogl, which in a practical perspective (game devving not proof of concept) it doesn't.

Also, tools like Blender are nothing to do with ogl.. as Justicle says, shaders are the thing to learn and outside of that, the API you choose is just convenience -> xna for prototyping.

Sorlaize