Categories
Game Development Linux Game Development

POTM for May: libSDL

The general idea of the Project of the Month is to donate some money to an open source project and write a blog post about it. Everyone knows about the major open source projects, such as the Linux kernel or Firefox, but there are plenty of examples of open source projects that impact you in some way that might not appear on most people’s radars.

For the month of May, I chose to donate money to the Simple Directmedia Layer, the popular cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. It is currently at version 1.2, is widely used in games and other media applications, and has bindings to a large number of languages. If you run an operating system, it is very likely that libSDL runs on your system.

Sam Lantinga created the SDL while working at Loki, although there are some people who think he may have written it at his previous job. SDL acts as a thin wrapper over platform-specific APIs. For instance, if you use it on Windows, it wraps around DirectX, but if you use it on a distribution of Gnu/Linux or BSD, it will use XLib. If you think of it as an abstraction, you can code once and compile anywhere. In fact, my Killer Kittens from Katis Minor project can be compiled for my Debian system and for Windows without any code changes if you use a compiler that doesn’t assume you need WinMain to replace the main function.

The documentation is available at the main site, and I’ve always found the SDL Documentation Wiki to be useful. Of the books I’ve read, I would highly suggest Focus on SDL by Ernest Pazera and Programming Linux Games by John Hall. While both books a few years old, they are still relevant and can get you up to speed quickly. You can also find SDL used in the example code a couple of game programming books by Erik Yuzwa at Wazoo Enterprises.

If you are trying to figure out what libraries to use for your project, even if you aren’t thinking about porting it to a second platform, I would suggest libSDL. If all it does is provide a simple abstraction for DirectX libraries, you will still come out ahead, and if you want to port it later, it should be much easier than completely gutting platform-specific libraries and replacing them with another platform-specific library.

Thanks go to Sam Lantinga and the libSDL development community for making a simple-to-use, cross-platform, freely-available tool for game development!