SDL2 Tutorials

Welcome!

The goal of the following tutorials is to provide you with an introduction to SDL2 in C++. It’s assumed throughout the series that you have some familiarity with C++ and are comfortable with functions, classes and memory management. If you find yourself having trouble understanding the code in the tutorials feel free to comment on the lesson and/or grab a good C++ book from this excellent list on StackOverflow.

The full source and assets for the tutorials can be found on Github. It may be helpful to check against this code to find errors, but it’s important to not copy directly as it will take away from the learning experience. If you ever have questions about the meaning or functionality of SDL features head over to the SDL documentation wiki and/or comment on the lesson page. You can also get help with SDL in the SDL Forums.

Tutorials

Lesson 0: Mac Command Line

Thu Aug 15, 2013

To build the projects on OS X we’ll be using a simple makefile that will include the framework for us. The makefile assumes you’ve installed SDL following the instructions in the .dmg file on the SDL2 downloads page and now have it available as a framework.

If you’re unfamiliar with Makefiles a basic introduction can be found here.

Continue

Lesson 0: MinGW

Thu Aug 15, 2013

To build the projects with mingw we’ll be using a lightweight makefile that will set the include and library paths along with linking our dependencies for us. The makefile assumes that you’ve placed the SDL mingw development libraries under C:/SDL2-2.0.0-mingw/ and that you’re using the 32bit version of mingw and the 32bit libraries. You should change this to match your compiler (32/64bit) and the location of your SDL folder. To use makefiles with mingw call mingw32-make.exe in the folder containing the makefile.

If you’re unfamiliar with Makefiles a basic introduction can be found here.

Continue

Lesson 0: Setting Up SDL

Thu Aug 15, 2013

The first step is to get the SDL2 development libraries setup on your system, you can download them from the SDL2 downloads page.

Continue

Lesson 0: Visual Studio

Thu Aug 15, 2013

Now that we’ve got the libraries installed we’ll want to create a new project to include and link against SDL. At the end we’ll save this as a template project so in the future we can just load our template and get to work. First we need a new empty C++ project.

Continue