I'm trying to make a platform game in 2D and I want to know what tool should I use to make it happen. I understand that I can use SDL with openGL. However, if I want to make a solid 2D platform game, should I use SDL? Or, openGL?

  • \$\begingroup\$ OpenGL is low-level enough that when in doubt, just use SDL. \$\endgroup\$
    – Cardin
    Jan 3 '13 at 16:10
  • 3
    \$\begingroup\$ Hello, and welcome to GDSE. This is a "which technology to use" question, which is considered off-topic for the site. Please see the FAQ for more details. \$\endgroup\$
    – user1430
    Jan 3 '13 at 16:27

If you want a lot of fancy effects and sprites on the screen at once, use OpenGL because it supports shaders and is hardware accelerated. If your game is simple and doesn't need a lot of effects or sprites, stick with SDL, especially if it's your first game. SDL isn't hardware accelerated, but it's much easier to use. SDL2 does have hardware acceleration, which also has a very easy API (SDL_Renderers and SDL_Textures).

Note that if you are going to use OpenGL, you can actually use SDL for everything but graphics at the same time. Other cross-platform windowing libraries that support OpenGL include:

  • FreeGLUT - a free implementation of GLUT, which is older and well-documented
  • GLFW - similar to FreeGLUT, but more modern (I use this one)
  • SFML - this one is a bit more heavyweight, but it's also object-oriented
  • \$\begingroup\$ Thank you! I started a doing openGL tutorial weeks ago at lazy foo's website. Good thing I asked today because I stumbled upon SDL and was confused which will be suitable for me. \$\endgroup\$ Jan 3 '13 at 16:34
  • \$\begingroup\$ SDL has a hardware accelerated API: wiki.libsdl.org/CategoryRender#A2D_Accelerated_Rendering \$\endgroup\$
    – weberc2
    Feb 17 '16 at 17:26

OpenGL is for rendering polygons on the screen and SDL provides low level access to hardware like joysticks and mice. SDL also provides access to the video frame buffer.

I would suggest you use SDL for hardware stuff and OpenGL for drawing and stay away from the video frame buffer. It's easy enough to create an orthographic projection and position the camera so it's always pointing down at your scene. If you don't want to use polygons you can always use a textured quad as a sprite. This gives you all the power of OpenGL(rotate, while maintaining your 2d platform game feel.

You might also take a look at love2d.org


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