Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Simple DirectMedia Layer
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Software architecture == SDL is a [[wrapper library|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).<ref>{{cite web |url=https://wiki.libsdl.org/Introduction |title=Introduction to SDL|access-date=3 March 2014}}</ref> SDL provides support for 2D pixel operations, sound, file access, event handling, timing and threading. It is often used to complement [[OpenGL]] 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 a 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]]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:<ref>{{Cite web|url=https://wiki.libsdl.org/APIByCategory|title = APIByCategory}}</ref> ; Basics: Initialization and Shutdown, Configuration Variables, Error Handling, Log Handling ; Video: Display and Window Management, surface functions, rendering acceleration, etc. ; Input Events: [[Event (computing)|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: [[thread (computer science)|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<ref>{{cite web |url=https://www.libsdl.org/projects/SDL_image/ |title=SDL_image 2.0 |website=libsdl.org |access-date=19 July 2014}}</ref> * ''SDL_mixer'' β complex audio functions, mainly for sound mixing<ref>{{cite web |url=https://www.libsdl.org/projects/SDL_mixer/ |title=SDL_mixer 2.0 |website=libsdl.org |access-date=19 July 2014}}</ref> * ''SDL_net'' β networking support<ref>{{cite web |url=https://www.libsdl.org/projects/SDL_net/ |title=SDL_net 2.0 |website=libsdl.org |access-date=19 July 2014}}</ref> * ''SDL_ttf'' β [[TrueType]] font rendering support<ref>{{cite web |url=https://www.libsdl.org/projects/SDL_ttf/ |title=SDL_ttf 2.0 |website=libsdl.org |access-date=19 July 2014}}</ref> * ''SDL_rtf'' β simple [[Rich Text Format]] rendering<ref>{{cite web |url=https://www.libsdl.org/projects/SDL_rtf/ |title=SDL_rtf 0.1 |website=libsdl.org |access-date=19 July 2014}}</ref> Other, non-standard libraries also exist. For example: SDL_Collide on SourceForge created by [[Amir Taaki]]. === Language bindings === The SDL 2.0 library has [[language binding]]s for: {{div col|colwidth=25em}} * [[Ada (programming language)|Ada]]<ref name="sdl2bindings"/> * Beef * [[C (programming language)|C]] * [[C++]] * [[C Sharp (programming language)|C#]]<ref name="sdl2bindings"/> * [[Common Lisp (programming language)|Common Lisp]]<ref>{{cite web|url=https://github.com/lispgames/cl-sdl2|title=cl-sdl2|publisher=GitHub|access-date=23 November 2017}}</ref> * [[D (programming language)|D]]<ref name="sdl2bindings"/> * [[Erlang (programming language)|Erlang]] * [[Fortran]]<ref>{{cite web|publisher=GitHub|url=https://github.com/interkosmos/f03sdl2|title=f03sdl2|access-date=2019-10-28}}</ref> * [[Gambas]]<ref>{{cite web|publisher=Gambas Wiki|url=https://gambaswiki.org/wiki/comp/gb.sdl2|title=gb.sdl2|access-date=2023-02-02}}</ref> * [[Go (programming language)|Go]]<ref name="sdl2bindings"/><ref name="Go+Julia">{{cite web|url=https://software.intel.com/en-us/blogs/2015/11/05/go-julia-fourier-open-source-frequon-invaders|title=Go + Julia + Fourier = Open Source Frequon Invaders|first=Arch D. |last=Robison|date= November 9, 2015|website=software.intel.com|language=en|access-date=2019-08-02}}</ref> * [[Haskell (programming language)|Haskell]]<ref>{{cite web|url=https://hackage.haskell.org/package/SDL|title=SDL on Hackage}}</ref><ref>{{cite web|url=https://hackage.haskell.org/package/sdl2|title=SDL2 on Hackage}}</ref> * [[Java (programming language)|Java]] (e.g. JSDL) * [[Julia (programming language)|Julia]]<ref>{{cite web|last=Bieler|first=Jonathan|title=jonathanBieler/SimpleDirectMediaLayer.jl|website=[[GitHub]]|date=2020-07-30|url=https://github.com/jonathanBieler/SimpleDirectMediaLayer.jl|access-date=2020-08-08}}</ref><ref>{{cite web|last=SquidSinker|title=Example games for GameZero.jl|website=[[GitHub]]|date=2020-08-02|url=https://github.com/SquidSinker/GZExamples|access-date=2020-08-08}}</ref><ref>{{cite web |last=Daly|first=Nathan|title=Example game written in julia using SDL2|website=[[GitHub]]|date=2019-07-31|url=https://github.com/NHDaly/PaddleBattle.jl|access-date=2019-08-02}}</ref><ref name="Go+Julia"/> * [[Lua (programming language)|Lua]]<ref name="sdl2bindings"/> * [[Nim (programming language)|Nim]]<ref>{{cite web|url=https://github.com/nim-lang/sdl2|title=SDL2 for Nim|publisher=GitHub|access-date=31 May 2022}}</ref> * [[OCaml]]<ref name="sdl2bindings"/> * [[Odin (programming language)|Odin]]<ref>{{cite web|url=https://pkg.odin-lang.org/vendor/sdl2/|title=Odin Vendor Library Collection}}</ref><ref>{{cite web|url=https://github.com/odin-lang/Odin/tree/master/vendor#sdl2|title=Odin GitHub repository|website=[[GitHub]] }}</ref> * [[Pascal (programming language)|Pascal]]<ref name="sdl2bindings"/> * [[Perl (programming language)|Perl]] (via SDL)<ref>{{cite web|url=https://github.com/PerlGameDev/SDL|title=PerlGameDev/SDL|publisher=GitHub|access-date=20 February 2019}}</ref> * [[PHP]]<ref>{{cite web|url=https://github.com/Ponup/php-sdl|title=PHP-SDL|publisher=GitHub|access-date=2019-10-28}}</ref> * [[Python (programming language)|Python]] (several, e.g. pygame_sdl2 and sdl2hl)<ref name="sdl2bindings"/> * [[Raku (programming language)|Raku]]<ref>{{cite web|url=https://modules.raku.org/dist/SDL2::Raw:cpan:TIMOTIMO)|title=SDL2::Raw|publisher=modules.raku.org|access-date=15 May 2020}}</ref> * [[Ring (programming language)|Ring]]<ref>{{Cite book|url=https://www.apress.com/gp/book/9781484258323|title=Beginning Ring Programming - From Novice to Professional {{!}} Mansour Ayouni {{!}} Apress|language=en}}</ref><ref>{{Cite web|url=https://ring-lang.github.io/doc1.16/libsdl.html|title = Using RingLibSDL β Ring 1.16 documentation}}</ref> * [[Rust (programming language)|Rust]]<ref name="sdl2bindings"/> * [[Vala (programming language)|Vala]] {{div col end}} === Supported back-ends === [[File:SDL Layers.svg|thumb|Abstraction layers of several SDL platforms]] 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:<ref name="platforms" /> * [[Graphics Device Interface|GDI]] back-end for [[Microsoft Windows]]. * [[DirectX]] back-end; older SDL 1.2 uses DirectX 7 by default, while 2.0 defaults to DirectX 9 and can access up to DirectX 12. * [[Quartz (graphics layer)|Quartz]] back-end for [[macOS]] (dropped in 2.0). * [[Metal (API)|Metal]] back-end for [[macOS]] / [[iOS]] / [[tvOS]] since 2.0.8; older versions use OpenGL by default.<ref>{{cite web|url=https://www.libsdl.org/tmp/SDL/WhatsNew.txt|access-date=28 September 2020|title=WhatsNew.txt|archive-date=11 November 2020|archive-url=https://web.archive.org/web/20201111232012/https://www.libsdl.org/tmp/SDL/WhatsNew.txt|url-status=dead}}</ref><ref>{{cite web|url=http://lists.libsdl.org/pipermail/commits-libsdl.org/2017-December/002441.html|date=7 December 2017|title=[Commits] SDL: Enable building the Metal renderer by default, and weak lin...}}{{Dead link|date=May 2025 |bot=InternetArchiveBot |fix-attempted=yes }}</ref> * [[Xlib]] back-end for [[X Window System core protocol|X11]]-based [[windowing system]] on various operating systems.<ref>{{cite web |url=http://hg.libsdl.org/SDL/file/default/README-platforms.txt |title=SDL: README-platforms.txt@3e2f230a6d62 |website=Hg.libsdl.org |publisher=libsdl.org |access-date=2013-12-08 |archive-url=https://web.archive.org/web/20131215031050/http://hg.libsdl.org/SDL/file/default/README-platforms.txt |archive-date=2013-12-15}}</ref> * [[OpenGL]] contexts on various platforms.<ref>{{cite web |url=https://www.libsdl.org/release/SDL-1.2.15/docs/html/guidevideoopengl.html |title=Using OpenGL With SDL |access-date=2015-07-09 }}</ref> * [[EGL (API)|EGL]] back-end when used in conjunction with Wayland-based windowing system.,<ref>{{cite web |url=https://wiki.archlinux.org/index.php/Wayland#SDL |title=SDL and Wayland}}</ref> [[Raspberry Pi]]<ref>{{cite web|url=https://www.phoronix.com/scan.php?page=news_item&px=MTQ3MzA|title= Raspberry Pi Support Added To SDL2 Library|first= Michael|last= Larabel|date= 30 September 2013}}</ref> and other systems. * [[Vulkan (API)|Vulkan]] contexts on platforms that support it.<ref name="vulkan" /> * sceGu back-end, a Sony OpenGL-like backend native to the [[PlayStation Portable|PSP]]. <!-- Was seemingly added back to SDL 2, at least in restricted form: SDL 1.2 has support for [[RISC OS]] (dropped in 2.0). --> An unofficial [[Sixel]] back-end is available for SDL 1.2.<ref>{{cite web |url=https://github.com/saitoha/libsixel/tree/v1.6.1#sdl-integration-gaming-virtualization-etc |title=SDL 1.2 Sixel |website=[[GitHub]] |access-date=2016-04-09}}</ref> The [[Rockbox]] MP3 player firmware also distributes a version of SDL 1.2, which is used to run games such as [[Quake (video game)|Quake]].<ref>{{cite web |url=https://www.rockbox.org/wiki/SdlPluginPort |title=SDLPluginPort |access-date=2019-08-11}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)