world leader in high performance signal processing
Trace: » sdl

Simple DirectMedia Layer

About

Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to aedudio, 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#, Eiffel, Erlang, Euphoria, Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, Pike, Pliant, Python, Ruby, and Smalltalk.

Why

  • SDL is simple -although it provides only the most basic 2D graphics capabilities it is more than needed to get going. Because it is doesn't have everything and the kitchen sink, one does not need to learn a hugely complicated system before one can get going. In just a few lines of code, you can have a program running with SDL.
  • SDL programming is like C programming not Win32 programming - one uses a standard C program layout and SDL manages all the negotiation with the operating system for you.
  • SDL is 32 bit - thus it is future proof to a degree.
  • SDL is FAST - real computer games and ports of games (some very well known) were written using SDL. If it is fast enough to implement real world games, it will be fast enough for most. It takes advantage of accelerated graphics hardware where possible. This is something very few graphics libraries are capable of.
  • SDL is portable - it can be used just as easily on a Linux system as a Windows, BeOS, Mac OS, Mac OS X, FreeBSD, OpenBSD, BSD/OS, Solaris and IRIX. Once you have written your program using SDL in Linux, you can change it to work in Windows or various other operating systems with a minimum of fuss. It will also work with most graphics cards transparently without you having to change your code.
  • SDL is extensible - OpenGL just plugs right into SDL, so if you decide you want to add some 3D graphics, you can just go right ahead, in the simplest possible way.
  • SDL is more than just a graphics system - it provides a complete multimedia solution. You can capture keyboard and joystick input, have access to the sound subsystem, etc, etc. In that sense it is similar to DirectX, but it is much simpler to use.

MainLine Project

Requirements

