12
\$\begingroup\$

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?

\$\endgroup\$

8 Answers 8

16
\$\begingroup\$

I'd recommend SDL (http://www.libsdl.org/) 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.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I found SDL good but it was very difficult to get the paths and includes setup properly. \$\endgroup\$
    – Skeith
    Apr 7, 2011 at 12:21
  • 1
    \$\begingroup\$ Also check out lazyfoo.net/SDL_tutorials for some decent tutorials (includes setup tutorials for various IDEs). \$\endgroup\$
    – BeanBag
    Jul 2, 2013 at 9:43
  • \$\begingroup\$ 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. \$\endgroup\$
    – Carter81
    Sep 24, 2013 at 5:31
7
\$\begingroup\$

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.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ SFML is also C++, whereas SDL is C. This makes a difference if you actually want to learn C++. \$\endgroup\$
    – jsimmons
    Aug 3, 2010 at 2:28
6
\$\begingroup\$

http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=263140&reply_id=3598844

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.

\$\endgroup\$
4
  • \$\begingroup\$ Great read =) What a minefield this subject is... \$\endgroup\$
    – Nailer
    Aug 4, 2010 at 14:48
  • 6
    \$\begingroup\$ 404, page not found \$\endgroup\$
    – axel22
    Apr 7, 2011 at 14:23
  • \$\begingroup\$ archive.gamedev.net/community/forums/mod/journal/… \$\endgroup\$ Apr 7, 2011 at 21:00
  • 1
    \$\begingroup\$ I get a 404 on the archive.gamedev.net/... link. \$\endgroup\$
    – Exilyth
    Apr 20, 2013 at 21:13
4
\$\begingroup\$

http://blog.wolfire.com/2010/01/Why-you-should-use-OpenGL-and-not-DirectX

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.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Tetrad
    Aug 2, 2010 at 21:45
  • \$\begingroup\$ 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. \$\endgroup\$
    – drxzcl
    Aug 4, 2010 at 21:05
1
\$\begingroup\$

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

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

http://hge.relishgames.com/

\$\endgroup\$
0
\$\begingroup\$

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.

cheers!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ +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. \$\endgroup\$
    – Carter81
    Sep 24, 2013 at 5:35

Not the answer you're looking for? Browse other questions tagged .