Linux Game Programming for PC & Embedded Systems using SDL
Presented by
Fore June
Author of Windows Fan, Linux Fan

Games and SDL
SDL Installation
SDL for Embedded
SDL API
SDL Events
 SDL Graphics
SDL Threads
Thread Example
SDL Animation
SDL Sound
 Raw Video Player
Video Formats
Video Compression
 Game Trees
About The Author
@Copyright by Fore June, 2006

Games and SDL

  1. Introduction

    Simple DirectMedia Layer ( SDL ) 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. It supports Linux, MS Windows and many other platforms. It is ideal to be used in embedded Linux as it is small and does not require X-window to do graphics. Embedded systems frequently have highly constrained resources and can afford neither the program storage space nor the memory footprint of desktop graphics software like X Window, KDE and GNOME. Because of these, SDL has been particularly popular in embedded Linux. It has been applied to a number of Embedded Linux implementations such as Microwindows, Paragui, and Superwaba.

    SDL was designed and written by a group of experienced, highly professional, game programmers and is supported by a huge collection of good programmers. In summary, it is lean, portable, reliable, API well-defined, simple to learn and use. It is reported in an article ( http://gameprogrammer.com/sdl.html ) that the author spent several months writing test programs both as a way to learn SDL and to try to find bugs in SDL. In all that time he only found a couple of minor documentation bugs and what he would call a miss-feature for which there was an easy work around. He tried ridiculous things with SDL, such as writing a program that used 10,000 timers, and wasn't able to break it. Every time he found what he thought was a bug it turned out to be either the result of minor errors in the documentation of his misunderstanding of the documentation. The one time he thought he had found a serious bug in SDL it turned out that it had already been fixed.

    It can be used in:

    • games
    • game SDKs
    • emulators
    • demos
    • multimedia applications

    Applications include:

    • video -- it can set a video at any depth ( 8-bpp or greater ) with optional conversion; write directly to a linear graphics framebuffer; create surfaces with colorkey or alpha blending attributes
    • events -- provides event change detection like keyboard input, mouse input; each event can be enabled or disabled with SDL_EventState()
    • audio -- set audio playback of 8-bit and 16-bit audio, mono or stereo; audio runs independently in a separate thread, filled via a user callback mechanism; provides complete CD audio control API
    • threads -- provides simple thread creation API and simple binary semaphores for synchronization
    • timers -- gets the number of milliseconds elapsed and waits a specified number of milliseconds
    The most important application of SDL, though, is game programming.

    The SDL library consists of several sub-APIs, providing cross-platform support for video, audio, input handling, multithreading, OpenGL rendering contexts and other amenities.