In order to run/play these examples/games, you must have a platforms with a display, known as a framebuffer exposed as /dev/fb. Standard Linux keyboard and mouse. (devices exposed as /dev/input/mouse and /dev/input/eventn. This can be done with USB keyboards/mice or on board keypads. This can not be done easily with serial console (for keyboards). These examples have all been tested on both the BF548 and BF527 development systems, which support USB and display.

Examples

SDL has many demos, games, and applications applications which you can look at and examine the source code. A select few of these examples are included in the uClinux-dist. You can build these by selecting:

   Blackfin app programs  --->
      [ ] SDL Examples

The examples can be run from any console, and will display on the display (Duh!). If you have no mouse configured (all you need is a driver compiled into the kernel, which exposes /dev/input/mice), you will get an error:

root:/usr/bin> ./plasma
Couldn't initialize SDL: Unable to open mouse

you must tell SDL that that is expected:

root:/usr/bin> export SDL_NOMOUSE=1

Here is a short video of some of the SDL Examples:

The Adobe Flash Plugin is needed to display this content.

aliens

root:/usr/bin> ./aliens

Aliens (Project Page) is an example of using SDL with the SDL_image and SDL_mixer libraries.

file: user/blkfin-apps/sdl-examples/aliens-1.0.2/README

scm failed with exit code 1:
file does not exist in git

The keys only work from the virtual console:

  • USB Keyboard
  • Numeric keypad

ballfield

root:/usr/bin> ./ballfield

file: user/blkfin-apps/sdl-examples/ballfield-1.0/README

scm failed with exit code 1:
file does not exist in git

Dodgin' Diamond II

root:/usr/bin> ./dd2

Player 1: UP, DOWN, LEFT, RIGHT, RIGHT CONTROL
Player 2: w, s, a, d, LEFT CONTROL

fire

root:/usr/bin> ./fire
Fire demo by David Ashley (dash@xdr.com)
1 = Change color map
2 = Randomly change color map
p = Pause
spc = Fire
esc = Exit
Left mouse button = paint
Right mouse button, CR = ignite atmosphere

file: user/blkfin-apps/sdl-examples/fire-1.0/README

scm failed with exit code 1:
file does not exist in git

newvox

root:/usr/bin> ./newvox

file: user/blkfin-apps/sdl-examples/newvox-1.0/README

scm failed with exit code 1:
file does not exist in git

plasma

root:/usr/bin> ./plasma

file: user/blkfin-apps/sdl-examples/plasma-1.0/README

scm failed with exit code 1:
file does not exist in git

sdldoom

This is a port of ID Software's popular DOOM! 3-D shooter game. This port is not supported by ID Software.

root:/usr/bin> ./doom

This patch scales doom by 2. It might be used together with the NTSC/PAL adv7393 framebuffer driver.

Index: user/blkfin-apps/sdl-examples/sdldoom-1.10/i_video.c
===================================================================
--- user/blkfin-apps/sdl-examples/sdldoom-1.10/i_video.c        (revision 5988)
+++ user/blkfin-apps/sdl-examples/sdldoom-1.10/i_video.c        (working copy)
@@ -47,7 +47,7 @@
 // replace each 320x200 pixel with multiply*multiply pixels.
 // According to Dave Taylor, it still is a bonehead thing
 // to use ....
-static int     multiply=1;
+static int     multiply=2;
 
 
 //

sdlroids

root:/usr/bin> ./sdlroids

file: user/blkfin-apps/sdl-examples/sdlroids-1.3.4/README

scm failed with exit code 1:
file does not exist in git

sierp

root:/usr/bin> ./sierp

file: user/blkfin-apps/sdl-examples/sierp-1.0/README

scm failed with exit code 1:
file does not exist in git

warp

root:/usr/bin> warp bmp/leeloo.bmp

file: user/blkfin-apps/sdl-examples/warp-1.1/README

scm failed with exit code 1:
file does not exist in git

water

root:/usr/bin> ./water
Controls are:      (you may use any background: "water file.bmp")
        ?       Help...
        `       Pause
Automatic effects:
        1       Toggle Surfer mode
        2       Toggle Rain mode
        3       Toggle Blob mode...
        4       Toggirly" mode...
        b/B     Turn on "bump" mode...
        <space> Turn off effects 1-4 and b
Manual effects:
        Mouse   Make blobs (button 1 and button 2 are different)
        6       Make a large waterdrop
        7       Make a large waterdrop in the center
        z       Distort / exaggerate the water
Physics:
        d/D     Decrease / Increase water density
        h/H     Decrease / Increase splash height
        r/R     Decrease / Increase waterdrop radius
        m       Toggle the water "movement"
        l/L     Change the light level (Off, 100%, 50%, 25%, ...)
        w/j/s/S Set physics for water/jelly/sludge/SuperSludge material...

picture viewer

NAME

vp − view image files

SYNOPSIS

root:/usr/bin> ./vp /media/images/beach_and_sea_* 

DESCRIPTION

vp View Picture files using SDL. Supported file types include jpeg, gif, png, bmp, ppm, xpm, pcx, tga, and anything else your install of sdl_image supports. Keyboard controls are escape or q to quit, f to toggle fullscreen, z to toggle zoom (only in fullscreen), left arrow to go to the previous image, right arrow to go to the next image, and space to toggle slideshow. Toggling the zoom and fullscreen or using the arrow keys disables slideshow mode. File names starting with http: or ftp: are interpreted as URL’s and downloaded.

OPTIONS

     −f, −‐fullscreen
             Start in fullscreen mode

     −h, −‐help
             Show the help screen

     −l, −‐loud
             Loud behavior. Print out file names as it displays

     −s, −‐sleep
             Sleep time between images, in seconds

     −r, −‐resolution
             Screen resolution (for fullscreen). <width>x<height>@<bpp>

     −v, −‐version
             Print the version and exit

     −z, −‐zoom
             Scale the images to fill the screen (zoom)

xflame

root:/usr/bin> ./xflame -height 272 -width 480

file: user/blkfin-apps/sdl-examples/xflame-1.0/README

scm failed with exit code 1:
file does not exist in git