"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."
In this series of blog posts I will look at the basic use of SDL with a focus on using it on the Raspberry Pi, however all the code should work under all linux distributions as well as Mac OSX ( Windows should also just work, however I don't have a windows machine to test against).
Installing SDL using apt-get
The easiest way to install SDL on the rpi is to use apt-get and install the pre-build development packages. To do this use the following commands
sudo apt-get install libsdl1.2-dev
To check that this has been successful we can now execute the sdl-config script as follows
sdl-config Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]
Installing from Source
The source code for SDL is available from this link http://www.libsdl.org/download-1.2.php. This is the easiest way to get SDL working on Linux system without apt as well as for Mac OSX. To build from the .tgz version do the following
tar vfxz SDL-1.2.15.tar.gz cd SDL-1.2.15 ./configure make sudo make install
Once this is done we can again check to ensure that things are working by testing the sdl-config program above.
Raspberry Pi user config for the console
If you intend to use SDL on the raspberry pi without using X windows the SDL library will attempt to access the framebuffer directly. By default only the root user has access to the framebuffer device so we need to add the current user (i.e. what you logged in as) to this group. To do this we need to add the user to the group video, input and audio groups (audio if we use it later) for a minimum you must have video and input.
sudo usermod -a -G video,input,audio [your username]
Once this is done logout and the user will be added to the group on the next login.