SDL (Simple DirectMedia Layer) is a cross-platform multimedia framework. It has suport fro Wayland since version 2.0.2.
Writing SDL applications requires the RPM package
SDL2-devel
under Fedora and
libsdl2-dev
under Ubuntu.
To demonstrate SDL and Wayland we don't need a complex application, just a simple window will do. The following application draws a window and exits after 10 seconds window.c:
It can be built using the Makefile
The default is to run under X:
./window
runs as an X application with an X window.
To run under Wayland, set the environment variable
SDL_VIDEODRIVER
:
SDL_VIDEODRIVER=wayland ./window
This runs as a Wayland application, native on Fedora, in Weston
on Ubuntu.
If you need to get a Wayland surface this is done by getting the
system structure SDL_GetWindowWMInfo
. This contains
a union of information for different backends. For Wayland,
the relevant calls are given in the program
wayland_info.c
Building SDL applications for Wayland is straightforward:
without any changes to the source code, run the executable
with the environment variable SDL_VIDEODRIVER
set to wayland
.
Access to the Wayland display and applications's Wayland surface
is straightforward.