SDL3 bindings for GNU Modula-2 (gm2 16.0.1, SDL 3.4.16, Linux).
All builds verified with make; tests and showcases also pass
headless via SDL_VIDEODRIVER=dummy.
Upstream SDL sources in SDL-release-3.4.16/ are a read-only
reference (prebuilt build/libSDL3.so used for linking) and are
not committed — per its AGENTS.md no AI-generated code is
contributed upstream. The binding is original work that only uses
SDL headers at compile time.
src/SDL3.def — init/quit, GetError, delay, 64-bit ticks,
perf counter. SDL3 returns C bool, hence BOOLEAN results;
SDL_INIT_TIMER/EVERYTHING gone, GAMEPAD renamed, CAMERA newsrc/SDL3Version.def — SDL_GetVersion(): INTEGER versionnum
(major*1000000+minor*1000+micro), GetRevisionsrc/SDL3Video.def — opaque WindowHandle,
CreateWindow(title, w, h, flags: LONGCARD) (no x/y),
title/size/position/show/hide ([ BOOLEAN ]), 64-bit flag constantssrc/SDL3Events.def — opaque 128-byte event pump (PumpEvents,
PollEvent, WaitEvent, WaitEventTimeout, PushEvent,
HasEvent(s)), quit/key/mouse ids plus EventWindowCloseRequestedsrc/SDL3Rect.def/.mod — pure-M2 SDLPoint/SDLFPoint/SDLRect/
SDLFRect + helpers (SHORTREAL = C float, verified vs C caller)src/SDL3Render.def — <SDL_render.h> subset: CreateRenderer
(name or NIL), CreateWindowAndRenderer (title form, BOOLEAN),
draw color (+float), logical presentation, clear/present,
points/lines/rects in single (VAR) and array (ADR + count)
forms, render scale, output size, debug textsrc/SDL3Key.def/.mod — pure-M2 keycode constants (unchanged values)lib/SDL3Utils.def/.mod — CStrToM2, GetErrorString,
VersionMajor/Minor/Micro, PollM2Event (keycode at offset 28,
verified with offsetof; QUIT + WINDOW_CLOSE_REQUESTED -> quit),
DrainEventstests/ — init, version, rect, window, key + run_tests.sh (5/5 green)examples/ — hello_window, version, event_loop, renderer_demoshowcases/ — ports of SDL examples/renderer/ + examples/demo/
(public domain): showcase_clear (01), showcase_primitives (02),
showcase_lines (03), showcase_points (04),
showcase_rectangles (05), showcase_debug_text (18),
showcase_snake (demo 01); SDL3 is native here, adaptations noted
in each header (callback flattening, rand/randf, ASCII text,
counter instead of varargs RenderDebugTextFormat)Makefile — links the local SDL-release-3.4.16/build/libSDL3.so
with rpath; make check runs the test suiteDEFINITION MODULE FOR "C" + EXPORT UNQUALIFIED, link -lSDL3.*) inside (* *) comments — C pointer spellings need a space.BOOLEAN <-> C bool, CARDINAL <-> Uint32, LONGCARD <-> Uint64,
INTEGER <-> int, SHORTREAL <-> float (REAL is double).bool results need [ BOOLEAN ] to call as statements.ADDRESS, ARRAY OF CHAR params = char *,
VAR record params = T *, arrays = ADR + count.SHORTREAL(real-expr) fails, use
VAL(SHORTREAL, ...).gm2 -c to .o, then link.WINDOW_CLOSE_REQUESTED, not QUIT —
handle both (done in DrainEvents/PollM2Event).Texture/surface subset, audio streams, gamepad/joystick, typed
SDL_Event variant record, then infinite-monkeys and further demos.