Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm fairly experienced with C and C#, but I've only ever created console/windows applications. I'm also experienced with AS3 and I've made some flash games.

I want to make proper 2D games in C++, but I have no idea where to begin with graphics. There are entire books devoted to game development in C++ that only work with console applications and I'm finding the lack of resources and tutorials for proper 2D games frustrating... I'm also not particularly interested in using existing engines because I want total control of what I create.

I've heard of the Allegro library; is it something important/popular that I should look into? How will I use DirectX?

Any resources or links to tutorials or information is greatly appreciated.

share|improve this question

closed as not constructive by Josh Petrie, Tetrad Dec 17 '12 at 17:47

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Please see the FAQ about "where to get started" and "which technology to use" questions. – Byte56 Dec 17 '12 at 16:58
up vote 5 down vote accepted

A very nice starting point for 2D development in C++ is SFML. Taken from the official website:

SFML is a portable and easy to use multimedia API written in C++. You can see it as a modern, object-oriented alternative to SDL. SFML is composed of several packages to perfectly suit your needs. You can use SFML as a minimal windowing system to interface with OpenGL, or as a fully-featured multimedia library for building games or interactive programs.

I've been using SFML for a while, it's an object-oriented API which has a lot of examples on the site for you to learn from, as well as tutorials. If you are confused whether to use 1.6 or 2.0 I'd suggest going with 2.0 because eventually you'll still have to upgrade.

Even better, SFML is not C++ exclusive, it works with the following languages:

  • C
  • C++
  • .net (C#, VB .net, C++/CLI)
  • Python
  • D
  • Ruby

And the nice thing is, you can use OpenGL with it and the Qt framework as well. I think it's a nice starting point for 2D development, but if you want alternatives you can try out Allegro or SDL

share|improve this answer
I've also seen SFML successfully integrated with with wxWidgets (not only Qt). The code is open-source, readable and very pleasant, if you have a problem you can easily look into SFML's code if you don't find an answer on the web. It's also possible to integrate your own shaders or post-process effects if you need to (since you can use low-level OpenGL calls without breaking anything). – Liosan Dec 17 '12 at 9:51
@Liosan it's indeed possible, SFML has a lot of possibilities in it. – Bugster Dec 17 '12 at 20:08

On some level, you're going to have to manage gamestates, your video hardware, audio hardware, etc. While it can be a good learning experience to dabble with DirectX, DirectSound, and the like, if you immediately want to make a game, it's best to use some layer of abstraction.

SDL is cross-platform, open-source, works with C++ natively, and has great documentation and tutorials to get you started.

SDL Website

share|improve this answer

I highly recommend OpenGL for starting your game programming exercises. 2D game is basically flatted display in terms of 3D. For links and tutorials, I think you should be able to actually learn to display some primitive shapes such as a triangle first. Such tutorials on basic display is all over the web and youtube.

share|improve this answer
The OP explicitely said he wants to make 2d games. There are excellent libraries for that which use OpenGL for hardware acceleration internally. What would he gain from learning OpenGL? – Philipp Dec 17 '12 at 9:47
I don't disagree with this question. It is very possible to make 2D games in OpenGL, and in fact I make my 2D games in plain Direct3D. Even though it may not be the easiest library to make 2D games for a beginner, I still believe this is a very legitimate answer. – Panda Pajama Dec 17 '12 at 9:57
@Philipp ur reputation is above 1000. I want to argue from my perspective but I guess it's better off using other libraries than use OpenGL to build 2D games... – Tofu_Craving_Redish_BlueDragon Dec 21 '12 at 10:15

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