A window that shows an RGBA pixel buffer, with keyboard and window events and streams of sound, through the host’s SDL3 over the dlopen FFI.
SdlA window that shows an RGBA pixel buffer, its keyboard and window events, and streams of sound, through the host’s SDL3 loaded with dlopen.
SDL3 is looked for at the path given to load!, then as libSDL3.so.0, libSDL3.0.dylib, and under /opt/homebrew/lib and /usr/local/lib. A missing library raises a label ‘io.
%path-cellStatic field: data held by Sdl itself, not by its instances.
%init-videoStatic field: data held by Sdl itself, not by its instances.
%init-gamepadStatic field: data held by Sdl itself, not by its instances.
%init-audioStatic field: data held by Sdl itself, not by its instances.
%s16Static field: data held by Sdl itself, not by its instances.
%default-playbackStatic field: data held by Sdl itself, not by its instances.
%buttonsStatic field: data held by Sdl itself, not by its instances.
%axesStatic field: data held by Sdl itself, not by its instances.
%mouse-buttonsStatic field: data held by Sdl itself, not by its instances.
%rgba32Static field: data held by Sdl itself, not by its instances.
%streamingStatic field: data held by Sdl itself, not by its instances.
%integer-scaleStatic field: data held by Sdl itself, not by its instances.
%letterboxStatic field: data held by Sdl itself, not by its instances.
%nearestStatic field: data held by Sdl itself, not by its instances.
%resizableStatic field: data held by Sdl itself, not by its instances.
%event-sizeStatic field: data held by Sdl itself, not by its instances.
%keysStatic field: data held by Sdl itself, not by its instances.
(Sdl keys)Keycodes by name for keys that are not printable characters.
Returns: LIST — ((name . keycode) …)
Examples:
(first (Sdl keys)) => ('up . 1073741906)(Sdl %handle)The libSDL3 handle, or nil when no candidate opens.
Returns: POINTER|NIL — The dlopen handle
(Sdl %sym name)The named SDL3 function; raises a label ‘io when libSDL3 is not found.
Parameters:
STRING — SDL function nameReturns: POINTER — The function pointer
(Sdl %ok r what)Raise a label ‘io with SDL’s error when a bool result is false.
Parameters:
INTEGER — A C bool resultSTRING — The call, for the messageReturns: ANY — nil
(Sdl %made p what)The pointer, or a label ‘io with SDL’s error when it is NULL.
Parameters:
INTEGER — A pointer resultSTRING — The call, for the messageReturns: INTEGER — The pointer, as an integer
(Sdl %zeroed n)A (str make) region of n zero bytes.
Parameters:
INTEGER — Byte count, a multiple of 8Returns: STRING — The region
(Sdl load! path)Name the libSDL3 to load ahead of the default names, as a game shipping its own copy does.
Parameters:
STRING — A libSDL3 file to try firstReturns: STRING — The path
Examples:
(Sdl load! "/nonexistent/libSDL3.dylib") => "/nonexistent/libSDL3.dylib"(Sdl available?)Whether a libSDL3 can be opened.
Returns: BOOL — #t when one opens
(Sdl error)SDL’s last error message.
Returns: STRING — The message, empty when there is none
(Sdl hint! name value)Set an SDL hint; video and render driver hints take effect at the next open.
Parameters:
STRING — An SDL hint name, such as SDL_VIDEO_DRIVERSTRING — Its valueReturns: BOOL — #t when SDL took the hint
(Sdl open title w h scale)Start SDL’s video and open a resizable window that shows a w x h RGBA picture, scaled by whole multiples with nearest-pixel sampling.
Parameters:
STRING — Window titleINTEGER — Picture width in pixelsINTEGER — Picture height in pixelsINTEGER — Initial window size, in multiples of the pictureReturns: LIST — The window: (window renderer texture w h)
(Sdl scaling! win mode)Set how the picture fills the window as it is resized: by whole multiples, every pixel the same size and bars round the rest, or as large as fits, the bars only on two sides and the pixels a little uneven.
Parameters:
LIST — A window from openSYMBOL — whole: whole multiples only; fit: as large as the window allows, its shape keptReturns: LIST — The window
(Sdl canvas win)A zeroed RGBA buffer the size of the window’s picture: transparent black.
Parameters:
LIST — A window from openReturns: STRING — A region of wh4 bytes
(Sdl draw! win buf)Upload the buffer and draw it over the whole picture; nothing shows until present!.
Parameters:
LIST — A window from openSTRING — An RGBA buffer the window’s sizeReturns: LIST — The window
(Sdl present! win)Put the drawn frame on screen.
Parameters:
LIST — A window from openReturns: LIST — The window
(Sdl show! win buf)Draw the buffer and present it.
Parameters:
LIST — A window from openSTRING — An RGBA buffer the window’s sizeReturns: LIST — The window
(Sdl read-pixels win)The frame drawn since the last present, read back as an RGBA buffer; call it before present!.
Parameters:
LIST — A window from openReturns: STRING — A region of wh4 bytes
(Sdl poll . win)The next queued event, or nil when the queue is empty.
A gamepad is opened when its pad-added arrives and closed at pad-removed; pads already connected at open arrive as pad-added too.
The mouse’s X Y are in the window’s pixels, or in the picture’s when the window is given, whole and toward zero; a place in the bars beside the picture lies outside it, below 0 or past its size.
Parameters:
LIST — A window from open: the mouse’s places in its picture’s pixelsReturns: LIST|NIL — (key-down KEY MOD REPEAT), (key-up KEY MOD REPEAT), (mouse-down BUTTON X Y), (mouse-up BUTTON X Y), (mouse-motion X Y HELD), (pad-down BUTTON PAD), (pad-up BUTTON PAD), (pad-axis AXIS VALUE PAD), (pad-added PAD), (pad-removed PAD), (quit), (close) or (other TYPE)
(Sdl %name names i)The symbol for an SDL enum value, or the value itself past the named ones.
Parameters:
LIST — Symbols in SDL’s enum orderINTEGER — An enum valueReturns: SYMBOL|INTEGER — The name, or i
Examples:
(Sdl %name (Sdl %buttons) 11) => 'dpad-up(Sdl %sint16 u)The field as a signed 16-bit value.
Parameters:
INTEGER — A 16-bit field read unsignedReturns: INTEGER — -32768 to 32767
Examples:
(Sdl %sint16 65535) => -1(Sdl %f32-int b)The float as a whole number, toward zero; SDL gives the mouse’s places as floats.
Parameters:
INTEGER — A 32-bit IEEE float’s bits, read as an integerReturns: INTEGER — The whole part
Examples:
(Sdl %f32-int 0x41200000) => 10
(Sdl %f32-int 0xBF800000) => -1(Sdl %held state)The mouse buttons held, by name, for the flags SDL gives with a motion.
Parameters:
INTEGER — SDL’s mouse button flagsReturns: LIST — Names from (Sdl mouse-buttons)
Examples:
(Sdl %held 5) => ('left 'right)(Sdl mouse-buttons)Mouse button names in SDL’s order, button 1 first.
Returns: LIST — (left middle right x1 x2)
Examples:
(List ref 2 (Sdl mouse-buttons)) => 'right(Sdl buttons)Gamepad button names in SDL’s order; south is the bottom face button, Xbox A.
Returns: LIST — (south east west north …)
Examples:
(List ref 0 (Sdl buttons)) => 'south(Sdl axes)Gamepad axis names in SDL’s order; sticks run -32768 to 32767, triggers 0 to 32767.
Returns: LIST — (left-x left-y right-x right-y left-trigger right-trigger)
Examples:
(List ref 4 (Sdl axes)) => 'left-trigger(Sdl fullscreen! win on)Switch the window to the desktop’s fullscreen or back; the picture keeps its whole-multiple scaling.
Parameters:
LIST — A window from openBOOL — #t for fullscreen, #f for a windowReturns: LIST — The window
(Sdl raise! win)Bring the window to the front and give it the keyboard, as far as the system allows: it may refuse to take the keyboard from another program.
Parameters:
LIST — A window from openReturns: LIST — The window
(Sdl post-key! code)Queue a key-down event for code, as if it had been pressed: input for tests and replays.
Parameters:
INTEGER — An SDL keycodeReturns: BOOL — #t when SDL queued it
(Sdl key name)The keycode of a named key that is not a printable character.
Parameters:
SYMBOL — A key name from (Sdl keys)Returns: INTEGER|NIL — The keycode, or nil for an unknown name
Examples:
(Sdl key (lit escape)) => 27(Sdl audio-open rate chans)Start SDL’s audio and open a stream to the default playback device that plays signed 16-bit little-endian frames, already running: what is put on it plays as soon as the device takes it. Each stream is mixed with every other one open.
With the hint SDL_AUDIO_DRIVER set to dummy, a stream opens and drains with no sound device, as a spec needs.
Parameters:
INTEGER — Frames a second, such as 44100INTEGER — Channels a frame: 1 mono, 2 stereo, left firstReturns: INTEGER — The stream, an SDL_AudioStream pointer as an integer
(Sdl audio-put! s buf n)Queue the first n bytes of buf to play after what is already queued. SDL copies them: buf may be written again at once.
Parameters:
INTEGER — A stream from audio-openSTRING — A region of framesINTEGER — Bytes of it to queue, from its startReturns: INTEGER — n
(Sdl audio-queued s)Bytes queued on the stream and not yet taken by the device: how far ahead of the speaker the stream is.
Parameters:
INTEGER — A stream from audio-openReturns: INTEGER — A byte count, 0 when it has run dry
(Sdl audio-clear! s)Drop everything queued on the stream, unplayed: the next put plays at once.
Parameters:
INTEGER — A stream from audio-openReturns: INTEGER — The stream
(Sdl audio-close s)Stop the stream and release it and its device; what was queued is dropped.
Parameters:
INTEGER — A stream from audio-openReturns: ANY — nil
(Sdl close win)Release the window’s texture, renderer and window, and shut SDL down.
Parameters:
LIST — A window from openReturns: ANY — nil