A comparison of graphics libraries and their respective programming languages. A.K.A. "Which do I pick? With a twist."

I'm a long time professional programmer who never gave up on programming as a hobby. 3D programming has always appealed to me, but after some trial and error I always came back to (and got stuck on) the same question:

Which to choose?

  • C# with XNA.
  • C++ with DirectX.
  • Java with OpenGL.

All three appeal to me:

  • XNA, because it's managed, of high quality and very complete.
  • DirectX, because it's de facto standard for large games.
  • OpenGL, because it's open. It has a proven track record of high quality games built using it. + Eclipse hotswap functionality is sexy.

Keep in mind here that I will:

  • Use the above library and language for hobby use.
  • Will want to develop both 3D games and 3D tooling.
  • Might seek a job in a 3D programming industry.

For the sake of the argument, assume I am equally well versed in C#, C++ and Java. And have no preference for any of the three mentioned libraries. In reality I have a slight preference for one of those three, but the quality of the code I produce in the languages is the same.

Replies with sources as links are preferred! OGRE and Irrlicht (and similar) are also contenders, but not preferred because it introduces additional depencies on other developers.

  • 1
    \$\begingroup\$ You can use DirectX and OpenGL with C# via SlimDX and OpenTK, respectively. \$\endgroup\$ – r2d2rigo Jan 11 '12 at 15:53
  • \$\begingroup\$ I think that is bad advice considering I am a proficient C++ programmer and it would be much easier to approach DirectX via C++. OpenGL via Java exactly the same. \$\endgroup\$ – Jos van Egmond Jan 11 '12 at 16:06
  • \$\begingroup\$ @Manadar I don't follow your comment. Why OpenGL with Java and not C++ or C#? \$\endgroup\$ – Jimmy Jan 11 '12 at 17:29
  • 1
    \$\begingroup\$ I think this "question" is, unfortunately, overly broad and discussion-oriented and as such not a great candidate for this site. \$\endgroup\$ – user1430 Jan 11 '12 at 17:41
  • 1
    \$\begingroup\$ Well, it got closed. The other guys are right to do so, as it is subjective. Thanks for accepting my answer, anyway. I would suggest you go ask this over at the gamedev.net forums, if you want a better response. I'll be glad to post my answer there as well, if you comment back here to let me know. \$\endgroup\$ – Engineer Jan 11 '12 at 20:03

If I were you, I'd take the time and learn OpenGL, particularly since you're a dedicated hobbyist at this stage. Like C and C++, it's a general-purpose tool that sets you up for opportunities in different industries, if it ever interests you to do 3D programming for eg. medical visualisation or defence contracting. They say that DirectX is a short leap from OpenGL. Also, I would say you can get into GPGPU technologies like OpenCL or Nvidia CUDA more easily if you take this route. And IMO, that's where the future is: General purpose, massively parallel processing without restricted access to the bulk of system memory.

So that's DirectX covered under that umbrella, as well. I would favour it only slightly less than OpenGL, but that's very much a personal preference. It's still miles ahead of the remaining alternatives.

For the above reasons and more, I wouldn't choose XNA. I find the framework restrictive and to me at least, the architecture desicions they took don't make much sense. Yes, I know it's great to be able to deploy for Windows and XBox360 at the same time. Yes I know C# 4.0 is (let's be fair) a great language in many ways. XNA may save you time. But I'd still avoid it unless I was specifically targetting the Xbox360 for a game that didn't require the degree of control that a lower level language offers.

To be fair, if you are not already a C or C++ programmer (you don't specify), I would certainly go the Java and OpenGL route. Notch, of Minecraft fame, has made a huge name for himself with those two technologies as an indie and I don't think that is something to sneeze at. I used Java briefly last year and in comparison to C#, it may have less modern features, but the consistency and simplicity of the core libraries are just brilliant. Java collections are an absolute pleasure, more than any other language I've worked with. And they support just about any type of collection you can think of, natively. And they're FAST.

You did leave out one popular option, which is Unity. This is ideal if you want a really, really fast start. The basic edition is free, and you can use DropBox for source control (since unless you pay for version control support otherwise, it can be problematic). It uses Mono C#, although not the newest version.

| improve this answer | |
  • \$\begingroup\$ I think you hit the nail on the head. Thanks, so much, for this answer. I'm interested in hearing other people their opinions. Wondering if they will choose DirectX over OpenGL, and why. Right now I am a C# programmer, but I have almost as much experience with Java and C++. It really doesn't matter which language I choose. \$\endgroup\$ – Jos van Egmond Jan 11 '12 at 15:24
  • \$\begingroup\$ I would personally be incredibly wary of using OpenGL for anything new - the quality of drivers, tools, documentation and overall support just isn't there. With D3D, for all it's quirks and proprietary nature, if your code doesn't work you can be very certain that it's due to a problem in your code, and not down to having to fight a broken driver or deal with obtuse spec documentation (the unity guys switched to D3D as the default on Windows for this precise reason, and several CAD tools have also made the same switch). \$\endgroup\$ – Maximus Minimus Jan 12 '12 at 12:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.