summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2024-10-02 21:22:19 -0400
committerDavid Thompson <dthompson2@worcester.edu>2024-10-03 07:12:23 -0400
commit567863b2398b6832f686b258709396572af0e980 (patch)
tree9876b28945a793fc6fedbd7f9804a0d7e159a47c
First commit!main
-rw-r--r--.gitignore11
-rw-r--r--COPYING202
-rw-r--r--Makefile.am59
-rw-r--r--README.md46
-rwxr-xr-xbootstrap3
-rw-r--r--configure.ac42
-rw-r--r--examples/cube.scm10
-rw-r--r--examples/window.scm6
-rw-r--r--guix.scm111
-rw-r--r--pre-inst-env.in28
-rw-r--r--sdl3.scm67
-rw-r--r--sdl3/bindings/error.scm26
-rw-r--r--sdl3/bindings/gpu.scm62
-rw-r--r--sdl3/bindings/init.scm49
-rw-r--r--sdl3/bindings/utils.scm60
-rw-r--r--sdl3/bindings/video.scm95
-rw-r--r--sdl3/config.scm.in22
-rw-r--r--sdl3/errors.scm54
-rw-r--r--sdl3/gpu.scm63
-rw-r--r--sdl3/guardian.scm30
-rw-r--r--sdl3/video.scm72
21 files changed, 1118 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..af9fe7e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,11 @@
+*.go
+/Makefile.in
+/aclocal.m4
+/autom4te.cache/
+/build-aux/
+/config.log
+/configure
+/pre-inst-env
+/config.status
+/Makefile
+/sdl3/config.scm
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..a986f77
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,59 @@
+# guile-sdl3 -- Scheme bindings for SDL3
+# Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+GOBJECTS = $(SOURCES:%.scm=%.go)
+
+nobase_mod_DATA = $(SOURCES) $(NOCOMP_SOURCES)
+nobase_go_DATA = $(GOBJECTS)
+
+# Make sure source files are installed first, so that the mtime of
+# installed compiled files is greater than that of installed source
+# files. See
+# <http://lists.gnu.org/archive/html/guile-devel/2010-07/msg00125.html>
+# for details.
+guile_install_go_files = install-nobase_goDATA
+$(guile_install_go_files): install-nobase_modDATA
+
+CLEANFILES = $(GOBJECTS)
+EXTRA_DIST = $(SOURCES) $(NOCOMP_SOURCES)
+GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
+SUFFIXES = .scm .go
+.scm.go:
+ $(AM_V_GEN)$(top_builddir)/pre-inst-env $(GUILE_TOOLS) compile $(GUILE_WARNINGS) -o "$@" "$<"
+
+moddir=$(prefix)/share/guile/site/$(GUILE_EFFECTIVE_VERSION)
+godir=$(libdir)/guile/$(GUILE_EFFECTIVE_VERSION)/site-ccache
+
+SOURCES = \
+ sdl3/config.scm \
+ sdl3/guardian.scm \
+ sdl3/bindings/utils.scm \
+ sdl3/bindings/error.scm \
+ sdl3/bindings/init.scm \
+ sdl3/bindings/video.scm \
+ sdl3/bindings/gpu.scm \
+ sdl3/errors.scm \
+ sdl3/video.scm \
+ sdl3/gpu.scm \
+ sdl3.scm
+
+EXTRA_DIST += \
+ pre-inst-env.in \
+ README \
+ guix.scm \
+ run-example \
+ examples/hello.scm \
+ examples/hello.bmp \
+ examples/controller.scm
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e1dddef
--- /dev/null
+++ b/README.md
@@ -0,0 +1,46 @@
+# Guile-SDL3
+
+Guile-SDL3 provides Guile Scheme bindings for the SDL3 library.
+
+## Requirements
+
+- Guile >= 3.0
+- SDL3 >= 3.0.0
+- make
+- pkg-config
+
+When building from a Git checkout, the following additional packages
+are required:
+
+- autoconf
+- automake
+- texinfo
+
+If you use Guix, a build environment can be created by running `guix
+shell`.
+
+## Building
+
+### From release tarball
+
+```
+./configure
+make
+make install
+```
+
+### From Git checkout
+
+```
+./bootstrap
+./configure
+make
+make install
+```
+
+## Contributing
+
+In lieu of a proper issue tracker, send patches and bug reports to
+<dthompson2@worcester.edu>. Discussion can be had on the #guile
+channel on the Libera.Chat IRC network or on the guile-user mailing
+lis.
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..872167c
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+autoreconf -vif
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..cb3407b
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,42 @@
+# -*- Autoconf -*-
+#
+# guile-sdl3 -- Scheme bindings for SDL3
+# Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+AC_INIT(guile-sdl3, 0.1.0)
+AC_CONFIG_SRCDIR(sdl3)
+AC_CONFIG_AUX_DIR([build-aux])
+AM_INIT_AUTOMAKE([color-tests -Wall -Wno-portability foreign])
+AM_SILENT_RULES([yes])
+
+AC_PATH_PROG([GUILE], [guile])
+AC_CONFIG_FILES([Makefile sdl3/config.scm])
+AC_CONFIG_FILES([pre-inst-env], [chmod +x pre-inst-env])
+
+GUILE_PKG([3.0])
+GUILE_PROGS
+
+# Core SDL3
+dnl PKG_CHECK_MODULES([SDL3], [sdl3])
+dnl PKG_CHECK_VAR([SDL3_LIBDIR], [sdl3], [libdir])
+dnl AC_MSG_CHECKING([SDL3 library path])
+dnl AS_IF([test "x$SDL3_LIBDIR" = "x"], [
+dnl AC_MSG_FAILURE([unable to find SDL3 library directory])
+dnl ], [
+dnl AC_MSG_RESULT([$SDL3_LIBDIR])
+dnl ])
+dnl AC_SUBST([SDL3_LIBDIR])
+
+AC_OUTPUT
diff --git a/examples/cube.scm b/examples/cube.scm
new file mode 100644
index 0000000..bcd4f01
--- /dev/null
+++ b/examples/cube.scm
@@ -0,0 +1,10 @@
+(use-modules (sdl3)
+ (sdl3 gpu)
+ (sdl3 video))
+
+(define window (make-window "Hello" 640 480))
+(define gpu (make-gpu-device '(spirv)))
+(claim-window-for-gpu-device! gpu window)
+(sleep 3)
+(destroy-gpu-device! gpu)
+(destroy-window! window)
diff --git a/examples/window.scm b/examples/window.scm
new file mode 100644
index 0000000..ea68079
--- /dev/null
+++ b/examples/window.scm
@@ -0,0 +1,6 @@
+(use-modules (sdl3)
+ (sdl3 video))
+
+(define window (make-window "Hello" 640 480))
+(sleep 3)
+(destroy-window! window)
diff --git a/guix.scm b/guix.scm
new file mode 100644
index 0000000..afc747d
--- /dev/null
+++ b/guix.scm
@@ -0,0 +1,111 @@
+;;; guile-sdl3 --- FFI bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; This file is part of guile-sdl3.
+;;;
+;;; Guile-sdl3 is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU Lesser General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; Guile-sdl3 is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with guile-sdl3. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; GNU Guix development package. To build and install, run:
+;;
+;; guix package -f guix.scm
+;;
+;; To use as the basis for a development environment, run:
+;;
+;; guix shell
+;;
+;;; Code:
+
+(use-modules (gnu packages)
+ (gnu packages autotools)
+ (gnu packages guile)
+ (gnu packages linux)
+ (gnu packages pkg-config)
+ (gnu packages sdl)
+ (gnu packages texinfo)
+ (guix build-system cmake)
+ (guix build-system gnu)
+ (guix gexp)
+ (guix git)
+ (guix git-download)
+ (guix licenses)
+ (guix packages))
+
+(define sdl3
+ (let ((commit "91b074beb7337416c3921da0b667ad88491b9c7b")
+ (revision "1"))
+ (package
+ (inherit sdl2)
+ (name "sdl3")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/libsdl-org/SDL")
+ (commit commit)))
+ (sha256
+ (base32
+ "1s2yvhsx129in2f92hj6gc11aalzjml7gc70rxvplji0d3x629kf"))))
+ (build-system cmake-build-system)
+ (arguments
+ (list
+ #:tests? #f
+ #:configure-flags
+ #~(list "-DSDL_KMSDRM=ON"
+ "-DSDL_ALSA_SHARED=OFF"
+ "-DSDL_PULSEAUDIO_SHARED=OFF"
+ "-DSDL_PIPEWIRE_SHARED=OFF"
+ "-DSDL_X11_SHARED=OFF"
+ "-DSDL_WAYLAND_SHARED=OFF"
+ "-DSDL_KMSDRM_SHARED=OFF"
+ ;; "-DSDL_HIDAPI_LIBUSB_SHARED=OFF"
+ (string-append "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-rpath,"
+ #$(this-package-input "eudev") "/lib"
+ ",-rpath,"
+ #$(this-package-input "vulkan-loader") "/lib"))
+ ;; #:make-flags
+ ;; #~(cons*
+ ;; ;; SDL dlopens libudev and libvulkan, so make sure they are in
+ ;; ;; rpath. This overrides the LDFLAG set in sdl’s configure-flags,
+ ;; ;; which isn’t necessary as sdl2 includes Mesa by default.
+ ;; (string-append "LDFLAGS=-Wl,-rpath,"
+ ;; #$(this-package-input "eudev") "/lib"
+ ;; ",-rpath,"
+ ;; #$(this-package-input "vulkan-loader") "/lib")
+ ;; '("V=1"))
+ ))
+ (inputs
+ (modify-inputs (package-inputs sdl2)
+ (append pipewire))))))
+
+(package
+ (name "guile-sdl3")
+ (version "0.1.0")
+ (source (git-checkout (url (dirname (current-filename)))))
+ (build-system gnu-build-system)
+ (arguments
+ '(#:make-flags '("GUILE_AUTO_COMPILE=0")
+ #:phases
+ (modify-phases %standard-phases
+ (add-after 'unpack 'bootstrap
+ (lambda _ (invoke "sh" "bootstrap"))))))
+ (native-inputs (list autoconf automake pkg-config texinfo))
+ (inputs (list guile-3.0-latest sdl3))
+ (synopsis "Guile bindings for SDL3")
+ (description "Guile-SDL3 provides pure Guile Scheme bindings to the SDL3 C shared
+library via the foreign function interface.")
+ (home-page "https://git.dthompson.us/guile-sdl3.git")
+ (license lgpl3+))
diff --git a/pre-inst-env.in b/pre-inst-env.in
new file mode 100644
index 0000000..067e358
--- /dev/null
+++ b/pre-inst-env.in
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# guile-sdl3 -- Scheme bindings for SDL3
+# Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+abs_top_srcdir="`cd "@abs_top_srcdir@" > /dev/null; pwd`"
+abs_top_builddir="`cd "@abs_top_builddir@" > /dev/null; pwd`"
+
+GUILE_LOAD_COMPILED_PATH="$abs_top_builddir${GUILE_LOAD_COMPILED_PATH:+:}$GUILE_LOAD_COMPILED_PATH"
+GUILE_LOAD_PATH="$abs_top_builddir:$abs_top_srcdir${GUILE_LOAD_PATH:+:}:$GUILE_LOAD_PATH"
+export GUILE_LOAD_COMPILED_PATH GUILE_LOAD_PATH
+
+PATH="$abs_top_builddir/scripts:$PATH"
+export PATH
+
+exec "$@"
diff --git a/sdl3.scm b/sdl3.scm
new file mode 100644
index 0000000..3d2fb7b
--- /dev/null
+++ b/sdl3.scm
@@ -0,0 +1,67 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; SDL3 initialization and shutdown.
+;;
+;;; Code:
+
+(define-module (sdl3)
+ #:use-module (ice-9 match)
+ #:use-module (sdl3 bindings init)
+ #:use-module (sdl3 errors)
+ #:use-module (srfi srfi-1)
+ #:use-module (system foreign)
+ #:export (sdl-init
+ sdl-quit))
+
+(define* (sdl-init #:optional (subsystems '(audio video joystick haptic gamepad events sensor camera)))
+ "Initialize SDL @var{subsystems}, a list of symbols. By default, all
+subsystems are initialized.
+
+Valid subsystem names are:
+
+@itemize
+@item @code{audio}
+@item @code{video}
+@item @code{joystick}
+@item @code{haptic}
+@item @code{gamepad}
+@item @code{events}
+@item @code{sensor}
+@item @code{camera}
+@end itemize"
+ (sdl-assert 'sdl-init
+ (SDL_Init
+ (fold (lambda (name prev)
+ (logior (match name
+ ('audio SDL_INIT_AUDIO)
+ ('video SDL_INIT_VIDEO)
+ ('joystick SDL_INIT_JOYSTICK)
+ ('haptic SDL_INIT_HAPTIC)
+ ('gamepad SDL_INIT_GAMEPAD)
+ ('events SDL_INIT_EVENTS)
+ ('sensor SDL_INIT_SENSOR)
+ ('camera SDL_INIT_CAMERA)
+ (_ (raise (make-sdl-error 'sdl-init
+ #:message "invalid subsystem name"
+ #:irritants (list name)))))
+ prev))
+ 0 subsystems))))
+
+(define (sdl-quit)
+ "Clean up all initialized subsystems."
+ (SDL_Quit))
diff --git a/sdl3/bindings/error.scm b/sdl3/bindings/error.scm
new file mode 100644
index 0000000..71e5885
--- /dev/null
+++ b/sdl3/bindings/error.scm
@@ -0,0 +1,26 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; Low-level bindings for SDL_error.h.
+;;
+;;; Code:
+
+(define-module (sdl3 bindings error)
+ #:use-module (sdl3 bindings utils)
+ #:export (SDL_GetError))
+
+(define-sdl SDL_GetError -> '*)
diff --git a/sdl3/bindings/gpu.scm b/sdl3/bindings/gpu.scm
new file mode 100644
index 0000000..6de7ef4
--- /dev/null
+++ b/sdl3/bindings/gpu.scm
@@ -0,0 +1,62 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; Low-level bindings for SDL_gpu.h.
+;;
+;;; Code:
+
+(define-module (sdl3 bindings gpu)
+ #:use-module (sdl3 bindings utils)
+ #:use-module (system foreign)
+ #:export (;; SDL_gpu.h
+ SDL_GPUShaderFormat
+ SDL_GPU_SHADERFORMAT_INVALID
+ SDL_GPU_SHADERFORMAT_PRIVATE
+ SDL_GPU_SHADERFORMAT_SPIRV
+ SDL_GPU_SHADERFORMAT_DXBC
+ SDL_GPU_SHADERFORMAT_DXIL
+ SDL_GPU_SHADERFORMAT_MSL
+ SDL_GPU_SHADERFORMAT_METALLIB
+
+ gpu-device?
+ wrap-gpu-device
+ unwrap-gpu-device
+ gpu-device-destroyed?
+ set-gpu-device-destroyed!
+
+ SDL_CreateGPUDevice
+ SDL_DestroyGPUDevice
+ SDL_ClaimWindowForGPUDevice))
+
+(define SDL_GPUShaderFormat uint32)
+(define SDL_GPU_SHADERFORMAT_INVALID 0)
+(define SDL_GPU_SHADERFORMAT_PRIVATE 1)
+(define SDL_GPU_SHADERFORMAT_SPIRV 2)
+(define SDL_GPU_SHADERFORMAT_DXBC 4)
+(define SDL_GPU_SHADERFORMAT_DXIL 8)
+(define SDL_GPU_SHADERFORMAT_MSL 16)
+(define SDL_GPU_SHADERFORMAT_METALLIB 32)
+
+(define-sdl-pointer-type <gpu-device>
+ gpu-device? wrap-gpu-device unwrap-gpu-device
+ gpu-device-destroyed? set-gpu-device-destroyed!
+ (lambda (device port)
+ (display "#<gpu-device>" port)))
+
+(define-sdl SDL_CreateGPUDevice SDL_GPUShaderFormat bool '* -> '*)
+(define-sdl SDL_DestroyGPUDevice '*)
+(define-sdl SDL_ClaimWindowForGPUDevice '* '* -> bool)
diff --git a/sdl3/bindings/init.scm b/sdl3/bindings/init.scm
new file mode 100644
index 0000000..ac92829
--- /dev/null
+++ b/sdl3/bindings/init.scm
@@ -0,0 +1,49 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; Low-level bindings for SDL_init.h.
+;;
+;;; Code:
+
+(define-module (sdl3 bindings init)
+ #:use-module (sdl3 bindings utils)
+ #:use-module (system foreign)
+ #:export (SDL_InitFlags
+ SDL_INIT_AUDIO
+ SDL_INIT_VIDEO
+ SDL_INIT_JOYSTICK
+ SDL_INIT_HAPTIC
+ SDL_INIT_GAMEPAD
+ SDL_INIT_EVENTS
+ SDL_INIT_SENSOR
+ SDL_INIT_CAMERA
+
+ SDL_Init
+ SDL_Quit))
+
+(define SDL_InitFlags uint32)
+(define SDL_INIT_AUDIO #x00000010)
+(define SDL_INIT_VIDEO #x00000020)
+(define SDL_INIT_JOYSTICK #x00000200)
+(define SDL_INIT_HAPTIC #x00001000)
+(define SDL_INIT_GAMEPAD #x00002000)
+(define SDL_INIT_EVENTS #x00004000)
+(define SDL_INIT_SENSOR #x00008000)
+(define SDL_INIT_CAMERA #x00010000)
+
+(define-sdl SDL_Init SDL_InitFlags -> bool)
+(define-sdl SDL_Quit)
diff --git a/sdl3/bindings/utils.scm b/sdl3/bindings/utils.scm
new file mode 100644
index 0000000..738f2bc
--- /dev/null
+++ b/sdl3/bindings/utils.scm
@@ -0,0 +1,60 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; Low-level FFI binding utilities.
+;;
+;;; Code:
+
+(define-module (sdl3 bindings utils)
+ #:use-module (sdl3 config)
+ #:use-module (sdl3 guardian)
+ #:use-module (srfi srfi-9)
+ #:use-module (srfi srfi-9 gnu)
+ #:use-module (system foreign)
+ #:use-module (system foreign-library)
+ #:export (bool
+ define-sdl
+ define-sdl-pointer-type))
+
+;; Type aliases:
+(define bool uint8)
+
+(define-syntax define-sdl
+ (lambda (stx)
+ (syntax-case stx (->)
+ ((_ name arg-type ... -> return-type)
+ #`(define name
+ (foreign-library-function %libsdl3
+ #,(symbol->string (syntax->datum #'name))
+ #:arg-types (list arg-type ...)
+ #:return-type return-type)))
+ ((_ name arg-type ...)
+ #'(define-sdl name arg-type ... -> void)))))
+
+(define-syntax-rule (define-sdl-pointer-type name
+ pred wrap unwrap
+ destroyed-pred set-destroyed
+ print)
+ (begin
+ (define-record-type name
+ (ctor ptr)
+ pred
+ (ptr unwrap)
+ (destroyed? destroyed-pred set-destroyed))
+ (define (wrap ptr)
+ (sdl-protect (ctor ptr)))
+ (set-record-type-printer! name print)))
diff --git a/sdl3/bindings/video.scm b/sdl3/bindings/video.scm
new file mode 100644
index 0000000..a9c55ac
--- /dev/null
+++ b/sdl3/bindings/video.scm
@@ -0,0 +1,95 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; Low-level bindings for SDL_video.h.
+;;
+;;; Code:
+
+(define-module (sdl3 bindings video)
+ #:use-module (sdl3 bindings utils)
+ #:use-module (system foreign)
+ #:export (SDL_WindowFlags
+ SDL_WINDOW_FULLSCREEN
+ SDL_WINDOW_OPENGL
+ SDL_WINDOW_OCCLUDED
+ SDL_WINDOW_HIDDEN
+ SDL_WINDOW_BORDERLESS
+ SDL_WINDOW_RESIZABLE
+ SDL_WINDOW_MINIMIZED
+ SDL_WINDOW_MAXIMIZED
+ SDL_WINDOW_MOUSE_GRABBED
+ SDL_WINDOW_INPUT_FOCUS
+ SDL_WINDOW_MOUSE_FOCUS
+ SDL_WINDOW_EXTERNAL
+ SDL_WINDOW_MODAL
+ SDL_WINDOW_HIGH_PIXEL_DENSITY
+ SDL_WINDOW_MOUSE_CAPTURE
+ SDL_WINDOW_MOUSE_RELATIVE_MODE
+ SDL_WINDOW_ALWAYS_ON_TOP
+ SDL_WINDOW_UTILITY
+ SDL_WINDOW_TOOLTIP
+ SDL_WINDOW_POPUP_MENU
+ SDL_WINDOW_KEYBOARD_GRABBED
+ SDL_WINDOW_VULKAN
+ SDL_WINDOW_METAL
+ SDL_WINDOW_TRANSPARENT
+ SDL_WINDOW_NOT_FOCUSABLE
+
+ window?
+ wrap-window
+ unwrap-window
+ window-destroyed?
+ set-window-destroyed!
+
+ SDL_CreateWindow
+ SDL_DestroyWindow))
+
+(define SDL_WindowFlags uint64)
+(define SDL_WINDOW_FULLSCREEN #x0000000000000001)
+(define SDL_WINDOW_OPENGL #x0000000000000002)
+(define SDL_WINDOW_OCCLUDED #x0000000000000004)
+(define SDL_WINDOW_HIDDEN #x0000000000000008)
+(define SDL_WINDOW_BORDERLESS #x0000000000000010)
+(define SDL_WINDOW_RESIZABLE #x0000000000000020)
+(define SDL_WINDOW_MINIMIZED #x0000000000000040)
+(define SDL_WINDOW_MAXIMIZED #x0000000000000080)
+(define SDL_WINDOW_MOUSE_GRABBED #x0000000000000100)
+(define SDL_WINDOW_INPUT_FOCUS #x0000000000000200)
+(define SDL_WINDOW_MOUSE_FOCUS #x0000000000000400)
+(define SDL_WINDOW_EXTERNAL #x0000000000000800)
+(define SDL_WINDOW_MODAL #x0000000000001000)
+(define SDL_WINDOW_HIGH_PIXEL_DENSITY #x0000000000002000)
+(define SDL_WINDOW_MOUSE_CAPTURE #x0000000000004000)
+(define SDL_WINDOW_MOUSE_RELATIVE_MODE #x0000000000008000)
+(define SDL_WINDOW_ALWAYS_ON_TOP #x0000000000010000)
+(define SDL_WINDOW_UTILITY #x0000000000020000)
+(define SDL_WINDOW_TOOLTIP #x0000000000040000)
+(define SDL_WINDOW_POPUP_MENU #x0000000000080000)
+(define SDL_WINDOW_KEYBOARD_GRABBED #x0000000000100000)
+(define SDL_WINDOW_VULKAN #x0000000010000000)
+(define SDL_WINDOW_METAL #x0000000020000000)
+(define SDL_WINDOW_TRANSPARENT #x0000000040000000)
+(define SDL_WINDOW_NOT_FOCUSABLE #x0000000080000000)
+
+(define-sdl-pointer-type <window>
+ window? wrap-window unwrap-window
+ window-destroyed? set-window-destroyed!
+ (lambda (window port)
+ (display "#<window>" port)))
+
+(define-sdl SDL_CreateWindow '* int int SDL_WindowFlags -> '*)
+(define-sdl SDL_DestroyWindow '*)
diff --git a/sdl3/config.scm.in b/sdl3/config.scm.in
new file mode 100644
index 0000000..af6c8e1
--- /dev/null
+++ b/sdl3/config.scm.in
@@ -0,0 +1,22 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+(define-module (sdl3 config)
+ #:export (%libsdl3))
+
+(define %libsdl3
+ "/gnu/store/5z28wrn3f770x3myhcmfki5zdyjbg9r7-sdl3-2.30.1/lib/libSDL3.so.0.1.2"
+ ;; "@SDL3_LIBDIR@/libSDL3"
+ )
diff --git a/sdl3/errors.scm b/sdl3/errors.scm
new file mode 100644
index 0000000..3d48647
--- /dev/null
+++ b/sdl3/errors.scm
@@ -0,0 +1,54 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; SDL3 errors.
+;;
+;;; Code:
+
+(define-module (sdl3 errors)
+ #:use-module (ice-9 exceptions)
+ #:use-module (sdl3 bindings error)
+ #:use-module (system foreign)
+ #:export (sdl-get-error
+ make-sdl-error
+ sdl-assert
+ sdl-assert-non-null))
+
+(define (sdl-get-error)
+ (pointer->string (SDL_GetError)))
+
+(define-exception-type &sdl-exception &error
+ make-sdl-exception
+ sdl-exception?)
+
+(define* (make-sdl-error origin #:key
+ (message (sdl-get-error))
+ (irritants '()))
+ (make-exception
+ (make-sdl-exception)
+ (make-exception-with-message message)
+ (make-exception-with-irritants irritants)
+ (make-exception-with-origin origin)))
+
+(define (sdl-assert origin bool)
+ (unless (eq? bool 1)
+ (raise-exception (make-sdl-error origin))))
+
+(define (sdl-assert-non-null origin pointer)
+ (when (null-pointer? pointer)
+ (raise-exception (make-sdl-error origin)))
+ pointer)
diff --git a/sdl3/gpu.scm b/sdl3/gpu.scm
new file mode 100644
index 0000000..d1129f3
--- /dev/null
+++ b/sdl3/gpu.scm
@@ -0,0 +1,63 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; SDL3 3D rendering and GPU compute.
+;;
+;;; Code:
+
+(define-module (sdl3 gpu)
+ #:use-module (ice-9 match)
+ #:use-module (sdl3 bindings gpu)
+ #:use-module (sdl3 bindings video)
+ #:use-module (sdl3 errors)
+ #:use-module (srfi srfi-1)
+ #:use-module (system foreign)
+ #:export (make-gpu-device
+ destroy-gpu-device!
+ claim-window-for-gpu-device!)
+ #:re-export (gpu-device?
+ gpu-device-destroyed?))
+
+(define* (make-gpu-device shader-formats #:key debug? driver)
+ (wrap-gpu-device
+ (sdl-assert-non-null
+ 'make-gpu-device
+ (SDL_CreateGPUDevice (fold (lambda (format prev)
+ (logior (match format
+ ('private SDL_GPU_SHADERFORMAT_PRIVATE)
+ ('spirv SDL_GPU_SHADERFORMAT_SPIRV)
+ ('dxbc SDL_GPU_SHADERFORMAT_DXBC)
+ ('dxil SDL_GPU_SHADERFORMAT_DXIL)
+ ('msl SDL_GPU_SHADERFORMAT_MSL)
+ ('metallib SDL_GPU_SHADERFORMAT_METALLIB))
+ prev))
+ 0 shader-formats)
+ (if debug? 1 0)
+ (if driver
+ (string->pointer driver)
+ %null-pointer)))))
+
+(define (destroy-gpu-device! device)
+ (unless (gpu-device-destroyed? device)
+ (SDL_DestroyGPUDevice (unwrap-gpu-device device))
+ (set-gpu-device-destroyed! device #t)))
+
+(define (claim-window-for-gpu-device! device window)
+ (sdl-assert
+ 'claim-window-for-gpu-device!
+ (SDL_ClaimWindowForGPUDevice (unwrap-gpu-device device)
+ (unwrap-window window))))
diff --git a/sdl3/guardian.scm b/sdl3/guardian.scm
new file mode 100644
index 0000000..d0a812b
--- /dev/null
+++ b/sdl3/guardian.scm
@@ -0,0 +1,30 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; SDL3 foreign object guardian.
+;;
+;;; Code:
+
+(define-module (sdl3 guardian)
+ #:export (sdl-guardian
+ sdl-protect))
+
+(define sdl-guardian (make-guardian))
+
+(define (sdl-protect obj)
+ (sdl-guardian obj)
+ obj)
diff --git a/sdl3/video.scm b/sdl3/video.scm
new file mode 100644
index 0000000..20cfd2d
--- /dev/null
+++ b/sdl3/video.scm
@@ -0,0 +1,72 @@
+;;; guile-sdl3 -- Scheme bindings for SDL3
+;;; Copyright © 2024 David Thompson <dthompson2@worcester.edu>
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Commentary:
+;;
+;; SDL3 display and window management.
+;;
+;;; Code:
+
+(define-module (sdl3 video)
+ #:use-module (sdl3 bindings video)
+ #:use-module (sdl3 errors)
+ #:use-module (system foreign)
+ #:export (make-window
+ destroy-window!)
+ #:re-export (window?
+ window-destroyed?))
+
+(define* (make-window title width height #:key
+ opengl?
+ vulkan?
+ metal?
+ (shown? #t)
+ fullscreen?
+ borderless?
+ transparent?
+ resizable?
+ (focusable? #t)
+ high-pixel-density?
+ always-on-top?
+ utility?)
+ "Open a window with the specified @var{title} and dimensions
+@var{width} by @var{height} pixels and return a handle to that window."
+ (wrap-window
+ (sdl-assert-non-null
+ 'make-window
+ (SDL_CreateWindow (string->pointer title)
+ width height
+ (logior
+ (if opengl? SDL_WINDOW_OPENGL 0)
+ (if vulkan? SDL_WINDOW_VULKAN 0)
+ (if metal? SDL_WINDOW_METAL 0)
+ (if fullscreen? SDL_WINDOW_FULLSCREEN 0)
+ (if shown? 0 SDL_WINDOW_HIDDEN)
+ (if borderless? SDL_WINDOW_BORDERLESS 0)
+ (if transparent? SDL_WINDOW_TRANSPARENT 0)
+ (if resizable? SDL_WINDOW_RESIZABLE 0)
+ (if focusable? 0 SDL_WINDOW_NOT_FOCUSABLE)
+ (if high-pixel-density? SDL_WINDOW_HIGH_PIXEL_DENSITY 0)
+ (if always-on-top? SDL_WINDOW_ALWAYS_ON_TOP 0)
+ (if utility? SDL_WINDOW_UTILITY 0))))))
+
+;; FIXME: SDL_DestroyWindow recursively destroys child windows. Do we
+;; need to keep track of those in Scheme, then?
+(define (destroy-window! window)
+ "Close @var{window} and make handle unusable for further window
+management calls."
+ (unless (window-destroyed? window)
+ (SDL_DestroyWindow (unwrap-window window))
+ (set-window-destroyed! window #t)))