Simple DirectMedia Layer (SDL) is a
cross-platform
In computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several computing platforms. Some cross-platform software ...
software development
Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components. Software development inv ...
library
A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vi ...
designed to provide a
hardware abstraction layer for computer
multimedia
Multimedia is a form of communication that uses a combination of different content forms such as text, audio, images, animations, or video into a single interactive presentation, in contrast to tradi ...
hardware components. Software developers can use it to write high-performance
computer games
A personal computer game, also known as a PC game or computer game, is a type of video game played on a personal computer (PC) rather than a video game console or arcade machine. Its defining characteristics include: more diverse and user-d ...
and other multimedia applications that can run on many
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
s such as
Android
Android may refer to:
Science and technology
* Android (robot), a humanoid robot or synthetic organism designed to imitate a human
* Android (operating system), Google's mobile operating system
** Bugdroid, a Google mascot sometimes referred to ...
,
iOS,
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which i ...
,
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
, and
Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
.
SDL manages
video
Video is an Electronics, electronic medium for the recording, copying, playback, broadcasting, and display of moving picture, moving image, visual Media (communication), media. Video was first developed for mechanical television systems, whi ...
,
audio,
input device
In computing, an input device is a piece of equipment used to provide data and control signals to an information processing system, such as a computer or information appliance. Examples of input devices include keyboards, mouse, scanners, cameras ...
s,
CD-ROM,
threads
Thread may refer to:
Objects
* Thread (yarn), a kind of thin yarn used for sewing
** Thread (unit of measurement), a cotton yarn measure
* Screw thread, a helical ridge on a cylindrical fastener
Arts and entertainment
* ''Thread'' (film), 2016 ...
,
shared object loading,
networking
Network, networking and networked may refer to:
Science and technology
* Network theory, the study of graphs as a representation of relations between discrete objects
* Network science, an academic field that studies complex networks
Mathematics
...
and timers. For 3D graphics, it can handle an
OpenGL
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
,
Vulkan,
Metal
A metal (from Greek μέταλλον ''métallon'', "mine, quarry, metal") is a material that, when freshly prepared, polished, or fractured, shows a lustrous appearance, and conducts electricity and heat relatively well. Metals are typi ...
, or
Direct3D11 (older Direct3D version 9 is also supported) context. A common misconception is that SDL is a
game engine
A game engine is a software framework primarily designed for the development of video games and generally includes relevant libraries and support programs. The "engine" terminology is similar to the term " software engine" used in the softwar ...
. However, the library is suited to building games directly, or is usable indirectly by engines built on top of it.
The library is internally written in
C and possibly, depending on the target platform,
C++ or
Objective-C
Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by NeXT for its N ...
, and provides the
application programming interface in C, with bindings to other languages available.
It is
free and open-source software subject to the requirements of the
zlib License since version 2.0, and with prior versions subject to the
GNU Lesser General Public License
The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
.
Under the zlib License, SDL 2.0 is freely available for
static linking in
closed-source projects, unlike SDL 1.2. SDL 2.0, released in 2013, was a major departure from previous versions, offering more opportunity for 3D hardware acceleration, but breaking backwards-compatibility.
SDL is extensively used in the industry in both large and small projects. Over 700 games, 180 applications, and 120 demos have been posted on the library website.
History
Sam Lantinga created the library, first releasing it in early 1998, while working for
Loki Software
Loki Software, Inc. (Loki Entertainment) was an American video game developer based in Tustin, California, that porting, ported several video games from Microsoft Windows to Linux. It took its name from the Norse deity Loki. Although successful ...
. He got the idea while porting a Windows application to Macintosh. He then used SDL to port ''
Doom'' to
BeOS
BeOS is an operating system for personal computers first developed by Be Inc. in 1990. It was first written to run on BeBox hardware.
BeOS was positioned as a multimedia platform that could be used by a substantial population of desktop users a ...
(see
Doom source ports). Several other free libraries were developed to work alongside SDL, such as
SMPEG
The SDL MPEG library was developed by Loki Software. It follows the MPEG-1 standard rather than MPEG-2 because MPEG-2 is restricted by software patents in the United States of America. It uses the LGPL
The GNU Lesser General Public License ( ...
and
OpenAL. He also founded Galaxy Gameworks in 2008 to help commercially support SDL, although the company plans are currently on hold due to time constraints.
Soon after putting Galaxy Gameworks on hold, Lantinga announced that SDL 1.3 (which would then later become SDL 2.0) would be licensed under the
zlib License.
[SDL 1.3 to be zLib Licensed]
SDL Mailing List, 7 April 2011 Lantinga announced SDL 2.0 on 14 July 2012, at the same time announcing that he was joining
Valve
A valve is a device or natural object that regulates, directs or controls the flow of a fluid (gases, liquids, fluidized solids, or slurries) by opening, closing, or partially obstructing various passageways. Valves are technically fitting ...
, the first version of which was announced the same day he joined the company. Lantinga announced the stable release of SDL 2.0.0 on 13 August 2013.
[Announcing SDL 2.0.0]
SDL Mailing List, 13 August 2013
SDL 2.0 is a major update to the SDL 1.2
codebase with a different, not
backwards-compatible API. It replaces several parts of the 1.2 API with more general support for multiple input and output options. Some feature additions include multiple window support, hardware-accelerated 2D graphics, and better
Unicode
Unicode, formally The Unicode Standard,The formal version reference is is an information technology standard for the consistent encoding, representation, and handling of text expressed in most of the world's writing systems. The standard, ...
support.
Support for
Mir and
Wayland was added in SDL 2.0.2 and enabled by default in SDL 2.0.4. Version 2.0.4 also provided better support for Android.
Software architecture
SDL is a
wrapper around the operating-system-specific functions that the game needs to access. The only purpose of SDL is to provide a common framework for accessing these functions for multiple operating systems (cross-platform). SDL provides support for 2D pixel operations, sound, file access, event handling, timing and threading. It is often used to complement
OpenGL
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
by setting up the graphical output and providing mouse and keyboard input, since OpenGL comprises only rendering.
A game using the Simple DirectMedia Layer will ''not'' automatically run on every operating system; further adaptations must be applied. These are reduced to the minimum, since SDL also contains a few abstraction APIs for frequent functions offered by an operating system.
The syntax of SDL is function-based: all operations done in SDL are done by passing parameters to
subroutine
In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.
Functions ma ...
s (functions). Special structures are also used to store the specific information SDL needs to handle. SDL functions are categorized under several different subsystems.
Subsystems
SDL is divided into several subsystems:
; Basics: Initialization and Shutdown, Configuration Variables, Error Handling, Log Handling
; Video: Display and Window Management, surface functions, rendering acceleration, etc.
; Input Events:
Event handling, Support for Keyboard, Mouse, Joystick and Game controller
; Force Feedback: SDL_haptic.h implements support for "Force Feedback"
; Audio: SDL_audio.h implements Audio Device Management, Playing and Recording
; Threads:
multi-threading: Thread Management, Thread Synchronization Primitives, Atomic Operations
; Timers: Timer Support
; File Abstraction: Filesystem Paths, File I/O Abstraction
; Shared Object Support: Shared Object Loading and Function Lookup
; Platform and CPU Information: Platform Detection, CPU Feature Detection, Byte Order and Byte Swapping, Bit Manipulation
; Power Management: Power Management Status
; Additional: Platform-specific functionality
Besides this basic, low-level support, there also are a few separate official libraries that provide some more functions. 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 font rendering support
* ''SDL_rtf'' — simple
Rich Text Format rendering
Other, non-standard libraries also exist. For example: SDL_Collide on SourceForge created by
Amir Taaki
Amir Taaki ( fa, امیر تاکی; born 6 February 1988) is a British-Iranian anarchist revolutionary, hacktivist, and programmer who is known for his leading role in the bitcoin project, and for pioneering many open source projects. Forbe ...
.
Language bindings
The SDL 2.0 library has
language bindings for:
*
Ada
* Beef
*
C
*
C++
*
C#
*
D
*
Fortran
*
Genie
Jinn ( ar, , ') – also romanized as djinn or anglicized as genies (with the broader meaning of spirit or demon, depending on sources)
– are invisible creatures in early pre-Islamic Arabian religious systems and later in Islamic m ...
*
Go
*
Haskell
*
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
(e.g. JSDL)
*
Julia
*
Lua
Lua or LUA may refer to:
Science and technology
* Lua (programming language)
* Latvia University of Agriculture
* Last universal ancestor, in evolution
Ethnicity and language
* Lua people, of Laos
* Lawa people, of Thailand sometimes referred t ...
*
Nim
Nim is a mathematical two player game.
Nim or NIM may also refer to:
* Nim (programming language)
* Nim Chimpsky, a signing chimpanzee Acronyms
* Network Installation Manager, an IBM framework
* Nuclear Instrumentation Module
* Negative index met ...
*
OCaml
OCaml ( , formerly Objective Caml) is a general-purpose, multi-paradigm programming language which extends the Caml dialect of ML with object-oriented features. OCaml was created in 1996 by Xavier Leroy, Jérôme Vouillon, Damien Doligez, D ...
*
Pascal
*
Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
(via SDL)
*
PHP
PHP is a General-purpose programming language, general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementati ...
*
Python (several, e.g. pygame_sdl2 and sdl2hl)
*
Raku
*
Ring
*
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), ...
*
Vala
*
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in ANSI standard document ''ANSI INCITS 226-1994 (S20018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived fr ...
Supported back-ends

Because of the way SDL is designed, much of its source code is split into separate modules for each operating system, to make calls to the underlying system. When SDL is compiled, the appropriate modules are selected for the target system. The following back-ends are available:
*
GDI back-end for
Microsoft Windows.
*
DirectX
Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direc ...
back-end; older SDL 1.2 uses DirectX 7 by default, while 2.0 defaults to DirectX 9 and can access up to DirectX 11.
*
Quartz
Quartz is a hard, crystalline mineral composed of silica ( silicon dioxide). The atoms are linked in a continuous framework of SiO4 silicon-oxygen tetrahedra, with each oxygen being shared between two tetrahedra, giving an overall chemical ...
back-end for
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
(dropped in 2.0).
*
Metal
A metal (from Greek μέταλλον ''métallon'', "mine, quarry, metal") is a material that, when freshly prepared, polished, or fractured, shows a lustrous appearance, and conducts electricity and heat relatively well. Metals are typi ...
back-end for
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
/
iOS /
tvOS since 2.0.8; older versions use OpenGL by default.
*
Xlib back-end for
X11-based
windowing system on various operating systems.
*
OpenGL
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
contexts on various platforms.
*
EGL back-end when used in conjunction with Wayland-based windowing system.,
Raspberry Pi
Raspberry Pi () is a series of small single-board computers (SBCs) developed in the United Kingdom by the Raspberry Pi Foundation in association with Broadcom. The Raspberry Pi project originally leaned towards the promotion of teaching basic ...
and other systems.
*
Vulkan contexts on platforms that support it.
* sceGu back-end, a Sony OpenGL-like backend native to the
PSP.
SDL 1.2 has support for
RISC OS
RISC OS is a computer operating system originally designed by Acorn Computers Ltd in Cambridge, England. First released in 1987, it was designed to run on the ARM chipset, which Acorn had designed concurrently for use in its new line of Archi ...
(dropped in 2.0).
An unofficial
Sixel back-end is available for SDL 1.2.
The
Rockbox MP3 player firmware also distributes a version of SDL 1.2, which is used to run games such as
Quake.
Reception and adoption

Over the years SDL was used for many commercial and non-commercial video game projects. For instance,
MobyGames listed 120 games using SDL in 2013,
and the SDL website itself listed around 700 games in 2012. Important commercial examples are ''
Angry Birds'',
''
Unreal Tournament'', and games developed using
Valve
A valve is a device or natural object that regulates, directs or controls the flow of a fluid (gases, liquids, fluidized solids, or slurries) by opening, closing, or partially obstructing various passageways. Valves are technically fitting ...
's
Source Engine, which uses SDL extensively for cross-platform compatibility; ones from the open-source domain are ''
OpenTTD'',
''
The Battle for Wesnoth''
or ''
Freeciv''.
The cross-platform game releases of the popular
Humble Indie Bundles for Linux, Mac and Android are often SDL-based.
SDL is also often used for later ports on new platforms with legacy code. For instance, the PC game
Homeworld was ported to the
Pandora handheld and
Jagged Alliance 2
''Jagged Alliance 2'' is a tactical role-playing game for PC, released in 1999 for Microsoft Windows and later ported to Linux by Tribsoft. It is the third entry in the ''Jagged Alliance'' series. The game was followed by the expansion '' Unfinis ...
for Android via SDL.
Also, several non video game programs use SDL; examples are the
emulators, such as
DOSBox,
FUSE ZX Spectrum emulator and
VisualBoyAdvance.
There were several books written for development with SDL (see further readings).
SDL is used in
university
A university () is an institution of higher (or tertiary) education and research which awards academic degrees in several academic disciplines. ''University'' is derived from the Latin phrase ''universitas magistrorum et scholarium'', which ...
courses teaching multimedia and
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, for instance, in a workshop about game programming using libSDL at the
University of Cadiz
A university () is an educational institution, institution of higher education, higher (or Tertiary education, tertiary) education and research which awards academic degrees in several Discipline (academia), academic disciplines. ''University'' ...
in 2010, or a Game Design discipline at
UTFPR (Ponta Grossa campus) in 2015.
Video game examples using SDL
File:Unknown horizons 3176.PNG, '' Unknown Horizons''
File:Hwscreen.png, ''Hedgewars''
File:Scorched 3D 39.1 screenshot 3.jpg, '' Scorched 3D''
File:Fretsonfirex1.jpg, '' Frets on Fire''
File:OOlite Mac OS X screenshot.jpg, ''Oolite
Oolite or oölite (''egg stone'') is a sedimentary rock formed from ooids, spherical grains composed of concentric layers. The name derives from the Ancient Greek word for egg (ᾠόν). Strictly, oolites consist of ooids of diameter 0.25� ...
''
File:Wesnoth-1.6-5.jpg, '' The Battle for Wesnoth''
File:OpenTTD-1.3.3-en.png, '' OpenTTD''
File:0 A.D. alpha 25 - playing as Spartans.jpg, '' 0 A.D.''
File:SMC15PromoShot.png, '' Secret Maryo Chronicles''
File:Trine - Wizard Knight Caverns.jpg, '' Trine''
File:Trine 2 - Deadly Dustland Three Heroes.jpg, '' Trine 2''
See also
References
Further reading
* Alberto García Serrano: ''Programación de videojuegos en SDL'', Ediversitas, (Spanish)
* Ernest Pazera: ''Focus On SDL'', Muska & Lipman/Premier-Trade,
* Ron Penton: ''Data Structures for Game Programmers'', Muska & Lipman/Premier-Trade, (''game programming examples with SDL'')
* John R. Hall: ''Programming Linux Games'', No Starch, (''First SDL book, by
Loki Games'', archived online version: , )
External links
* {{official website
Application programming interfaces
Audio libraries
C (programming language) libraries
Cross-platform software
Graphics libraries
Linux APIs
MacOS APIs
Software using the zlib license
Video game development
Video game development software for Linux
Windows APIs