All Topics  
Simple DirectMedia Layer

 

   Email Print
   Bookmark   Link






 

Simple DirectMedia Layer



 
 
Simple DirectMedia Layer (SDL) is a cross-platform, free and open source software
Free and open source software

Free and open source software, also F/OSS, FOSS, or FLOSS is software which is liberally software licence to grant the right of users to study, change, and improve its design through the availability of its source code....
 multimedia library written in C
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
 that presents a simple interface to various platforms' graphics
Computer graphics

Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer....
, sound, and input devices, allowing a developer to write a computer game
Personal computer game

A personal computer game is a game played on a personal computer, rather than on a video game console or arcade machine. Computer games have evolved from the simple graphics and gameplay of early titles like Spacewar!, to a wide range of more visually advanced titles....
 or other multimedia
Multimedia

Multimedia is media and content that utilizes a combination of different content format. The term can be used as a noun or as an adjective describing a medium as having multiple content forms....
 application that can run on many operating systems including Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
, Syllable, Haiku
Haiku (operating system)

Haiku, formerly known as OpenBeOS , is a free software and open source software project dedicated to the re-creation and continuation of BeOS on X86 architecture and PowerPC based computers....
/BeOS
BeOS

BeOS was an operating system for personal computers which began development by Be Inc. in 1991. It was first written to run on BeBox hardware. BeOS was optimized for digital media work and was written to take advantage of modern hardware facilities such as symmetric multiprocessing by utilizing modular I/O bandwidth, pervasive multithreading,...
, OpenVMS
OpenVMS

OpenVMS , previously known as VAX-11/VMS, VAX/VMS or VMS, is the name of a high-end computer server operating system that runs on the VAX and DEC Alpha families of computers, developed by Digital Equipment Corporation of Maynard, Massachusetts, Massachusetts , and most recently on Hewlett-Packard systems built around the In...
, Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
, Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
, AmigaOS
AmigaOS

AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000....
 and its clone MorphOS
MorphOS

MorphOS is a computer operating system . It is a mixed proprietary software and open source OS produced for the Pegasos PowerPC -processor-based computer, most models of PPC-accelerator-equipped Amiga computers, and a series of Freescale development boards that use the Genesi Firmware, including the EFIKA and mobileGT....
. It manages video, events, digital audio, CD-ROM, sound, threads, shared object loading, networking and timers.

lass="link1" onMouseover='showByLink("m1779308",this)' onMouseout='hide("m1779308")'href="http://www.absoluteastronomy.com/topics/Sam_Lantinga">Sam Lantinga
Sam Lantinga

Sam Oscar Lantinga is the creator of the Simple DirectMedia Layer, a very popular open source multimedia programming library. He is also a video-game programmer - he was one of the programmers for Loki Software which closed their doors several years ago....
 created the library, first releasing it in early 1998, while working for Loki Software
Loki Software

Loki Software, Inc. was a software firm based in Tustin, California, United States, that porting several computer and video game from Microsoft Windows to Linux....
.






Discussion
Ask a question about 'Simple DirectMedia Layer'
Start a new discussion about 'Simple DirectMedia Layer'
Answer questions from other users
Full Discussion Forum



Encyclopedia


Simple DirectMedia Layer (SDL) is a cross-platform, free and open source software
Free and open source software

Free and open source software, also F/OSS, FOSS, or FLOSS is software which is liberally software licence to grant the right of users to study, change, and improve its design through the availability of its source code....
 multimedia library written in C
C (programming language)

C is a general-purpose computer programming language originally developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories to implement the Unix operating system....
 that presents a simple interface to various platforms' graphics
Computer graphics

Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer....
, sound, and input devices, allowing a developer to write a computer game
Personal computer game

A personal computer game is a game played on a personal computer, rather than on a video game console or arcade machine. Computer games have evolved from the simple graphics and gameplay of early titles like Spacewar!, to a wide range of more visually advanced titles....
 or other multimedia
Multimedia

Multimedia is media and content that utilizes a combination of different content format. The term can be used as a noun or as an adjective describing a medium as having multiple content forms....
 application that can run on many operating systems including Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
, Syllable, Haiku
Haiku (operating system)

Haiku, formerly known as OpenBeOS , is a free software and open source software project dedicated to the re-creation and continuation of BeOS on X86 architecture and PowerPC based computers....
/BeOS
BeOS

BeOS was an operating system for personal computers which began development by Be Inc. in 1991. It was first written to run on BeBox hardware. BeOS was optimized for digital media work and was written to take advantage of modern hardware facilities such as symmetric multiprocessing by utilizing modular I/O bandwidth, pervasive multithreading,...
, OpenVMS
OpenVMS

OpenVMS , previously known as VAX-11/VMS, VAX/VMS or VMS, is the name of a high-end computer server operating system that runs on the VAX and DEC Alpha families of computers, developed by Digital Equipment Corporation of Maynard, Massachusetts, Massachusetts , and most recently on Hewlett-Packard systems built around the In...
, Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
, Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
, AmigaOS
AmigaOS

AmigaOS is the default native operating system of the Amiga personal computer. It was developed first by Commodore International, and initially introduced in 1985 with the Amiga 1000....
 and its clone MorphOS
MorphOS

MorphOS is a computer operating system . It is a mixed proprietary software and open source OS produced for the Pegasos PowerPC -processor-based computer, most models of PPC-accelerator-equipped Amiga computers, and a series of Freescale development boards that use the Genesi Firmware, including the EFIKA and mobileGT....
. It manages video, events, digital audio, CD-ROM, sound, threads, shared object loading, networking and timers.

History

Sam Lantinga
Sam Lantinga

Sam Oscar Lantinga is the creator of the Simple DirectMedia Layer, a very popular open source multimedia programming library. He is also a video-game programmer - he was one of the programmers for Loki Software which closed their doors several years ago....
 created the library, first releasing it in early 1998, while working for Loki Software
Loki Software

Loki Software, Inc. was a software firm based in Tustin, California, United States, that porting several computer and video game from Microsoft Windows to Linux....
. He got the idea while porting a Windows application to Macintosh. He then used SDL to port Doom to BeOS
BeOS

BeOS was an operating system for personal computers which began development by Be Inc. in 1991. It was first written to run on BeBox hardware. BeOS was optimized for digital media work and was written to take advantage of modern hardware facilities such as symmetric multiprocessing by utilizing modular I/O bandwidth, pervasive multithreading,...
 (see Doom source port
Doom source port

A Doom source port is a source port of the Doom engine, the game engine used by the computer game Doom . The term usually denotes a modification made by Doom community, as opposed to any of the Versions and ports of Doom produced by id Software or affiliated companies....
s). Several other free libraries were developed to work alongside SDL, such as SMPEG
SMPEG

SMPEG is short for the Simple DirectMedia Layer MPEG library originally developed by Loki Software. Since both it and SDL are free software under the GNU Lesser General Public License, it uses the MPEG-1 standard as a video display library, rather than MPEG-2, since only the MPEG-1 standard is unencumbered with software patents in the United...
 and OpenAL
OpenAL

OpenAL is a free software cross-platform audio Application programming interface. It is designed for efficient rendering of multichannel three dimensional positional audio....
.

The SDL library has bindings
Binding (computer science)

