Simple DirectMedia Layer is a 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 used by MPEG playback software, emulators, and many popular games, including the award winning Linux port of “Civilization: Call To Power.”
SDL supports Linux, Windows, Windows CE, BeOS, MacOS, Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX. The code contains support for AmigaOS, Dreamcast, Atari, AIX, OSF/Tru64, RISC OS, SymbianOS, and OS/2, but these are not officially supported.
SDL is written in C, but works with C++ natively, and has bindings to several other languages, including Ada, C#, D, Eiffel, Erlang, Euphoria, Go, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, Pike, Pliant, Python, Ruby, Smalltalk, and Tcl.
SDL is distributed under GNU LGPL version 2. This license allows you to use SDL freely in commercial programs as long as you link with the dynamic library.
The above passage is from the main page of SDL’s website.
Why SDL? SDL is cross-platform, has a simple enough API (I used simple, not good), comes with a comparatively permissive license (you can create commercial apps with it as long as you link dynamically with SDL.dll), integrates well with OpenGL (though my knowledge in that field is limited) and supports most of the stuff required for a game (albeit with extensions). So, since I can’t see why we should not use SDL, we might as well use it.
What exactly is this Simple something Layer? Well. As it’s name suggests, it’s a cross-platform wrapper that provides graphics, input-handling, sound etc. It has several back-ends for various platforms.
SDL? Isn’t that pre-historic stuff? Well, yeah, I agree. The SDL community has ceased to be as active as it once was. SDL 2.0 is taking ages to get officially released. There are no recent additions (except for bug fixes). The API is imperative (not that that’s a bad thing, but it’s pretty tiring sometimes). They still haven’t added support for multiple windows. And the list goes on… (I should write an article on the various short-comings of SDL). But at any rate, SDL is time-tested, has been used in a lot of commercial and open-source projects and is ‘good enough’.
Why don’t you use SFML / Allegro / etc. ?. It’s WAY better than this obsolete junk. Yet another library war begins! (wait a min, I’ll get popcorn). Seriously, why do people compare libraries? Admittedly SDL lacks stuff that some other library may have. But, you can make games with pretty much all of them. The only reason I picked SDL instead of all the others for this tutorial is well… because it was the easiest to quickly set up. Maybe I’ll do tutorials on them too some other time.
How dare you let that SFMl / Allegro / etc. fan-boy trick you into admitting SDL’s inferiority? SDL is way better than all of that useless garbage! REAL programmers use SDL! The return blow. Guess the war has already begun in spite of my efforts to prevent it…