New Features in SDL3
If you've got an SDL2 app, you might be wondering if you should move
to SDL3, or maybe just drop sdl2-compat into
the mix.
A lot of things you're already using in SDL2 are easier, more
consistent, and just generally better in SDL3, so the upgrade
can be worth it in any case, but here are some things that are new
features in SDL3 that you might want access to:
- Extremely good documentation: We've
spent a ton of effort writing and revising the API
reference.
- Example
programs to get you started, running in your web
browser!
- More consistent API naming conventions. Everything is named
consistently across the API now, instead of different subsystems taking
different approaches. Also, we've tended toward more descriptive names
for things in SDL3.
- Main
Callbacks: optionally run your program from callbacks
instead of
main().
- GPU API: access to modern 3D
rendering and GPU compute in a cross-platform way.
- Dialog API: access to system file
dialogs (file and folder selection UI for opening/saving).
- Filesystem API: simple
directory management and globbing, access to topic-specific user
folders.
- Storage API: Abstract interface
to platform-specific storage.
- Camera API: access to
webcams.
- Pen API: access to pens (like Wacom
tablets and Apple Pencil, etc).
- Logical audio devices:
different parts of an app can get their own unique audio device to
use.
- Audio streams: handle
buffering, converting, resampling, mixing, channel mapping, pitch, and
gain. Bind to an audio device and go!
- Default audio
devices: SDL3 will automatically manage migrating to new physical
hardware as devices are plugged in, ripped out, or changed.
- Asynchronous I/O: Start file
reads/writes, come back later to get the results. Can use Windows IoRing
and Linux io_uring behind the scenes!
- Time API: date and time
functionality beyond ticks and performance counters.
- Properties API: fast, flexible
dictionaries of name/value pairs.
- Process API: Spawn child
processes and communicate with them in various ways.
- Colorspace support: Surfaces and
the renderer, etc, can manage multiple colorspaces.
- Alternate surface
representations for embedding HiDPI versions of images into a single
SDL_Surface.
- The Clipboard API can support
any data type (SDL2 only handled text), and apps can provide data in
multiple formats upon request in a provided callback.
- Multiple keyboards and mice can be managed separately.
- System theme (light, dark) can
be queried.
- Better keyboard input, for
all your keypress needs.
- Customizable virtual
keyboards on iOS and Android.
- Unicode-friendly case-insensitive
string comparison.
- HiDPI support is dramatically improved over SDL2.
- System Tray API: Create custom
system tray/notification area icons and menus.
- App metadata API for letting
SDL report things about your app correctly (like in the About dialog on
macOS, etc).
- Read/write thread locks, to let
multiple threads access rarely-changing data in parallel.
- Init State to help with multiple
threads that might need to initialize something on-demand without
racing.
- 64-bit SDL_GetTicks: No more
worrying about timer wraparound every ~49 days!
- SDL_GetTicksNS: when milliseconds
won't cut it, you can use nanoseconds!
- SDL_DelayPrecise:
Nanosecond-precision waits, using a mixture of OS-level sleeps and
busy-waits.
- SDL_RunOnMainThread: dispatch
arbitrary code to the main thread, for those pesky OS requirements.
- Async windowing
- (More new features are still coming to SDL3, so check back here
later!)
If you are looking to move to SDL3 so you can start using these new
features, you should take a look at README-migration for all the
details.