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

So, i'm a student looking to get my foot in the door of game development and im looking to do something 2D, maybe a tetris/space invaders/something-with-a-little-mouse-interaction clone.

I pointed my searches in the direction of C++ and 2d and was eventually lead to DirectX/OpenGL

Now as i understand it, all these packages will do for me is draw stuff on a screen. And thats all i really care about at this point. Sound isn't necessary. Input can be handled with stdlib probably.

So, for a beginner trying to create a basic game in C++, would you recommend DirectX or OpenGL? Why? What are some key feature differences between the two? Which is more usable?

share|improve this question

closed as primarily opinion-based by Byte56 Oct 28 '13 at 20:45

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 15 down vote accepted

I'd recommend SDL ( for 2D, it was where I first started with graphics stuff and it was pretty easy to use, even though I barely knew C++ at the time.

This (mirror) is the set of tutorials that I started with and found very useful (they were a bit dated even ~4 years ago when I worked through them, but I don't think SDL has changed much and they should still be relevant).

SDL also does input handling and SDL_Mixer can do basic audio.

I've never worked with DirectDraw or OpenGL for 2D stuff, so I can't comment there, but I can definitely recommend SDL.

share|improve this answer
I found SDL good but it was very difficult to get the paths and includes setup properly. – Skeith Apr 7 '11 at 12:21
Also check out for some decent tutorials (includes setup tutorials for various IDEs). – BeanBag Jul 2 '13 at 9:43
Agreed with @Skeith. I can't imagine the headaches of getting SDL setup for the first time for beginners. It is difficult enough dealing with some of the common setup problems with amateurs or even professionals. After getting SDL setup for the first time, I was able to get ANYTHING setup for the rest of my life, with ease. That's how many headaches it gave me; how much experience I got learning about more than is typical for setting up a library. It was too long ago to recall what exactly gave me the most problems, or what problems I had, but all other libraries were easy to setup. – Carter81 Sep 24 '13 at 5:31

I used both SDL and SFML for my game projects. I used SDL for a finished game, a tetris game, and I mostly used SFML as a windowing layer for shader experiments. From my experience, I'd have to say that SDL is what it says. It's a simple direct-media layer, which abstracts the data your media (sound and video) works with to a level you can interact with accross different platforms. That's "all" it does.

Because of that, you generally have to mix it with a few other libraries, most notably SDL_mixer, SDL_gfx, and SDL_image, which provide functionality everyone needs to create games.

All of these libraries are also meant for the C programming language, and they follow it's conventions. Not that there is anything wrong with that, but if you want an object oriented approach to how you interact with io, then you basically have to build that layer yourself.

SFML comes with everything right out of the box. It has sound, it has video, it has mixing, it has frame-capping, and it is object oriented. If that's what you want, I'd recommend you go for that. SFML also has an abstraction layer for some of the basic functionality in opengl (specifically beginShape/EndShape and pixel shaders). I don't think SDL has anything like that, just a method to merge with it.

P.S. Not to drive away the conversation from C/C++, but if you're not using that language for any particular reason, and want an easier one, there's always pygame. Which is basically SDL+ for Python.

share|improve this answer
SFML is also C++, whereas SDL is C. This makes a difference if you actually want to learn C++. – jsimmons Aug 3 '10 at 2:28

I agree with these remarks and think it is a stellar discussion of why DirectX is better than OpenGL.

That journal is in response to David at Wolfire.

I hope that serves to balance it out a bit. ;)

But in general, if you're using a cross-platform, cross-API framework:

Use DirectX on Windows and OpenGL on *nix.

share|improve this answer
Great read =) What a minefield this subject is... – Nailer Aug 4 '10 at 14:48
404, page not found – axel22 Apr 7 '11 at 14:23
I get a 404 on the link. – sarahm Apr 20 '13 at 21:13

I agree with these remarks and think it is a stellar discussion of why OpenGL is better than DirectX.

However, this question is absolutely a matter of opinion, and DirectX absolutely has its benefits over OpenGL, especially 10 and 11 and especially in the context of game development.

Also, should you choose to go with OpenGL, SDL is a wonderful and very popular library, and there are plenty of resources for learning OpenGL (NeHe, etc.) - but that's the place for another question perhaps.

share|improve this answer
As a counterpoint to the OGL vs DX discussion, the Unity guys explicitly decided to switch to DirectX on Windows since default OpenGL drivers for most video cards are so bad. I don't have the reference in front of me, but at once of their conferences they said something along the lines of OGL drivers being their #1 crash problem on Windows. Fortunately their abstraction layer means that you don't really care from a users perspective. – Tetrad Aug 2 '10 at 21:45
We make business-oriented visualization software for both unix and windows, and I can confirm that the majority of the issues we see on Windows are OpenGL driver related. – drxzcl Aug 4 '10 at 21:05

If you're just starting out it's probably better to use an existing 2D engine or framework such as SFML.

share|improve this answer

I like Direct X and have been using it for several years on many projects but if your learning do watch out for version issues.

I found that the majority of direct x code will not compile under a different version and this can be hell if you are trying to follow a tutorial.

I recommend Direct X as there are features for everything that make it easier when you are first beginning and then more advanced ways of manipulating things as you advance.

share|improve this answer

Haaf's Game Engine

I don't know how up-to-date it is (i mean it's not, but i don't think there's any reason that it shouldn't be usable), but i used it a while ago (C++) and i really enjoyed it. HGE wasn't updated since 05.08, but again, i remember it being pretty simple to learn, and fast. It also comes with all sorts of tools and helper like a particle system.

Anyway, if what you want is to create an actualy -game-, as opposed to learning the stuff that's going on "under the hood" in the processes of drawing and such, i'd recommend using something higher level then openGL or DirectX, or you're going to spend your time drawing stuff on the screen as opposed to creating an actual game. And HGE is definitly worth checking out.

share|improve this answer

Im in the same position as you are, having just begun working on game development myself (on the iPhone platform) a few months ago. Coming from a C background, I would actually suggest you use a framework (Particularly Cocos2d).

The advantages of a framework are more then can be discussed in this post - but mainly it handles most of the low level processing with OpenGL and provides you methods to deal with the what your most likely going to require for game dev. They have a great community, are open source, and hence if you need to access the core code of the framework / modify any bit of it to suit your needs / go to the low level OpenGL if necessary - you are still given that choice.

You can go the route of direct OpenGL but to me it just seems like overkill.

You will most likely also want to look into various different physics libraries that exist out there - Google Chipmunk and Box2D for more information.


share|improve this answer
+1 for not deserving to be at -2. Too many trolls on this website giving negatives for no reason. Honestly, I don't even understand why they even allow anything below 0 to be shown. It's as idiotic as youtube allowing downvoting. – Carter81 Sep 24 '13 at 5:35

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