In computer science, binding is the creation of a simple reference to something that is larger and more complicated and used frequently. The simple reference can be used instead of having to repeat the larger thing....
 for almost every programming language, from the popular (C++
C++

C++ is a general-purpose programming language. It is regarded as a middle-level language, as it comprises a combination of both high-level programming language and low-level programming language language features....
, Perl
Perl

In computer programming, Perl is a high-level programming language, List of programming languages by category, Interpreter , dynamic programming language....
, Python
Python (programming language)

Python is a general-purpose high-level programming language. Its design philosophy emphasizes code readability. Python's core syntax and semantics are Minimalism , while the standard library is large and comprehensive....
 (through pygame
Pygame

Pygame is a cross-platform set of Python modules designed for writing video games.It includes computer graphics and sound library designed to be used with the Python programming language....
), Pascal
Pascal (programming language)

Pascal is an influential imperative programming and Procedural programming programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small and efficient language intended to encourage good programming practices using structured programming and data structure....
 etc.) to the less known (such as Euphoria or Pliant
Pliant

HistoryIn computer software programming languages history, Pliant is the first attempt to connect C and Lisp programming language branches....
). This, and the fact that it is open-source and licensed under the LGPL, make SDL a common choice for many multimedia applications.

SDL itself is very simple; it merely acts as a thin, cross-platform wrapper, providing support for 2D pixel operations, sound, file access, event handling, timing, threading, and more. It is often used to complement OpenGL
OpenGL

OpenGL is a standard specification defining a cross-language cross-platform Application programming interface for writing applications that produce 2D computer graphics and 3D computer graphics....
 by setting up the graphical output and providing mouse and keyboard input, which are beyond the scope of OpenGL.

The library is divided into several subsystems, namely the Video (handles both surface functions and OpenGL
OpenGL

OpenGL is a standard specification defining a cross-language cross-platform Application programming interface for writing applications that produce 2D computer graphics and 3D computer graphics....
), Audio, CD-ROM, Joystick and Timer subsystems. Besides this basic, low-level support, there also are a few separate official libraries that provide some additional functionality. These comprise the "standard library", and are provided on the official website and included in the official documentation:

  • SDL_image - support for multiple image formats
  • SDL_mixer - complex audio functions, mainly for sound mixing
  • SDL_net - networking support
  • SDL_ttf - TrueType
    TrueType

    TrueType is an outline font standardization originally developed by Apple Computer in the late 1980s as a competitor to Adobe Systems's Type 1 fonts used in PostScript....
     font rendering support
  • SDL_rtf - simple Rich Text Format
    Rich Text Format

    The Rich Text Format is a document file format file format developed by Microsoft in 1987 for cross-platform document interchange. Most word processors are able to read and write RTF documents....
     rendering


Architecture

SDL has the word "layer" in its title because it is actually a wrapper around operating-system-specific functionality. The chief purpose of SDL is to provide a common framework for accessing this functionality.

Because of the way SDL is designed, a lot of the source code is split into separate modules for each operating system, in order to make calls to the underlying system. When SDL is compiled, the correct modules are selected for the target system.

On Microsoft Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
, SDL uses a windib backend by default. A DirectX backend is also available. Older versions of SDL used DirectX 5, but SDL 1.2 (the current stable release) requires DirectX 7 by default. Sam Lantinga has stated that he plans to use DirectX 8 in future SDL releases.

On X11
X Window System

The X Window System is a computing software system and network protocol that provides a graphical user interface for networked computers. It implements the X Window System protocols and architecture and provides windowing system on raster graphics Visual display units and manages Keyboard and pointing device control functions....
 platforms, including Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
 and OpenVMS
OpenVMS

OpenVMS , previously known as VAX-11/VMS, VAX/VMS or VMS, is the name of a high-end computer server operating system that runs on the VAX and DEC Alpha families of computers, developed by Digital Equipment Corporation of Maynard, Massachusetts, Massachusetts , and most recently on Hewlett-Packard systems built around the In...
, SDL uses Xlib
Xlib

Xlib is an X Window System protocol client library in the C . It contains subroutines for interacting with an X Server . These functions allow programmers to write programs without knowing the details of the protocol ....
 to communicate with the X11 system for graphics and events.

On Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
, SDL uses Quartz
Quartz (graphics layer)

Quartz specifically refers to a pair of Mac OS X technologies, each part of the Core Graphics framework: Quartz 2D and Quartz Compositor. It includes both a 2D renderer in Core Graphics and the composition engine that sends instructions to the graphics card....
.

