SDL

From MZXWiki
Jump to navigation Jump to search

SDL is a cross-platform library written by Sam Lantinga that provides a common abstracted interface for platform-specific functionality for graphics, audio, input devices like keyboards, and joysticks. Because of its wide support for various platforms, it has been used by MegaZeux for most of its supported platforms since 2004.

MegaZeux ports that currently rely on SDL include the Windows, Mac OS X, Linux/BSD, Amiga, GP2X, Pandora, HTML5/Emscripten, Android, Nintendo Switch, and PlayStation Portable ports. The Nintendo Wii port can also optionally use SDL, but this is disabled by default.

SDL 1.2

MegaZeux has supported SDL 1.2 since 2004, which was used by default for every MegaZeux release between 2.80 and 2.84c. While most ports no longer use SDL 1.2 by default and no SDL 1.2 builds are provided for them, most platforms still support it.

Platforms that only support SDL 1.2

  • Windows 9x/ME: SDL 2.0 discontinued support.
  • Macs OS X (PowerPC): SDL 2.0 discontinued support.
  • PlayStation Portable: toolchain/deps haven't been updated to support 2.0.
  • Nintendo Wii: if optionally enabled via SDL Wii, which hasn't been updated to 2.0.

SDL 2.0

MegaZeux has supported SDL 2.0 since late 2013, and the first release with it enabled by default was MegaZeux 2.90 (2017-06-29). Most MegaZeux ports currrently use SDL 2.0. Platforms that only support SDL 2.0 include HTML5, Android, and the Nintendo Switch. SDL 2.0 doesn't officially support Intel Macs using Leopard and Snow Leopard, but the builds currently provided by MacPorts seems to work fine.

MegaZeux features relying on SDL 2.0

The following MegaZeux features are only supported by builds using SDL 2.0.

softscale

The softscale renderer is a renderer designed specifically for the SDL_Renderer API introduced in SDL 2.0 and replaces the overlay1 and overlay2 renderers for builds using SDL 2.0. For modern platforms with accelerated graphics it's typically the second best renderer (after glsl), and on some older computers it outperforms glsl. softscale is very similar to the opengl1 renderer, but performs better on Windows (where it can use Direct3D) and on Macs (where it can use hardware accelerated YUV textures).

SDL 1.2 builds can use the overlay or OpenGL renderers for scaling instead. Note that the overlay2 renderer does not support extended graphics, meaning the UI will look corrupted when playing SMZX games and certain newer games may not work at all.

Desktop resolution detection

MZX builds using SDL 2.0 can automatically detect the current desktop resolution and/or currently supported desktop resolutions to calculate the default fullscreen_resolution config values. These builds also support fake fullscreen with the fullscreen_windowed option. Builds with SDL 1.2 have no equivalent functionality for either of these.

Various joystick features

Several joystick features rely on features specific to SDL 2.0:

  • Joystick hotplugging (relies on SDL_JoyDeviceEvent).
  • Automatic mapping of joystick axes/buttons/hats to joystick actions (relies on various mapping string functions from the SDL_Gamecontroller API).
  • Joystick action analog axis values (currently relies on SDL_ControllerAxisEvent).

System clipboard support

MegaZeux will use SDL 2.0's system clipboard support by default on all platforms except Windows. Builds with SDL 1.2 will default to platform-specific clipboard handlers instead, which may not always work properly or are not as relatively well-tested.