Guile-SDL2 provides Guile Scheme bindings for the SDL2 C shared library. The bindings are written in pure Scheme using Guile's foreign function interface.
Guile-SDL2 provides modules in the (sdl2 ...)
namespace, roughly organized how the SDL2 C header files are
organized. Low-level bindings are available in the(sdl2 bindings ...)
namespace, but these are not recommended for normal usage.
Additionally, SDL2 extension library bindings are available in the following modules:
(sdl2 image)
(sdl2 mixer)
(sdl2 ttf)
Here is a short “hello, world” example program:
(use-modules (sdl2)
(sdl2 render)
(sdl2 surface)
(sdl2 video))
(define (draw ren)
(let* ((surface (load-bmp "hello.bmp"))
(texture (surface->texture ren surface)))
(clear-renderer ren)
(render-copy ren texture)
(present-renderer ren)
(sleep 2)))
(sdl-init)
(call-with-window (make-window)
(lambda (window)
(call-with-renderer (make-renderer window) draw)))
(sdl-quit)
To install Guile-SDL2 with the GNU Guix package manager, run:
guix install guile-sdl2
To build and install Guile-SDL2 from source, run:
wget https://files.dthompson.us/releases/guile-sdl2/guile-sdl2-0.8.0.tar.gz tar xf guile-sdl2-0.8.0.tar.gz cd guile-sdl2-0.8.0 ./configure make make install
GNU LGPLv3+
Guile-SDL2 is developed using the Git version control system. The official repository is hosted at https://git.dthompson.us/guile-sdl2.git.
To clone the repository, run:
git clone https://git.dthompson.us/guile-sdl2.git
Real-time discussion for Guile-SDL2 can be found on the #guile
channel on the Libera.chat IRC network
Send patches and bug reports to davet@gnu.org.