views:

203

answers:

6

I've decided to start making graphical games. My language of choice is C++ and the only game I've made so far was a text based game based on Hunt the Wumpus which taught me fundamentals of game loops and robust error handling.

I now think I'm going to move onto a version of Tetris. Obviously moving from text-based to graphical programming is a big leap so I want to make the right decision when it comes to choosing an API. I've done some research and have narrowed the choices down to...

  1. DirectX (using DirectDraw)
  2. OpenGl
  3. Ogre

My main questions are:

1) Will learning one API hurt me further down the road if another becomes much more popular?

2) I've looked around questions on stackoverflow and some basic information on google and have found a lot of comparisons of DirectX and OpenGl. I've gleaned that the main difference is that OpenGl is cross-platform and DirectX is not. I've also seen people recommend Ogre because it's "easier" to use, but that just loops back to Question 1.

Am I missing any crucial information from what I described above?

3) What would you recommend, and suggestions of other API's are definitely okay.

4) Any other info regarding what to expect when it comes to API programming, etc.

Thanks.

+1  A: 

Qt is a good, popular, free cross-platform graphics and UI library. In particular, the Qt Examples page has a wide range of useful examples showing how to use Qt for a number of tasks. Including a tetris implementation, actually.

Learning one API now won't hurt at all, even if you decide to use something else later.

The best thing you can do right now is to pick one, build some example programs that look interesting, and start playing with them. Have fun!

Greg Hewgill
+2  A: 
  1. No, not really. For graphics, OpenGL and DirectX are similar enough that once you learn one, it's not difficult to learn the other. Ogre is a scene graph library, not a graphics API. Alternatives to Ogre might include Qt, SGL, Open Scene Graph, etc.
  2. OpenGL is supported in some form on nearly every platform with the capability to render 3D graphics. Embedded systems (handhelds like the N900 and iPhone, for example) and the PS3 support OpenGL ES, and desktop systems including Linux, Mac OS X, Windows, and many others support OpenGL 1.1 or later. DirectX is supported only on Microsoft platforms - the XBox 360, and Windows, for example. A partial implementation exists in Wine. Ogre, as I said, is a Scene Graph API - it's an abstraction layer over the top of OpenGL and DirectX, supporting both.

Boost does not provide any sort of a GUI library. It provides a lot of useful tools like smart pointers, filesystem abstractions, etc. It's useful in any modern C++ program, and you should use it in new projects.

greyfade
A: 

OpenGL and Direct3D are 3D hardware rendering APIs whereas Ogre is a rendering engine that wraps these lower level OGL/D3D APIs into a more usable scene/model oriented context, providing ways to load meshes, materials, scenes and animations which you would normally painstakingly code yourself to run through OGL/D3D. Its much more than that however.

Nick Bedford
A: 

I'd suggest making it easy on yourself and go with Flash. It's by far the most widely used platform for games. It would allow you to focus more on the gameplay than the programming intricacies. Kongregate is a nice distribution channel and has some tutorials on getting started: http://www.kongregate.com/labs

pbreitenbach
+1  A: 

SDL provides a very simple interface for 2D graphical apps

check out the tutorials on lazy foo's site

http://lazyfoo.net/SDL%5Ftutorials/index.php

Stowelly
+7  A: 

I think the research you've done has misled you somewhat, unfortunately.

Firstly, DirectDraw is not a relevant route in the year 2009 - it was deprecated many versions of DirectX ago. Generally speaking you can start off with any API and what you learn will benefit you when you move to the next, but there's no point starting off with one that is explicitly out of date. For 2D graphics through DirectX you'd typically want to use the ID3DXSprite interface on top of the normal Direct3D 9 initialisation.

Secondly, Ogre is not a good choice for 2D applications. It is a 3D library (not really an 'API' - see below) and as such contains mostly code to help you render 3D models. As such, using Ogre for 2D bypasses most of the benefits that Ogre would give you relative to OpenGL or DirectX on a 3D project.

Finally on the research front, you have missed several good 2D game libraries for C++:

  • SFML (my recommendation, less well known)
  • SDL (very well known and supported, but feature set is getting a bit dated)
  • HGE (I know little about this one, but have heard it recommended)
  • and there are many more, less well known.

In answer to your main questions:

1) No, graphics APIs and libraries are broadly similar and you will learn a lot of transferable knowledge. Please don't start off with a deprecated API or one designed for a different type of game, however.

2) OpenGL and DirectX are largely equivalent for your needs. However I would not recommend you use either of them directly to begin with and instead start your graphical programming experience with one of the libraries above. (Ogre is indeed easier to use, for 3D apps. You're not making a 3D app yet.)

3) See above.

4) I'm not sure if you're aware, but API just means "Application Programming Interface" and doesn't mean graphics specifically, which might be why you were asking about Boost, which provides various other programming facilities (and is worth using in any C++ project). Low level stuff like DirectX and OpenGL are "graphics APIs" but generally speaking to begin with you should be looking at "graphics libraries" which do the dirty work of talking to the API for you.

I would also advise that you can find out a lot more on sites like GameDev.net and specifically their forums, which are full of people like you who are setting out on the same path.

Kylotan
This info was very helpful. I've decided to go with SDL. Regarding Boost, I've used it in a lot of other apps and I thought I remembered reading that it had a graphics library. I'm glad that you clarified the difference between an API and a graphics library. Great post. P.S. I knew the acronym API, but for some reason I only attributed it to graphics rather than the larger picture of requesting services from libraries and OS's in general.
trikker