Getting Started with 2d Game Dev (C++): DirectX or OpenGL?

  • Getting Started with 2d Game Dev (C++): DirectX or OpenGL? Dfowj

    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?


    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.

  • 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.

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

  • 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.


    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.

  • 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.

  • 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.


  • 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.

c++ opengl directx
Related questions and answers
  • I have the book iPhone 3D Programming; this book taught be a lot about overall c++ iPhone application architecture and iPhone OpenGL ES. But a lot of the book is obviously about 3D, so most of the book wasn't that useful to me. I also have Game Coding Complete 3rd Edition; this book taught me a lot about game engine architecture but the emphasis is on c++ windows desktop game programming. I am looking for c++ 2D game engine architecture books. I'm not looking to use any frameworks; I want something more geared towards 2d c++ game engine architecture. Any suggestions? Thanks.

  • better. I would also like compatability, If Theres one that fits DirectX(at least 9) and OpenGL, then that would be good) 2D Graphics(I liked SFML, so it its possible to get something that works with SFML..., so I planned to start over. The libraries that I have used are SFML, OpenGL, and Bullet Physics, along with GLM to load the models. But the problem is that the 3D graphics arent working with the Physics correctly... So my main question is: What would be a good combination of libraries to make an online game with? Im sure that many people have good combinations of libraries for making a game

  • I'm looking into building a cross-platform opensource 2D RPG style game engine for ChaiScript. I want to be able to do all of the graphics with SVG and need joystick input. I also need... not seem to have joystick input support, which would require that SDL or some other library also be used. So my question can be summed up as this: What is the best way to get SVG and joystick support in a 2D C++ library while minimizing dependencies as much as possible (preferably avoiding Qt altogether)?

  • to be moved then so be it), but i felt it would fit here just a bit, since its a game-dev type question. Anyways, My compiler is MinGW that uses the IDE Code::Blocks. also the operating system that im...I am using Ogre3D, and have been using it for a while. Also lately, I have been using the Opengl Rendering system that is included in Ogre, only because Directx will not compile correctly(Will post errors on request through comment). But as of now the main problem is when i render my model(it is a plane with simple, unblended pixelated texture), it looks like this on my Laptop(Left Image

  • I been working in the animation of a 2D platformer game in C++/SDL/OpenGL, and my team and I reach the point where we need to establish that every animation of the player (Walking, Running, etc..) needs a different framerate for our concept, but I use as a guideline the Game Programming All In One as a example for the smooth animation, and in the book recommend have variables that limits... points of the game the animation doesn't look really smooth when in other points it is. I leave the video of the "gameplay" so everyone could see what I mean.

  • Say I develop a game for mobile platform running OpenGL ES 2.0. I have done 2D part, and now I wish to import some 3D objects. The imported 3D objects must contain the following: Vertices..., that will let me import 3d meshes into my game, ready to use? The solution/middleware should be: easy to use easy to port efficient not consuming too much memory with unnecessary things containing all the above mentioned features plus things I haven't considered yet Programming language is: C++. Currently, I'm developing under Windows 7, Visual Studio 2010, and OpenGL ES 2.0 emulator. Later

  • through APIs. After all, I want to make a game, not an engine. So the question becomes: Is there maybe a cross platform (free or free to develop?) engine available that I could use for 2D development? I prefer: C#, Actionscript. I don't mind using c++ if the toolset is above average, but I highly doubt that there is something out there like that. Please prove me wrong :) So summary: I'd like... people can play my game once finished). I'd like to have it available on many mobile platforms aswell. (because I love touch input for some reason) I do know the XNA framework pretty well

  • I'm writing a game engine which is going very fine. However, I'm now posed with handling textures. My Engine is in 2D, for simplicity reasons mostly to get a good idea of how to work with OpenGL. I do this in C++, and I have a hierarchical set-up when it comes to classes. There's a base class and some other classes derive from that. So now I'm onto the part where I want to load up some textures..., and OpenGL renders the whole thing. I think that's the best I can do at explaining. Know that the SceneManager itself contains no OpenGL code, just paths and information that OpenGL needs to know

  • ? My idea is to have a separate thread that compares the space difference of all the players every few seconds or so and stores references to all nearby players in the player's object for easy access...I'm looking into designing and implementing an online RPG (or more accurately, redesigning an existing piece of server software). One of the problems is that of managing visibility. Update data for other players should only be sent to a game client if their player is near the other players (i.e. you shouldn't get health updates for people you can't see on the other side of the map). The main