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.
- Rules about memory management are more clear in SDL3 (what happens if I query a device's name and the device is unplugged before I can touch the string? SDL3 protects this memory. In SDL2, you hoped for the best.
- 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.
- Main Callbacks: optionally run your program from callbacks instead of
main()
.
- 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.
- 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.
- 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_DelayNS: Nanosecond-precision waits, using a mixture of OS-level sleeps and busy-waits.
- 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.