Simple Direct Media Layer
   HOME

TheInfoList



OR:

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 r ...
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 invol ...
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 vir ...
designed to provide a
hardware abstraction layer Hardware abstractions are sets of routines in software that provide programs with access to hardware resources through programming interfaces. The programming interface allows all devices in a particular class ''C'' of hardware devices to be acce ...
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 tradition ...
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-deter ...
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 services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
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 iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also includes ...
,
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 ...
,
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 computers. Within the market of desktop and lapt ...
, 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 serv ...
. SDL manages
video Video is an electronic medium for the recording, copying, playback, broadcasting, and display of moving visual media. Video was first developed for mechanical television systems, which were quickly replaced by cathode-ray tube (CRT) syste ...
,
audio Audio most commonly refers to sound, as it is transmitted in signal form. It may also refer to: Sound *Audio signal, an electrical representation of sound *Audio frequency, a frequency in the audio spectrum *Digital audio, representation of sound ...
,
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 A CD-ROM (, compact disc read-only memory) is a type of read-only memory consisting of a pre-pressed optical compact disc that contains data. Computers can read—but not write or erase—CD-ROMs. Some CDs, called enhanced CDs, hold both comput ...
, threads, 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 hardwa ...
, 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 typicall ...
, 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 software i ...
. 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, and provides the
application programming interface An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how t ...
in C, with bindings to other languages available. It is
free and open-source software Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source ...
subject to the requirements of the
zlib License The zlib license is a permissive free software license which defines the terms under which the zlib software library can be distributed. It is also used by many other free software packages. The libpng library uses a similar license sometimes re ...
since version 2.0, and with prior versions subject to the GNU Lesser General Public License. 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 ported several video games from Microsoft Windows to Linux. It took its name from the Norse deity Loki. Although successful in its ...
. He got the idea while porting a Windows application to Macintosh. He then used SDL to port ''
Doom Doom is another name for damnation. Doom may also refer to: People * Doom (professional wrestling), the tag team of Ron Simmons and Butch Reed * Daniel Doom (born 1934), Belgian cyclist * Debbie Doom (born 1963), American softball pitcher * L ...
'' 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 and
OpenAL OpenAL (Open Audio Library) is a cross-platform audio application programming interface (API). It is designed for efficient rendering of multichannel three-dimensional positional audio. Its API style and conventions deliberately resemble those ...
. 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 The zlib license is a permissive free software license which defines the terms under which the zlib software library can be distributed. It is also used by many other free software packages. The libpng library uses a similar license sometimes re ...
.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 fittings ...
, 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 An application programming interface (API) is a way for two or more computer programs to communicate with each other. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standa ...
. 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 Technical standard, standard for the consistent character encoding, encoding, representation, and handling of Character (computing), text expre ...
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 hardwa ...
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 may ...
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 In programming and software design, an event is an action or occurrence recognized by software, often originating asynchronously from the external environment, that may be handled by the software. Computer events can be generated or triggere ...
, 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 ) As an example, the following RTF code would be rendered as follows: This is some bold text. Character encoding A standard RTF file can only consist of 7-bit ASCII characters, but can use escape sequences to encode other characters. Th ...
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 Ada may refer to: Places Africa * Ada Foah, a town in Ghana * Ada (Ghana parliament constituency) * Ada, Osun, a town in Nigeria Asia * Ada, Urmia, a village in West Azerbaijan Province, Iran * Ada, Karaman, a village in Karaman Province, Tur ...
* Beef * C * C++ * C# * D * Fortran * Genie * 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 List ...
(e.g. JSDL) * Julia * Lua *
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 programming language, general-purpose, multi-paradigm programming language which extends the Caml dialect of ML (programming language), ML with object-oriented programming, object-oriented ...
*
Pascal Pascal, Pascal's or PASCAL may refer to: People and fictional characters * Pascal (given name), including a list of people with the name * Pascal (surname), including a list of people and fictional characters with the name ** Blaise Pascal, Fren ...
*
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
(via SDL) *
PHP PHP is a 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 implementation is now produced by The PHP Group ...
*
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
(several, e.g. pygame_sdl2 and sdl2hl) * Raku *
Ring Ring may refer to: * Ring (jewellery), a round band, usually made of metal, worn as ornamental jewelry * To make a sound with a bell, and the sound made by a bell :(hence) to initiate a telephone connection Arts, entertainment and media Film and ...
*
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 fro ...


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 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 serv ...
. *
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 "Direct", ...
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 form ...
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 computers. Within the market of desktop and lapt ...
(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 typicall ...
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 computers. Within the market of desktop and lapt ...
/
iOS iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also includes ...
/ tvOS since 2.0.8; older versions use OpenGL by default. * Xlib back-end for X11-based
windowing system In computing, a windowing system (or window system) is software that manages separately different parts of display screens. It is a type of graphical user interface (GUI) which implements the WIMP (windows, icons, menus, pointer) paradigm for ...
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 hardwa ...
contexts on various platforms. * EGL back-end when used in conjunction with Wayland-based windowing system., Raspberry Pi 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 (dropped in 2.0). An unofficial
Sixel Sixel, short for "six pixels", is a bitmap graphics format supported by terminals and printers from DEC. It consists of a pattern six pixels high and one wide, resulting in 64 possible patterns. Each possible pattern is assigned an ASCII chara ...
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 MobyGames is a commercial website that catalogs information on video games and the people and companies behind them via crowdsourcing. This includes nearly 300,000 games for hundreds of platforms. The site is supported by banner ads and a small ...
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 fittings ...
'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 Bundle Humble Bundle, Inc. is a digital storefront for video games, which grew out of its original offering of Humble Bundles, collections of games sold at a price determined by the purchaser and with a portion of the price going towards charity and t ...
s 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 In Greek mythology, Pandora (Greek: , derived from , ''pān'', i.e. "all" and , ''dōron'', i.e. "gift", thus "the all-endowed", "all-gifted" or "all-giving") was the first human woman created by Hephaestus on the instructions of Zeus. As Hes ...
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 '' Unfinish ...
for Android via SDL. Also, several non video game programs use SDL; examples are the emulators, such as
DOSBox DOSBox is a free and open-source emulator which runs software for MS-DOS compatible disk operating systems—primarily video games. It was first released in 2002, when DOS technology was becoming obsolete. Its adoption for running DOS games i ...
, FUSE ZX Spectrum emulator and
VisualBoyAdvance VisualBoyAdvance (commonly abbreviated as VBA) is a free emulator of the Game Boy, Game Boy Color, and Game Boy Advance handheld game consoles as well as of Super Game Boy and Super Game Boy 2. Besides the DirectX version for the Windows platf ...
. 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. Universities typically offer both undergraduate and postgraduate programs. In the United States, t ...
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 Applied science, practical discipli ...
, 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 ''Unknown Horizons'' is a city-building game and real-time strategy game, inspired by the ''Anno'' series. It is released under the GNU General Public License (GPLv2) and is therefore free and open source software. Much of the artwork is open ...
'' File:Hwscreen.png, ''Hedgewars'' File:Scorched 3D 39.1 screenshot 3.jpg, ''
Scorched 3D ''Scorched 3D'' is a free and open source artillery game modeled after the MS-DOS game ''Scorched Earth (video game), Scorched Earth''. ''Scorched 3D'' is licensed under the GNU General Public License, GNU GPL-2.0-or-later, and supports numerous p ...
'' File:Fretsonfirex1.jpg, ''
Frets on Fire ''Frets on Fire'' (''FoF'') is a free, open-source music video game created by Finnish independent video game developer Unreal Voodoo. Players use the keyboard to play along with markers which appear on screen, with the aim to score points, achi ...
'' 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–2 ...
'' 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 ''Secret Maryo Chronicles'' is a free and open-source two-dimensional platform computer game that began in 2003. The game has been described by the German ''PCtipp'' as a ''Super Mario Bros.'' clone. History ''Secret Maryo Chronicles'' bega ...
'' File:Trine - Wizard Knight Caverns.jpg, '' Trine'' File:Trine 2 - Deadly Dustland Three Heroes.jpg, ''
Trine 2 ''Trine 2'' is a side-scrolling, puzzle-platform game developed by Frozenbyte. It is the sequel to '' Trine'' and was released on Microsoft Windows, OS X, PlayStation 3, and Xbox 360 in December 2011, and later for Linux in March 2012. ''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