compat.sdl2
#includeSDL2 — cross-platform window, input and audio layer
#include <SDL.h>
mcpp add compat.sdl2@2.32.10
Usage
From this repository's own test project — built and run by CI, not written for the website.
// Behavioral test — verify compat.sdl2 builds an SDL that can actually run a
// video subsystem, create a window and pump events.
//
// SDL is the one backend in this family that CAN be exercised headlessly:
// its `dummy` video driver is a real, fully functional driver that just never
// touches a display. So unlike the OpenGL and Vulkan backends, this is not a
// link-only smoke test — SDL_Init, SDL_CreateWindow, SDL_GetWindowSize and the
// event pump all execute.
//
// The driver is selected through SDL_HINT_VIDEODRIVER rather than the
// SDL_VIDEODRIVER environment variable so the test is self-contained and does
// not depend on how CI invokes it.
// SDL_MAIN_HANDLED before <SDL.h>: on Windows SDL_main.h does
// `#define main SDL_main` and expects the real entry point to come from
// SDL2main (src/main/windows/SDL_windows_main.c). This package does not ship
// that — a library consumer should not be handed an entry point — so the test
// takes SDL's documented alternative and keeps its own main, pairing it with
// SDL_SetMainReady() below. Without this the link fails with
// "LNK1561: entry point must be defined".
#define SDL_MAIN_HANDLED
#include <SDL.h>
import std;
// …
tests/examples/sdl2/tests/video.cpp · project tests/examples/sdl2
Build
- targets
sdl2 (lib)- language
c++23- C standard
c99- import std
- no
- include dirs
mcpp_generated, */include, */src, */src/video/khronos
Sources (39)
*/src/*.c*/src/atomic/*.c*/src/audio/*.c*/src/audio/disk/*.c*/src/audio/dummy/*.c*/src/cpuinfo/*.c*/src/dynapi/*.c*/src/events/*.c*/src/file/*.c*/src/haptic/*.c*/src/hidapi/*.c*/src/joystick/*.c*/src/joystick/hidapi/*.c*/src/joystick/steam/*.c*/src/joystick/virtual/*.c*/src/libm/*.c*/src/locale/*.c*/src/misc/*.c*/src/power/*.c*/src/render/*.c*/src/render/direct3d/*.c*/src/render/direct3d11/*.c*/src/render/direct3d12/*.c*/src/render/opengl/*.c*/src/render/opengles/*.c*/src/render/opengles2/*.c*/src/render/ps2/*.c*/src/render/psp/*.c*/src/render/software/*.c*/src/render/vitagxm/*.c*/src/sensor/*.c*/src/sensor/dummy/*.c*/src/stdlib/*.c*/src/thread/*.c*/src/timer/*.c*/src/video/*.c*/src/video/dummy/*.c*/src/video/offscreen/*.c*/src/video/yuv2rgb/*.c
Generated files
mcpp_generated/SDL_config.h