Syntax and subsystems

The syntax of SDL is function-based, all operations done in SDL are done by passing parameters to functions. Special structures are also used to store the specific information SDL needs to handle. There are a few different subsystems SDL categorizes its functions under:

  • The Video, events and threads subsystem - this provides functionality for video, multi-threading
    Thread (computer science)

    In computer science, a thread of execution is a Fork of a computer program into two or more Concurrency running task s. The implementation of threads and process es differs from one operating system to another, but in most cases, a thread is contained inside a process....
    , and event handling
    Event handler

    In computer programming, an event handler is an asynchronous callback subroutine that handles inputs received in a program. Each event is a piece of application-level information from the underlying framework, typically the GUI toolkit....
    .
  • The Audio subsystem - this provides audio functionality.
  • The Time subsystem
  • The Joystick subsystem
  • The CD-ROM subsystem


Gallery


Extensions

  • , , , , , - Widget sets
  • - OpenGL backend for SDL (hardware accelerated blits, scaling, and rotation)
  • - libSDL library set for OpenVMS
    OpenVMS

    OpenVMS , previously known as VAX-11/VMS, VAX/VMS or VMS, is the name of a high-end computer server operating system that runs on the VAX and DEC Alpha families of computers, developed by Digital Equipment Corporation of Maynard, Massachusetts, Massachusetts , and most recently on Hewlett-Packard systems built around the In...
     port by Alexey Chupahin.
  • , - Video playback
  • , , , - Graphics primitives rendering and other effects
  • - Vector graphics
  • - Audio engine
  • - Enhanced event processing
  • - SDL_Event-based networking
  • , BFont, DFont, - Bitmap font rendering
  • - TTF rendering


See also

  • List of games using SDL
    List of games using SDL

    This is a list of notable games, gaming engines, and arcade or game-console emulators that make use of Simple DirectMedia Layer , a cross-platform software library abstracts platforms' graphics, sound, and input APIs, allowing a developer to write a computer game or other multimedia application once and run it on many operating systems....
  • Allegro library
    Allegro library

    Allegro is a free software and open source software software library for video game development.The functionality of the library includes support for basic 2D graphics, image manipulation, text output, audio output, midi music, input and timers, as well as additional routines for fixed-point and floating-point matrix arithmetic, unicode...
  • DirectX
    DirectX

    Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms....
  • OpenGL
    OpenGL

    OpenGL is a standard specification defining a cross-language cross-platform Application programming interface for writing applications that produce 2D computer graphics and 3D computer graphics....
  • OpenML
    OpenML

    Open Media Library is a free, cross-platform programming environment designed by the Khronos Group for capturing, transporting, processing, displaying, and synchronizing digital media ....
  • pygame
    Pygame

    Pygame is a cross-platform set of Python modules designed for writing video games.It includes computer graphics and sound library designed to be used with the Python programming language....
  • SFML
    Simple and Fast Multimedia Library

    Simple and Fast Multimedia Library is an object-oriented, cross-platform, free and open source software multimedia API written in C++....
  • Troll2D
    Troll2D

    Troll is a free software and open source software software library for video game development, with functions for basic 2D computer graphics, image manipulation, text output, audio output, midi music, input and timers....
  • GGI
    General Graphics Interface

    General Graphics Interface is a project that aims to develop a reliable, stable and fast computer graphics system that works everywhere. The intent is to allow for any program using GGI to run on any computing platform supported by it, requiring at most a recompile....
     - a free cross-platform graphics interface
  • Cross-Platform Support Middleware
    Cross-Platform Support Middleware

    A Cross-Platform Support Middleware is a software abstraction layer that guarantees the existence, and correct implementation, of a set of services on top a set of Platform ....


External links

  • - Parallel Realities SDL Game programming tutorials series
  • - a game development site that also has articles and tutorials on SDL.