Wiki Page Content

Differences between revisions 10 and 31 (spanning 21 versions)
Revision 10 as of 2013-07-21 18:36:11
Size: 4922
Editor: Sam Lantinga
Comment:
Revision 31 as of 2018-11-06 03:33:30
Size: 5306
Editor: DanielG
Comment: restore Introduction page to prior version
Deletions are marked like this. Additions are marked like this.
Line 9: Line 9:
Line 10: Line 11:
The Simple DirectMedia Layer library (SDL) is a general API that provides low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D framebuffer across multiple platforms. Simple !DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including [[http://valvesoftware.com|Valve]]'s award winning catalog and many [[https://www.humblebundle.com|Humble Bundle]] games.
Line 12: Line 13:
The current version supports Windows XP/Vista/7/8, Mac OS X, Linux, iOS, and Android. The code contains support for other operating systems but those are not officially supported.
 . For the latest information on what is supported see http://hg.libsdl.org/SDL/file/default/README-platforms.txt
SDL officially supports Windows, Mac OS X, Linux, iOS, and [[Android]]. Support for other platforms may be found in the source code.
 . For the latest information on what is supported see /* http://hg.libsdl.org/SDL/file/default/docs/README-platforms.md */ [[Installation|the page about Installation]].
Line 15: Line 16:
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. SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.
Line 18: Line 19:
SDL 2.0 is under the [[http://www.zlib.net/zlib_license.html|zlib]] license, which allows free use for commercial and non-commercial purposes.
SDL 2.0 is distributed under the [[http://www.gzip.org/zlib/zlib_license.html|zlib license]]. This license allows you to use SDL freely in any software.
The Simple !DirectMedia Layer library (SDL) is a general API that provides low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D framebuffer across multiple platforms.
Line 22: Line 23:
Read ahead for an overview of what SDL is capable of. If you're simply interested in the changes from 1.2 to 2.0, check out the [[MigrationGuide|Migration Guide]].
Line 24: Line 27:
 * Set a video mode at any depth (8-bpp or greater) with optional conversion, if the video mode is not supported by the hardware
 * Write directly to a linear graphics framebuffer
 * Create surfaces with color key or alpha blending attributes
 * Surface blits are automatically converted to the target format using optimized blitters and are hardware accelerated, when possible. MMX optimized blits are available for the x86
 * Hardware accelerated blit and fill operations are used if supported by the hardware
 * Window Management
 * Rendering
 * 3D graphics:
  * SDL can be used in combination with the OpenGL API or Direct3D API for 3D graphics
 * Accelerated 2D render API:
  * Supports easy rotation, scaling and alpha blending, all accelerated using modern 3D APIs
  * Acceleration is supported using OpenGL and Direct3D, and there is a software fallback
 * Create and manage multiple windows
Line 34: Line 36:
 * Events provided for:
  * Application visibility changes
 * Events and API functions provided for:
  * Application and window state changes
  * Mouse input
Line 37: Line 40:
  * Mouse input
* Joystick input
  * User-requested quit
 * Each event can be enabled or disabled with SDL_!EventState()
  * Joystick and game controller input
  * Multitouch gestures
 * Each event can be enabled or disabled with [[SDL_EventState]]()
Line 46: Line 48:
 * Force feedback is supported under Windows, Mac OSX and Linux  * Force feedback is supported under Windows, Mac OS X and Linux
Line 50: Line 52:
 * Set audio playback of 8-bit and 16-bit audio, mono or stereo, with optional conversion if the format is not supported by the hardware  * Set audio playback of 8-bit and 16-bit audio, mono stereo or 5.1 surround sound, with optional conversion if the format is not supported by the hardware
Line 52: Line 54:
 * Designed for custom software audio mixers, but the example archive contains a complete audio/music output library  * Designed for custom software audio mixers, but [[http://www.libsdl.org/projects/SDL_mixer/|SDL_mixer]] provides a complete audio/music output library
Line 61: Line 63:
 * Load shared objects (DLL on Windows, .dylib on Mac OSX, .so on Linux)  * Load shared objects (DLL on Windows, .dylib on Mac OS X, .so on Linux)
Line 67: Line 69:
 * Simple binary semaphores for synchronization  * Simple thread local storage API
 * Mutexes, semaphores and condition variables
 * Atomic operations for lockless programming
Line 73: Line 77:
 * Set a single periodic timer with 10ms resolution  * Create timers that run alongside your code in a separate thread
 * Use high resolution counter for profiling
Line 77: Line 82:
 * Detect MMX, SSE, 3DNow and !AltiVec CPU features  * Query the number of CPUs
 * Detect CPU features and supported instruction sets
Line 90: Line 96:
Line 92: Line 99:
 * Two versions, one safe for all systems based on Win32 APIs, and one with higher performance, based on DirectX APIs
 * Safe version uses GDI for video display. High performance version uses !Direct3D for video display, taking advantage of modern hardware acceleration
 * Safe version uses waveOut APIs for sound. High performance version uses !DirectSound for audio playback
 * Uses Win32 APIs for display, taking advantage of Direct3D for hardware acceleration
 * Uses !DirectSound and XAudio2 for sound
Line 115: Line 121:
 * See also [[Android]]
Line 116: Line 123:
== Special features in SDL 2.0 ==
 * Full 3D hardware acceleration
 * Support for OpenGL 3.0+
 * Support for multiple windows
 * Support for multiple displays
 * Support for multiple mice, tablets, etc.
 * Force Feedback available on Windows, Mac OS X and Linux
== How to get and install SDL ==
You can [[SourceCode|get the source code]] and [[Installation|build and install it]].
Line 124: Line 126:
=== Transitioning from SDL 1.2 to 2.0 ===
 * [[http://wiki.libsdl.org/moin.cgi/MigrationGuide|Migration Guide]]
== Transitioning from SDL 1.2 to 2.0 ==
If you used SDL 1.2 previously and you want to use SDL 2.0, please note there are some API changes and some of your code will need to be adapted.

The migration guide lists the feature differences and how to adapt old code to the new SDL 2.0:

 * [[MigrationGuide|Migration Guide]]

Introduction to SDL 2.0

1. Introduction to SDL

1.1. What is SDL?

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.

SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code.

SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.

SDL 2.0 is distributed under the zlib license. This license allows you to use SDL freely in any software. The Simple DirectMedia Layer library (SDL) is a general API that provides low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D framebuffer across multiple platforms.

1.2. What can SDL do?

Read ahead for an overview of what SDL is capable of. If you're simply interested in the changes from 1.2 to 2.0, check out the Migration Guide.

Video

  • 3D graphics:
    • SDL can be used in combination with the OpenGL API or Direct3D API for 3D graphics
  • Accelerated 2D render API:
    • Supports easy rotation, scaling and alpha blending, all accelerated using modern 3D APIs
    • Acceleration is supported using OpenGL and Direct3D, and there is a software fallback
  • Create and manage multiple windows

Input Events

  • Events and API functions provided for:
    • Application and window state changes
    • Mouse input
    • Keyboard input
    • Joystick and game controller input
    • Multitouch gestures
  • Each event can be enabled or disabled with SDL_EventState()

  • Events are passed through a user-specified filter function before being posted to the internal event queue
  • Thread-safe event queue

Force Feedback

  • Force feedback is supported under Windows, Mac OS X and Linux

Audio

  • Set audio playback of 8-bit and 16-bit audio, mono stereo or 5.1 surround sound, with optional conversion if the format is not supported by the hardware
  • Audio runs independently in a separate thread, filled via a user callback mechanism
  • Designed for custom software audio mixers, but SDL_mixer provides a complete audio/music output library

File I/O Abstraction

  • General purpose abstraction for opening, reading and writing data
  • Built-in support for files and memory

Shared Object Support

  • Load shared objects (DLL on Windows, .dylib on Mac OS X, .so on Linux)
  • Lookup functions in shared objects

Threads

  • Simple thread creation API
  • Simple thread local storage API
  • Mutexes, semaphores and condition variables
  • Atomic operations for lockless programming

Timers

  • Get the number of milliseconds elapsed
  • Wait a specified number of milliseconds
  • Create timers that run alongside your code in a separate thread
  • Use high resolution counter for profiling

CPU Feature Detection

  • Query the number of CPUs
  • Detect CPU features and supported instruction sets

Endian Independence

  • Detect the endianness of the current system
  • Routines for fast swapping of data values
  • Read and write data of a specified endianness

Power Management

  • Querying power management status

1.3. What platforms does SDL run on?

Windows

  • Uses Win32 APIs for display, taking advantage of Direct3D for hardware acceleration
  • Uses DirectSound and XAudio2 for sound

Mac OS X

  • Uses Cocoa for video display, taking advantage of OpenGL for hardware acceleration
  • Uses Core Audio for sound

Linux

  • Uses X11 for video display, taking advantage of OpenGL for hardware acceleration
  • Uses the ALSA, OSS and PulseAudio APIs for sound

iOS

  • Uses UIKit for video display, taking advantage of OpenGL ES 2.0 for hardware acceleration
  • Uses Core Audio for sound

Android

  • Uses JNI interfaces for video display, taking advantage of OpenGL ES 1.1 and 2.0 for hardware acceleration
  • Uses JNI audio callbacks for sound
  • See also Android

2. How to get and install SDL

You can get the source code and build and install it.

3. Transitioning from SDL 1.2 to 2.0

If you used SDL 1.2 previously and you want to use SDL 2.0, please note there are some API changes and some of your code will need to be adapted.

The migration guide lists the feature differences and how to adapt old code to the new SDL 2.0:

None: Introduction (last edited 2018-11-06 03:33:30 by DanielG)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit