diff options
Diffstat (limited to 'sdl3/bindings')
-rw-r--r-- | sdl3/bindings/error.scm | 26 | ||||
-rw-r--r-- | sdl3/bindings/events.scm | 750 | ||||
-rw-r--r-- | sdl3/bindings/gpu.scm | 1202 | ||||
-rw-r--r-- | sdl3/bindings/init.scm | 49 | ||||
-rw-r--r-- | sdl3/bindings/pixels.scm | 41 | ||||
-rw-r--r-- | sdl3/bindings/surface.scm | 36 | ||||
-rw-r--r-- | sdl3/bindings/utils.scm | 133 | ||||
-rw-r--r-- | sdl3/bindings/video.scm | 103 |
8 files changed, 2340 insertions, 0 deletions
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/events.scm b/sdl3/bindings/events.scm new file mode 100644 index 0000000..c27be68 --- /dev/null +++ b/sdl3/bindings/events.scm @@ -0,0 +1,750 @@ +;;; 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 events) + #:use-module (bstruct) + #:use-module (sdl3 bindings utils) + #:use-module (system foreign) + #:export (SDL_EventType + symbol->event-type + event-type->symbol + SDL_EVENT_FIRST + SDL_EVENT_QUIT + SDL_EVENT_TERMINATING + SDL_EVENT_LOW_MEMORY + SDL_EVENT_WILL_ENTER_BACKGROUND + SDL_EVENT_DID_ENTER_BACKGROUND + SDL_EVENT_WILL_ENTER_FOREGROUND + SDL_EVENT_DID_ENTER_FOREGROUND + SDL_EVENT_LOCALE_CHANGED + SDL_EVENT_SYSTEM_THEME_CHANGED + SDL_EVENT_DISPLAY_ORIENTATION + SDL_EVENT_DISPLAY_ADDED + SDL_EVENT_DISPLAY_REMOVED + SDL_EVENT_DISPLAY_MOVED + SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED + SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED + SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED + SDL_EVENT_WINDOW_SHOWN + SDL_EVENT_WINDOW_HIDDEN + SDL_EVENT_WINDOW_EXPOSED + SDL_EVENT_WINDOW_MOVED + SDL_EVENT_WINDOW_RESIZED + SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED + SDL_EVENT_WINDOW_METAL_VIEW_RESIZED + SDL_EVENT_WINDOW_MINIMIZED + SDL_EVENT_WINDOW_MAXIMIZED + SDL_EVENT_WINDOW_RESTORED + SDL_EVENT_WINDOW_MOUSE_ENTER + SDL_EVENT_WINDOW_MOUSE_LEAVE + SDL_EVENT_WINDOW_FOCUS_GAINED + SDL_EVENT_WINDOW_FOCUS_LOST + SDL_EVENT_WINDOW_CLOSE_REQUESTED + SDL_EVENT_WINDOW_HIT_TEST + SDL_EVENT_WINDOW_ICCPROF_CHANGED + SDL_EVENT_WINDOW_DISPLAY_CHANGED + SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED + SDL_EVENT_WINDOW_SAFE_AREA_CHANGED + SDL_EVENT_WINDOW_OCCLUDED + SDL_EVENT_WINDOW_ENTER_FULLSCREEN + SDL_EVENT_WINDOW_LEAVE_FULLSCREEN + SDL_EVENT_WINDOW_DESTROYED + SDL_EVENT_WINDOW_HDR_STATE_CHANGED + SDL_EVENT_KEY_DOWN + SDL_EVENT_KEY_UP + SDL_EVENT_TEXT_EDITING + SDL_EVENT_TEXT_INPUT + SDL_EVENT_KEYMAP_CHANGED + SDL_EVENT_KEYBOARD_ADDED + SDL_EVENT_KEYBOARD_REMOVED + SDL_EVENT_TEXT_EDITING_CANDIDATES + SDL_EVENT_MOUSE_MOTION + SDL_EVENT_MOUSE_BUTTON_DOWN + SDL_EVENT_MOUSE_BUTTON_UP + SDL_EVENT_MOUSE_WHEEL + SDL_EVENT_MOUSE_ADDED + SDL_EVENT_MOUSE_REMOVED + SDL_EVENT_JOYSTICK_AXIS_MOTION + SDL_EVENT_JOYSTICK_BALL_MOTION + SDL_EVENT_JOYSTICK_HAT_MOTION + SDL_EVENT_JOYSTICK_BUTTON_DOWN + SDL_EVENT_JOYSTICK_BUTTON_UP + SDL_EVENT_JOYSTICK_ADDED + SDL_EVENT_JOYSTICK_REMOVED + SDL_EVENT_JOYSTICK_BATTERY_UPDATED + SDL_EVENT_JOYSTICK_UPDATE_COMPLETE + SDL_EVENT_GAMEPAD_AXIS_MOTION + SDL_EVENT_GAMEPAD_BUTTON_DOWN + SDL_EVENT_GAMEPAD_BUTTON_UP + SDL_EVENT_GAMEPAD_ADDED + SDL_EVENT_GAMEPAD_REMOVED + SDL_EVENT_GAMEPAD_REMAPPED + SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN + SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION + SDL_EVENT_GAMEPAD_TOUCHPAD_UP + SDL_EVENT_GAMEPAD_SENSOR_UPDATE + SDL_EVENT_GAMEPAD_UPDATE_COMPLETE + SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED + SDL_EVENT_FINGER_DOWN + SDL_EVENT_FINGER_UP + SDL_EVENT_FINGER_MOTION + SDL_EVENT_CLIPBOARD_UPDATE + SDL_EVENT_DROP_FILE + SDL_EVENT_DROP_TEXT + SDL_EVENT_DROP_BEGIN + SDL_EVENT_DROP_COMPLETE + SDL_EVENT_DROP_POSITION + SDL_EVENT_AUDIO_DEVICE_ADDED + SDL_EVENT_AUDIO_DEVICE_REMOVED + SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED + SDL_EVENT_SENSOR_UPDATE + SDL_EVENT_PEN_PROXIMITY_IN + SDL_EVENT_PEN_PROXIMITY_OUT + SDL_EVENT_PEN_DOWN + SDL_EVENT_PEN_UP + SDL_EVENT_PEN_BUTTON_DOWN + SDL_EVENT_PEN_BUTTON_UP + SDL_EVENT_PEN_MOTION + SDL_EVENT_PEN_AXIS + SDL_EVENT_CAMERA_DEVICE_ADDED + SDL_EVENT_CAMERA_DEVICE_REMOVED + SDL_EVENT_CAMERA_DEVICE_APPROVED + SDL_EVENT_CAMERA_DEVICE_DENIED + SDL_EVENT_RENDER_TARGETS_RESET + SDL_EVENT_RENDER_DEVICE_RESET + SDL_EVENT_POLL_SENTINEL + SDL_EVENT_DISPLAY_FIRST + SDL_EVENT_DISPLAY_LAST + SDL_EVENT_WINDOW_FIRST + SDL_EVENT_WINDOW_LAST + SDL_EVENT_USER + SDL_EVENT_LAST + SDL_EVENT_ENUM_PADDING + + SDL_CommonEvent + SDL_DisplayEvent + SDL_WindowEvent + SDL_KeyboardDeviceEvent + SDL_KeyboardEvent + SDL_TextEditingEvent + SDL_TextEditingCandidatesEvent + SDL_TextInputEvent + SDL_MouseDeviceEvent + SDL_MouseMotionEvent + SDL_MouseButtonEvent + SDL_MouseWheelEvent + SDL_JoyAxisEvent + SDL_JoyBallEvent + SDL_JoyHatEvent + SDL_JoyButtonEvent + SDL_JoyDeviceEvent + SDL_JoyBatteryEvent + SDL_GamepadAxisEvent + SDL_GamepadButtonEvent + SDL_GamepadDeviceEvent + SDL_GamepadTouchpadEvent + SDL_GamepadSensorEvent + SDL_AudioDeviceEvent + SDL_CameraDeviceEvent + SDL_TouchFingerEvent + SDL_PenProximityEvent + SDL_PenMotionEvent + SDL_PenTouchEvent + SDL_PenButtonEvent + SDL_PenAxisEvent + SDL_DropEvent + SDL_ClipboardEvent + SDL_SensorEvent + SDL_QuitEvent + SDL_UserEvent + SDL_Event + + SDL_PumpEvents + SDL_HasEvent + SDL_HasEvents + SDL_FlushEvent + SDL_FlushEvents + SDL_PollEvent + SDL_WaitEvent + SDL_WaitEventTimeout + SDL_PushEvent)) + +(define-enum SDL_EventType + symbol->event-type + event-type->symbol + (first SDL_EVENT_FIRST) + (quit SDL_EVENT_QUIT #x100) + (terminating SDL_EVENT_TERMINATING) + (low-memory SDL_EVENT_LOW_MEMORY) + (will-enter-background SDL_EVENT_WILL_ENTER_BACKGROUND) + (did-enter-background SDL_EVENT_DID_ENTER_BACKGROUND) + (will-enter-foreground SDL_EVENT_WILL_ENTER_FOREGROUND) + (did-enter-foreground SDL_EVENT_DID_ENTER_FOREGROUND) + (locale-changed SDL_EVENT_LOCALE_CHANGED) + (system-theme-changed SDL_EVENT_SYSTEM_THEME_CHANGED) + (display-orientation SDL_EVENT_DISPLAY_ORIENTATION #x151) + (display-added SDL_EVENT_DISPLAY_ADDED) + (display-removed SDL_EVENT_DISPLAY_REMOVED) + (display-moved SDL_EVENT_DISPLAY_MOVED) + (display-desktop-mode-changed SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED) + (display-current-mode-changed SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED) + (display-content-scale-changed SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED) + (window-shown SDL_EVENT_WINDOW_SHOWN #x202) + (window-hidden SDL_EVENT_WINDOW_HIDDEN) + (window-exposed SDL_EVENT_WINDOW_EXPOSED) + (window-moved SDL_EVENT_WINDOW_MOVED) + (window-resized SDL_EVENT_WINDOW_RESIZED) + (window-pixel-size-changed SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) + (window-metal-view-resized SDL_EVENT_WINDOW_METAL_VIEW_RESIZED) + (window-minimized SDL_EVENT_WINDOW_MINIMIZED) + (window-maximized SDL_EVENT_WINDOW_MAXIMIZED) + (window-restored SDL_EVENT_WINDOW_RESTORED) + (window-mouse-enter SDL_EVENT_WINDOW_MOUSE_ENTER) + (window-mouse-leave SDL_EVENT_WINDOW_MOUSE_LEAVE) + (window-focus-gained SDL_EVENT_WINDOW_FOCUS_GAINED) + (window-focus-lost SDL_EVENT_WINDOW_FOCUS_LOST) + (window-close-requested SDL_EVENT_WINDOW_CLOSE_REQUESTED) + (window-hit-test SDL_EVENT_WINDOW_HIT_TEST) + (window-iccprof-changed SDL_EVENT_WINDOW_ICCPROF_CHANGED) + (window-display-changed SDL_EVENT_WINDOW_DISPLAY_CHANGED) + (window-display-scale-changed SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED) + (window-safe-area-changed SDL_EVENT_WINDOW_SAFE_AREA_CHANGED) + (window-occluded SDL_EVENT_WINDOW_OCCLUDED) + (window-enter-fullscreen SDL_EVENT_WINDOW_ENTER_FULLSCREEN) + (window-leave-fullscreen SDL_EVENT_WINDOW_LEAVE_FULLSCREEN) + (window-destroyed SDL_EVENT_WINDOW_DESTROYED) + (window-hdr-state-changed SDL_EVENT_WINDOW_HDR_STATE_CHANGED) + (key-down SDL_EVENT_KEY_DOWN #x300) + (key-up SDL_EVENT_KEY_UP) + (text-editing SDL_EVENT_TEXT_EDITING) + (text-input SDL_EVENT_TEXT_INPUT) + (keymap-changed SDL_EVENT_KEYMAP_CHANGED) + (keyboard-added SDL_EVENT_KEYBOARD_ADDED) + (keyboard-removed SDL_EVENT_KEYBOARD_REMOVED) + (text-editing-candidates SDL_EVENT_TEXT_EDITING_CANDIDATES) + (mouse-motion SDL_EVENT_MOUSE_MOTION #x400) + (mouse-button-down SDL_EVENT_MOUSE_BUTTON_DOWN) + (mouse-button-up SDL_EVENT_MOUSE_BUTTON_UP) + (mouse-wheel SDL_EVENT_MOUSE_WHEEL) + (mouse-added SDL_EVENT_MOUSE_ADDED) + (mouse-removed SDL_EVENT_MOUSE_REMOVED) + (joystick-axis-motion SDL_EVENT_JOYSTICK_AXIS_MOTION #x600) + (joystick-ball-motion SDL_EVENT_JOYSTICK_BALL_MOTION) + (joystick-hat-motion SDL_EVENT_JOYSTICK_HAT_MOTION) + (joystick-button-down SDL_EVENT_JOYSTICK_BUTTON_DOWN) + (joystick-button-up SDL_EVENT_JOYSTICK_BUTTON_UP) + (joystick-added SDL_EVENT_JOYSTICK_ADDED) + (joystick-removed SDL_EVENT_JOYSTICK_REMOVED) + (joystick-battery-updated SDL_EVENT_JOYSTICK_BATTERY_UPDATED) + (joystick-update-complete SDL_EVENT_JOYSTICK_UPDATE_COMPLETE) + (gamepad-axis-motion SDL_EVENT_GAMEPAD_AXIS_MOTION #x650) + (gamepad-button-down SDL_EVENT_GAMEPAD_BUTTON_DOWN) + (gamepad-button-up SDL_EVENT_GAMEPAD_BUTTON_UP) + (gamepad-added SDL_EVENT_GAMEPAD_ADDED) + (gamepad-removed SDL_EVENT_GAMEPAD_REMOVED) + (gamepad-remapped SDL_EVENT_GAMEPAD_REMAPPED) + (gamepad-touchpad-down SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN) + (gamepad-touchpad-motion SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION) + (gamepad-touchpad-up SDL_EVENT_GAMEPAD_TOUCHPAD_UP) + (gamepad-sensor-update SDL_EVENT_GAMEPAD_SENSOR_UPDATE) + (gamepad-update-complete SDL_EVENT_GAMEPAD_UPDATE_COMPLETE) + (gamepad-steam-handle-updated SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED) + (finger-down SDL_EVENT_FINGER_DOWN #x700) + (finger-up SDL_EVENT_FINGER_UP) + (finger-motion SDL_EVENT_FINGER_MOTION) + (clipboard-update SDL_EVENT_CLIPBOARD_UPDATE #x900) + (drop-file SDL_EVENT_DROP_FILE #x1000) + (drop-text SDL_EVENT_DROP_TEXT) + (drop-begin SDL_EVENT_DROP_BEGIN) + (drop-complete SDL_EVENT_DROP_COMPLETE) + (drop-position SDL_EVENT_DROP_POSITION) + (audio-device-added SDL_EVENT_AUDIO_DEVICE_ADDED #x1100) + (audio-device-removed SDL_EVENT_AUDIO_DEVICE_REMOVED) + (audio-device-format-changed SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED) + (sensor-update SDL_EVENT_SENSOR_UPDATE #x1200) + (pen-proximity-in SDL_EVENT_PEN_PROXIMITY_IN #x1300) + (pen-proximity-out SDL_EVENT_PEN_PROXIMITY_OUT) + (pen-down SDL_EVENT_PEN_DOWN) + (pen-up SDL_EVENT_PEN_UP) + (pen-button-down SDL_EVENT_PEN_BUTTON_DOWN) + (pen-button-up SDL_EVENT_PEN_BUTTON_UP) + (pen-motion SDL_EVENT_PEN_MOTION) + (pen-axis SDL_EVENT_PEN_AXIS) + (camera-device-added SDL_EVENT_CAMERA_DEVICE_ADDED #x1400) + (camera-device-removed SDL_EVENT_CAMERA_DEVICE_REMOVED) + (camera-device-approved SDL_EVENT_CAMERA_DEVICE_APPROVED) + (camera-device-denied SDL_EVENT_CAMERA_DEVICE_DENIED) + (render-targets-reset SDL_EVENT_RENDER_TARGETS_RESET #x2000) + (render-device-reset SDL_EVENT_RENDER_DEVICE_RESET) + (poll-sentinel SDL_EVENT_POLL_SENTINEL #x7F00)) + +(define SDL_EVENT_DISPLAY_FIRST SDL_EVENT_DISPLAY_ORIENTATION) +(define SDL_EVENT_DISPLAY_LAST SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED) +(define SDL_EVENT_WINDOW_FIRST SDL_EVENT_WINDOW_SHOWN) +(define SDL_EVENT_WINDOW_LAST SDL_EVENT_WINDOW_HDR_STATE_CHANGED) +(define SDL_EVENT_USER #x8000) +(define SDL_EVENT_LAST #xFFFF) +(define SDL_EVENT_ENUM_PADDING #x7FFFFFFF) + +(define-bstruct SDL_CommonEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64))) + +(define-bstruct SDL_DisplayEvent + (struct + (type int) ; SDL_EventType + (reserved uint32) + (timestamp uint64) + (displayID uint32) ; SDL_DisplayID + (data1 int32) + (data2 int32))) + +(define-bstruct SDL_WindowEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (data1 int32) + (data2 int32))) + +(define-bstruct SDL_KeyboardDeviceEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_KeyboardID + )) + +(define-bstruct SDL_KeyboardEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_KeyboardID + (scancode int) ; SDL_Scancode + (key int) ; SDL_Keycode + (mod uint16) ; SDL_Keymod + (raw uint16) + (down uint8) ; bool + (repeat uint8) ; bool + )) + +(define-bstruct SDL_TextEditingEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (text (* uint8)) ; char* + (start int32) + (length int32))) + +(define-bstruct SDL_TextEditingCandidatesEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (candidates (* uint8)) + (num_candidates int32) + (selected_candidate int32) + (horizontal uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_TextInputEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (text (* uint8)))) + +(define-bstruct SDL_MouseDeviceEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_MouseID + )) + +(define-bstruct SDL_MouseMotionEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_MouseID + (state uint32) ; SDL_MouseButtonFlags + (x float) + (y float) + (xrel float) + (yrel float))) + +(define-bstruct SDL_MouseButtonEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_MouseID + (button uint8) + (down uint8) ; bool + (clicks uint8) + (_ uint8) + (x float) + (y float))) + +(define-bstruct SDL_MouseWheelEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_MouseID + (x float) + (y float) + (direction int) ; SDL_MouseWheelDirection + (mouse_x float) + (mouse_y float))) + +(define-bstruct SDL_JoyAxisEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (axis uint8) + (_ uint8) + (_ uint8) + (_ uint8) + (value int16) + (_ uint16))) + +(define-bstruct SDL_JoyBallEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (ball uint8) + (_ uint8) + (_ uint8) + (_ uint8) + (xrel int32) + (yrel int32))) + +(define-bstruct SDL_JoyHatEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (hat uint8) + (value uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_JoyButtonEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (button uint8) + (down uint8) ; bool + (_ uint8) + (_ uint8) + )) + +(define-bstruct SDL_JoyDeviceEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + )) + +(define-bstruct SDL_JoyBatteryEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (state int) ; SDL_PowerState + (percent int))) + +(define-bstruct SDL_GamepadAxisEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (axis uint8) + (_ uint8) + (_ uint8) + (_ uint8) + (value int16) + (_ uint16))) + +(define-bstruct SDL_GamepadButtonEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (button uint8) + (down uint8) ; bool + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GamepadDeviceEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + )) + +(define-bstruct SDL_GamepadTouchpadEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (touchpad int32) + (finger int32) + (x float) + (y float) + (pressure float))) + +(define-bstruct SDL_GamepadSensorEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_JoystickID + (sensor int32) + (data (array 3 float)) + (sensor_timestamp uint64))) + +(define-bstruct SDL_AudioDeviceEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_AudioDeviceID + (recording uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_CameraDeviceEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_CameraID + )) + +(define-bstruct SDL_TouchFingerEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (touchID uint32) ; SDL_TouchID + (fingerID uint32) ; SDL_FingerID + (x float) + (y float) + (dx float) + (dy float) + (pressure float) + (windowID uint32) ; SDL_WindowID + )) + +(define-bstruct SDL_PenProximityEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_PenID + )) + +(define-bstruct SDL_PenMotionEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_PenID + (pen_state uint32) ; SDL_PenInputFlags + )) + +(define-bstruct SDL_PenTouchEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_PenID + (pen_state uint32) ; SDL_PenInputFlags + (x float) + (y float) + (eraser uint8) ; bool + (down uint8) ; bool + )) + +(define-bstruct SDL_PenButtonEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_PenID + (pen_state uint32) ; SDL_PenInputFlags + (x float) + (y float) + (button uint8) + (down uint8) ; bool + )) + +(define-bstruct SDL_PenAxisEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (which uint32) ; SDL_PenID + (pen_state uint32) ; SDL_PenInputFlags + (x float) + (y float) + (axis int) ; SDL_PenAxis + (value float))) + +(define-bstruct SDL_DropEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (x float) + (y float) + (source (* uint8)) ; char* + (data (* uint8)) ; char* + )) + +(define-bstruct SDL_ClipboardEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64))) + +(define-bstruct SDL_SensorEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (which uint32) ; SDL_SensorID + (data (array 6 float)) + (sensor_timestamp uint64))) + +(define-bstruct SDL_QuitEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64))) + +(define-bstruct SDL_UserEvent + (struct + (type uint32) + (reserved uint32) + (timestamp uint64) + (windowID uint32) ; SDL_WindowID + (code int32) + (data1 (* void)) + (data2 (* void)))) + +(define-bstruct SDL_Event + (union + (type uint32) + (common SDL_CommonEvent) + (display SDL_DisplayEvent) + (window SDL_WindowEvent) + (kdevice SDL_KeyboardDeviceEvent) + (key SDL_KeyboardEvent) + (edit SDL_TextEditingEvent) + (edit_candidates SDL_TextEditingCandidatesEvent) + (text SDL_TextInputEvent) + (mdevice SDL_MouseDeviceEvent) + (motion SDL_MouseMotionEvent) + (button SDL_MouseButtonEvent) + (wheel SDL_MouseWheelEvent) + (jdevice SDL_JoyDeviceEvent) + (jaxis SDL_JoyAxisEvent) + (jball SDL_JoyBallEvent) + (jhat SDL_JoyHatEvent) + (jbutton SDL_JoyButtonEvent) + (jbattery SDL_JoyBatteryEvent) + (gdevice SDL_GamepadDeviceEvent) + (gaxis SDL_GamepadAxisEvent) + (gbutton SDL_GamepadButtonEvent) + (gtouchpad SDL_GamepadTouchpadEvent) + (gsensor SDL_GamepadSensorEvent) + (adevice SDL_AudioDeviceEvent) + (cdevice SDL_CameraDeviceEvent) + (sensor SDL_SensorEvent) + (quit SDL_QuitEvent) + (user SDL_UserEvent) + (tfinger SDL_TouchFingerEvent) + (pproximity SDL_PenProximityEvent) + (ptouch SDL_PenTouchEvent) + (pmotion SDL_PenMotionEvent) + (pbutton SDL_PenButtonEvent) + (paxis SDL_PenAxisEvent) + (drop SDL_DropEvent) + (clipboard SDL_ClipboardEvent) + (_ (array 128 uint8)))) + +(define-sdl SDL_PumpEvents) +;; SDL_PeepEvents +(define-sdl SDL_HasEvent uint32 -> bool) +(define-sdl SDL_HasEvents uint32 uint32 -> bool) +(define-sdl SDL_FlushEvent uint32) +(define-sdl SDL_FlushEvents uint32 uint32) +(define-sdl SDL_PollEvent '* -> bool) +(define-sdl SDL_WaitEvent '* -> bool) +(define-sdl SDL_WaitEventTimeout '* int32 -> bool) +(define-sdl SDL_PushEvent '* -> bool) +;; SDL_SetEventFilter +;; SDL_GetEventFilter +;; SDL_AddEventWatch +;; SDL_RemoveEventWatch +;; SDL_FilterEvents +;; SDL_SetEventEnabled +;; SDL_EventEnabled +;; SDL_RegisterEvents +;; SDL_GetWindowFromEvent diff --git a/sdl3/bindings/gpu.scm b/sdl3/bindings/gpu.scm new file mode 100644 index 0000000..0c83405 --- /dev/null +++ b/sdl3/bindings/gpu.scm @@ -0,0 +1,1202 @@ +;;; 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 (bstruct) + #:use-module (sdl3 bindings utils) + #:use-module (sdl3 bindings pixels) + #:use-module (sdl3 bindings surface) + #:use-module (system foreign) + #:export (SDL_GPUPrimitiveType + symbol->gpu-primitive-type + primitive-type->symbol + SDL_GPU_PRIMITIVETYPE_TRIANGLELIST + SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP + SDL_GPU_PRIMITIVETYPE_LINELIST + SDL_GPU_PRIMITIVETYPE_LINESTRIP + SDL_GPU_PRIMITIVETYPE_POINTLIST + + SDL_GPULoadOp + symbol->gpu-load-op + gpu-load-op->symbol + SDL_GPU_LOADOP_LOAD + SDL_GPU_LOADOP_CLEAR + SDL_GPU_LOADOP_DONT_CARE + + SDL_GPUStoreOp + symbol->gpu-store-op + gpu-store-op->symbol + SDL_GPU_STOREOP_STORE + SDL_GPU_STOREOP_DONT_CARE + SDL_GPU_STOREOP_RESOLVE + SDL_GPU_STOREOP_RESOLVE_AND_STORE + + SDL_GPUIndexElementSize + symbol->gpu-index-element-size + gpu-index-element-size->symbol + SDL_GPU_INDEXELEMENTSIZE_16BIT + SDL_GPU_INDEXELEMENTSIZE_32BIT + + SDL_GPUTextureFormat + symbol->gpu-texture-format + gpu-texture-format->symbol + SDL_GPU_TEXTUREFORMAT_INVALID + SDL_GPU_TEXTUREFORMAT_A8_UNORM + SDL_GPU_TEXTUREFORMAT_R8_UNORM + SDL_GPU_TEXTUREFORMAT_R8G8_UNORM + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM + SDL_GPU_TEXTUREFORMAT_R16_UNORM + SDL_GPU_TEXTUREFORMAT_R16G16_UNORM + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM + SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM + SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM + SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM + SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM + SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM + SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM + SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM + SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM + SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM + SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM + SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT + SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT + SDL_GPU_TEXTUREFORMAT_R8_SNORM + SDL_GPU_TEXTUREFORMAT_R8G8_SNORM + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM + SDL_GPU_TEXTUREFORMAT_R16_SNORM + SDL_GPU_TEXTUREFORMAT_R16G16_SNORM + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM + SDL_GPU_TEXTUREFORMAT_R16_FLOAT + SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT + SDL_GPU_TEXTUREFORMAT_R32_FLOAT + SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT + SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT + SDL_GPU_TEXTUREFORMAT_R8_UINT + SDL_GPU_TEXTUREFORMAT_R8G8_UINT + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT + SDL_GPU_TEXTUREFORMAT_R16_UINT + SDL_GPU_TEXTUREFORMAT_R16G16_UINT + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT + SDL_GPU_TEXTUREFORMAT_R32_UINT + SDL_GPU_TEXTUREFORMAT_R32G32_UINT + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT + SDL_GPU_TEXTUREFORMAT_R8_INT + SDL_GPU_TEXTUREFORMAT_R8G8_INT + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT + SDL_GPU_TEXTUREFORMAT_R16_INT + SDL_GPU_TEXTUREFORMAT_R16G16_INT + SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT + SDL_GPU_TEXTUREFORMAT_R32_INT + SDL_GPU_TEXTUREFORMAT_R32G32_INT + SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT + SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB + SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB + SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB + SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB + SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB + SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB + SDL_GPU_TEXTUREFORMAT_D16_UNORM + SDL_GPU_TEXTUREFORMAT_D24_UNORM + SDL_GPU_TEXTUREFORMAT_D32_FLOAT + SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT + SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT + + SDL_GPUTextureUsageFlags + symbols->gpu-texture-usage-flags + gpu-texture-usage-flags->symbols + SDL_GPU_TEXTUREUSAGE_SAMPLER + SDL_GPU_TEXTUREUSAGE_COLOR_TARGET + SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET + SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ + SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ + SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE + SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE + + SDL_GPUTextureType + symbol->gpu-texture-type + gpu-texture-type->symbol + SDL_GPU_TEXTURETYPE_2D + SDL_GPU_TEXTURETYPE_2D_ARRAY + SDL_GPU_TEXTURETYPE_3D + SDL_GPU_TEXTURETYPE_CUBE + SDL_GPU_TEXTURETYPE_CUBE_ARRAY + + SDL_GPUSampleCount + int->gpu-sample-count + gpu-sample-count->int + SDL_GPU_SAMPLECOUNT_1 + SDL_GPU_SAMPLECOUNT_2 + SDL_GPU_SAMPLECOUNT_4 + SDL_GPU_SAMPLECOUNT_8 + + SDL_GPUCubeMapFace + symbol->gpu-cube-map-face + gpu-cube-map-face->symbol + SDL_GPU_CUBEMAPFACE_POSITIVEX + SDL_GPU_CUBEMAPFACE_NEGATIVEX + SDL_GPU_CUBEMAPFACE_POSITIVEY + SDL_GPU_CUBEMAPFACE_NEGATIVEY + SDL_GPU_CUBEMAPFACE_POSITIVEZ + SDL_GPU_CUBEMAPFACE_NEGATIVEZ + + SDL_GPUBufferUsageFlags + symbols->gpu-buffer-usage-flags + gpu-buffer-usage-flags->symbols + SDL_GPU_BUFFERUSAGE_VERTEX + SDL_GPU_BUFFERUSAGE_INDEX + SDL_GPU_BUFFERUSAGE_INDIRECT + SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ + SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ + SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE + + SDL_GPUTransferBufferUsage + symbol->gpu-transfer-buffer-usage + gpu-transfer-buffer-usage->symbol + SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD + SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD + + SDL_GPUShaderStage + symbol->gpu-shader-stage + gpu-shader-stage->symbol + SDL_GPU_SHADERSTAGE_VERTEX + SDL_GPU_SHADERSTAGE_FRAGMENT + + SDL_GPUShaderFormat + symbols->gpu-shader-format + gpu-shader-format->symbols + 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 + + SDL_GPUVertexElementFormat + symbol->gpu-vertex-element-format + gpu-vertex-element-format->symbol + SDL_GPU_VERTEXELEMENTFORMAT_INVALID + SDL_GPU_VERTEXELEMENTFORMAT_INT + SDL_GPU_VERTEXELEMENTFORMAT_INT2 + SDL_GPU_VERTEXELEMENTFORMAT_INT3 + SDL_GPU_VERTEXELEMENTFORMAT_INT4 + SDL_GPU_VERTEXELEMENTFORMAT_UINT + SDL_GPU_VERTEXELEMENTFORMAT_UINT2 + SDL_GPU_VERTEXELEMENTFORMAT_UINT3 + SDL_GPU_VERTEXELEMENTFORMAT_UINT4 + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2 + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3 + SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4 + SDL_GPU_VERTEXELEMENTFORMAT_BYTE2 + SDL_GPU_VERTEXELEMENTFORMAT_BYTE4 + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2 + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4 + SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM + SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM + SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM + SDL_GPU_VERTEXELEMENTFORMAT_SHORT2 + SDL_GPU_VERTEXELEMENTFORMAT_SHORT4 + SDL_GPU_VERTEXELEMENTFORMAT_USHORT2 + SDL_GPU_VERTEXELEMENTFORMAT_USHORT4 + SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM + SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM + SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM + SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM + SDL_GPU_VERTEXELEMENTFORMAT_HALF2 + SDL_GPU_VERTEXELEMENTFORMAT_HALF4 + + SDL_GPUVertexInputRate + symbol->gpu-vertex-input-rate + gpu-vertex-input-rate->symbol + SDL_GPU_VERTEXINPUTRATE_VERTEX + SDL_GPU_VERTEXINPUTRATE_INSTANCE + + SDL_GPUFillMode + symbol->gpu-fill-mode + gpu-fill-mode->symbol + SDL_GPU_FILLMODE_FILL + SDL_GPU_FILLMODE_LINE + + SDL_GPUCullMode + symbol->gpu-cull-mode + gpu-cull-mode->symbol + SDL_GPU_CULLMODE_NONE + SDL_GPU_CULLMODE_FRONT + SDL_GPU_CULLMODE_BACK + + SDL_GPUFrontFace + symbol->gpu-front-face + gpu-front-face->symbol + SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE + SDL_GPU_FRONTFACE_CLOCKWISE + + SDL_GPUCompareOp + symbol->gpu-compare-op + gpu-compare-op->symbol + SDL_GPU_COMPAREOP_INVALID + SDL_GPU_COMPAREOP_NEVER + SDL_GPU_COMPAREOP_LESS + SDL_GPU_COMPAREOP_EQUAL + SDL_GPU_COMPAREOP_LESS_OR_EQUAL + SDL_GPU_COMPAREOP_GREATER + SDL_GPU_COMPAREOP_NOT_EQUAL + SDL_GPU_COMPAREOP_GREATER_OR_EQUAL + SDL_GPU_COMPAREOP_ALWAYS + + SDL_GPUStencilOp + symbol->gpu-stencil-op + gpu-stencil-op->symbol + SDL_GPU_STENCILOP_INVALID + SDL_GPU_STENCILOP_KEEP + SDL_GPU_STENCILOP_ZERO + SDL_GPU_STENCILOP_REPLACE + SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP + SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP + SDL_GPU_STENCILOP_INVERT + SDL_GPU_STENCILOP_INCREMENT_AND_WRAP + SDL_GPU_STENCILOP_DECREMENT_AND_WRAP + + SDL_GPUBlendOp + symbol->gpu-blend-op + gpu-blend-op->symbol + SDL_GPU_BLENDOP_INVALID + SDL_GPU_BLENDOP_ADD + SDL_GPU_BLENDOP_SUBTRACT + SDL_GPU_BLENDOP_REVERSE_SUBTRACT + SDL_GPU_BLENDOP_MIN + SDL_GPU_BLENDOP_MAX + + SDL_GPUBlendFactor + symbol->gpu-blend-factor + gpu-blend-factor->symbol + SDL_GPU_BLENDFACTOR_INVALID + SDL_GPU_BLENDFACTOR_ZERO + SDL_GPU_BLENDFACTOR_ONE + SDL_GPU_BLENDFACTOR_SRC_COLOR + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR + SDL_GPU_BLENDFACTOR_DST_COLOR + SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR + SDL_GPU_BLENDFACTOR_SRC_ALPHA + SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA + SDL_GPU_BLENDFACTOR_DST_ALPHA + SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA + SDL_GPU_BLENDFACTOR_CONSTANT_COLOR + SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR + SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE + + SDL_GPUColorComponentFlags + symbols->gpu-color-component-flags + gpu-color-component-flags->symbols + SDL_GPU_COLORCOMPONENT_R + SDL_GPU_COLORCOMPONENT_G + SDL_GPU_COLORCOMPONENT_B + SDL_GPU_COLORCOMPONENT_A + + SDL_GPUFilter + symbol->gpu-filter + gpu-filter->symbol + SDL_GPU_FILTER_NEAREST + SDL_GPU_FILTER_LINEAR + + SDL_GPUSamplerMipmapMode + symbol->gpu-sampler-mipmap-mode + gpu-sampler-mipmap-mode->symbol + SDL_GPU_SAMPLERMIPMAPMODE_NEAREST + SDL_GPU_SAMPLERMIPMAPMODE_LINEAR + + SDL_GPUSamplerAddressMode + symbol->gpu-sampler-address-mode + gpu-sampler-address-mode->symbol + SDL_GPU_SAMPLERADDRESSMODE_REPEAT + SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT + SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE + + SDL_GPUPresentMode + symbol->gpu-present-mode + gpu-present-mode->symbol + SDL_GPU_PRESENTMODE_VSYNC + SDL_GPU_PRESENTMODE_IMMEDIATE + SDL_GPU_PRESENTMODE_MAILBOX + + SDL_GPUSwapchainComposition + symbol->gpu-swapchain-composition + gpu-swapchain-composition->symbol + SDL_GPU_SWAPCHAINCOMPOSITION_SDR + SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR + SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR + SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048 + + SDL_GPUViewport + SDL_GPUTextureTransferInfo + SDL_GPUTransferBufferLocation + SDL_GPUTextureLocation + SDL_GPUTextureRegion + SDL_GPUBlitRegion + SDL_GPUBufferLocation + SDL_GPUBufferRegion + SDL_GPUVertexBufferDescription + SDL_GPUVertexAttribute + SDL_GPUVertexInputState + SDL_GPUStencilOpState + SDL_GPUColorTargetBlendState + SDL_GPUShaderCreateInfo + SDL_GPUTextureCreateInfo + SDL_GPUBufferCreateInfo + SDL_GPUTransferBufferCreateInfo + SDL_GPURasterizerState + SDL_GPUMultisampleState + SDL_GPUDepthStencilState + SDL_GPUColorTargetDescription + SDL_GPUGraphicsPipelineTargetInfo + SDL_GPUGraphicsPipelineCreateInfo + SDL_GPUComputePipelineCreateInfo + SDL_GPUColorTargetInfo + SDL_GPUDepthStencilTargetInfo + SDL_GPUBlitInfo + SDL_GPUBufferBinding + SDL_GPUTextureSamplerBinding + SDL_GPUStorageBufferReadWriteBinding + SDL_GPUStorageTextureReadWriteBinding + + gpu-device? + wrap-gpu-device + unwrap-gpu-device + gpu-device-destroyed? + set-gpu-device-destroyed! + + gpu-buffer? + wrap-gpu-buffer + unwrap-gpu-buffer + gpu-buffer-released? + set-gpu-buffer-released! + + gpu-transfer-buffer? + wrap-gpu-transfer-buffer + unwrap-gpu-transfer-buffer + gpu-transfer-buffer-released? + set-gpu-transfer-buffer-released! + + gpu-shader? + wrap-gpu-shader + unwrap-gpu-shader + gpu-shader-released? + set-gpu-shader-released! + + gpu-texture? + wrap-gpu-texture + unwrap-gpu-texture + gpu-texture-released? + set-gpu-texture-released! + + gpu-graphics-pipeline? + wrap-gpu-graphics-pipeline + unwrap-gpu-graphics-pipeline + gpu-graphics-pipeline-released? + set-gpu-graphics-pipeline-released! + + gpu-command-buffer? + wrap-gpu-command-buffer + unwrap-gpu-command-buffer + + gpu-copy-pass? + wrap-gpu-copy-pass + unwrap-gpu-copy-pass + + gpu-render-pass? + wrap-gpu-render-pass + unwrap-gpu-render-pass + + gpu-compute-pass? + wrap-gpu-compute-pass + unwrap-gpu-compute-pass + + SDL_AcquireGPUCommandBuffer + SDL_AcquireGPUSwapchainTexture + SDL_BeginGPUCopyPass + SDL_BeginGPURenderPass + SDL_BindGPUGraphicsPipeline + SDL_BindGPUVertexBuffers + SDL_BlitGPUTexture + SDL_CreateGPUBuffer + SDL_CreateGPUDevice + SDL_CreateGPUGraphicsPipeline + SDL_CreateGPUShader + SDL_CreateGPUTexture + SDL_CreateGPUTransferBuffer + SDL_ClaimWindowForGPUDevice + SDL_DestroyGPUDevice + SDL_DrawGPUPrimitives + SDL_EndGPUCopyPass + SDL_EndGPURenderPass + SDL_GetGPUDeviceDriver + SDL_GetGPUDriver + SDL_GetGPUSwapchainTextureFormat + SDL_GetNumGPUDrivers + SDL_GPUTextureSupportsSampleCount + SDL_MapGPUTransferBuffer + SDL_PushGPUVertexUniformData + SDL_PushGPUFragmentUniformData + SDL_ReleaseGPUBuffer + SDL_ReleaseGPUGraphicsPipeline + SDL_ReleaseGPUShader + SDL_ReleaseGPUTexture + SDL_ReleaseGPUTransferBuffer + SDL_ReleaseWindowFromGPUDevice + SDL_SetGPUBufferName + SDL_SubmitGPUCommandBuffer + SDL_UnmapGPUTransferBuffer + SDL_UploadToGPUBuffer)) + +(define-bstruct SDL_GPUDevice) +(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-bstruct SDL_GPUBuffer) +(define-sdl-pointer-type <gpu-buffer> + gpu-buffer? wrap-gpu-buffer unwrap-gpu-buffer + gpu-buffer-released? set-gpu-buffer-released! + (lambda (buffer port) + (display "#<gpu-buffer>" port))) + +(define-bstruct SDL_GPUTransferBuffer) +(define-sdl-pointer-type <gpu-transfer-buffer> + gpu-transfer-buffer? wrap-gpu-transfer-buffer unwrap-gpu-transfer-buffer + gpu-transfer-buffer-released? set-gpu-transfer-buffer-released! + (lambda (transfer-buffer port) + (display "#<gpu-transfer-buffer>" port))) + +(define-bstruct SDL_GPUShader) +(define-sdl-pointer-type <gpu-shader> + gpu-shader? wrap-gpu-shader unwrap-gpu-shader + gpu-shader-released? set-gpu-shader-released! + (lambda (shader port) + (display "#<gpu-shader>" port))) + +(define-bstruct SDL_GPUTexture) +(define-sdl-pointer-type <gpu-texture> + gpu-texture? wrap-gpu-texture unwrap-gpu-texture + gpu-texture-released? set-gpu-texture-released! + (lambda (texture port) + (format port "#<gpu-texture ~a>" + (pointer-address (unwrap-gpu-texture texture))))) + +(define-bstruct SDL_GPUSampler) +(define-sdl-pointer-type <gpu-sampler> + gpu-sampler? wrap-gpu-sampler unwrap-gpu-sampler + gpu-sampler-released? set-gpu-sampler-released! + (lambda (sampler port) + (format port "#<gpu-sampler ~a>" + (pointer-address (unwrap-gpu-sampler sampler))))) + +(define-sdl-pointer-type <gpu-graphics-pipeline> + gpu-graphics-pipeline? wrap-gpu-graphics-pipeline unwrap-gpu-graphics-pipeline + gpu-graphics-pipeline-released? set-gpu-graphics-pipeline-released! + (lambda (graphics-pipeline port) + (display "#<gpu-graphics-pipeline>" port))) + +(define-wrapped-pointer-type <gpu-command-buffer> + gpu-command-buffer? wrap-gpu-command-buffer unwrap-gpu-command-buffer + (lambda (command-buffer port) + (display "#<gpu-command-buffer>" port))) + +(define-wrapped-pointer-type <gpu-copy-pass> + gpu-copy-pass? wrap-gpu-copy-pass unwrap-gpu-copy-pass + (lambda (copy-pass port) + (display "#<gpu-copy-pass>" port))) + +(define-wrapped-pointer-type <gpu-render-pass> + gpu-render-pass? wrap-gpu-render-pass unwrap-gpu-render-pass + (lambda (render-pass port) + (display "#<gpu-render-pass>" port))) + +(define-wrapped-pointer-type <gpu-compute-pass> + gpu-compute-pass? wrap-gpu-compute-pass unwrap-gpu-compute-pass + (lambda (compute-pass port) + (display "#<gpu-compute-pass>" port))) + +(define-enum SDL_GPUPrimitiveType + symbol->gpu-primitive-type + primitive-type->symbol + (triangle-list SDL_GPU_PRIMITIVETYPE_TRIANGLELIST) + (triangle-strip SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP) + (line-list SDL_GPU_PRIMITIVETYPE_LINELIST) + (line-strip SDL_GPU_PRIMITIVETYPE_LINESTRIP) + (point-list SDL_GPU_PRIMITIVETYPE_POINTLIST)) + +(define-enum SDL_GPULoadOp + symbol->gpu-load-op + gpu-load-op->symbol + (load SDL_GPU_LOADOP_LOAD) + (clear SDL_GPU_LOADOP_CLEAR) + (dont-care SDL_GPU_LOADOP_DONT_CARE)) + +(define-enum SDL_GPUStoreOp + symbol->gpu-store-op + gpu-store-op->symbol + (store SDL_GPU_STOREOP_STORE) + (dont-care SDL_GPU_STOREOP_DONT_CARE) + (resolve SDL_GPU_STOREOP_RESOLVE) + (resolve-and-store SDL_GPU_STOREOP_RESOLVE_AND_STORE)) + +(define-enum SDL_GPUIndexElementSize + symbol->gpu-index-element-size + gpu-index-element-size->symbol + (16-bit SDL_GPU_INDEXELEMENTSIZE_16BIT) + (32-bit SDL_GPU_INDEXELEMENTSIZE_32BIT)) + +(define-enum SDL_GPUTextureFormat + symbol->gpu-texture-format + gpu-texture-format->symbol + (invalid SDL_GPU_TEXTUREFORMAT_INVALID) + (a8-unorm SDL_GPU_TEXTUREFORMAT_A8_UNORM) + (r8-unorm SDL_GPU_TEXTUREFORMAT_R8_UNORM) + (r8g8-unorm SDL_GPU_TEXTUREFORMAT_R8G8_UNORM) + (r8g8b8a8-unorm SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM) + (r16-unorm SDL_GPU_TEXTUREFORMAT_R16_UNORM) + (r16g16-unorm SDL_GPU_TEXTUREFORMAT_R16G16_UNORM) + (r16g16b16a16-unorm SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM) + (r10g10b10a2-unorm SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM) + (b5g6r5-unorm SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM) + (b5g5r5a1-unorm SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM) + (b4g4r4a4-unorm SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM) + (b8g8r8a8-unorm SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM) + (bc1-rbga-unorm SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM) + (bc2-rgba-unorm SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM) + (bc3-rgba-unorm SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM) + (bc4-r-unorm SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM) + (bc5-rg-unorm SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM) + (bc7-rgba-unorm SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM) + (bc6h-rgb-float SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT) + (bc6h-rgb-float SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT) + (r8-snorm SDL_GPU_TEXTUREFORMAT_R8_SNORM) + (r8g8-snorm SDL_GPU_TEXTUREFORMAT_R8G8_SNORM) + (r8g8b8a8-snorm SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM) + (r16-snorm SDL_GPU_TEXTUREFORMAT_R16_SNORM) + (r16g16-snorm SDL_GPU_TEXTUREFORMAT_R16G16_SNORM) + (r16g16b16a16-snorm SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM) + (r16-float SDL_GPU_TEXTUREFORMAT_R16_FLOAT) + (r16g16-float SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT) + (r16g16b16a16-float SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT) + (r32-float SDL_GPU_TEXTUREFORMAT_R32_FLOAT) + (r32g32-float SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT) + (r32g32b32a32-float SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT) + (r11g11b10-ufloat SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT) + (r8-uint SDL_GPU_TEXTUREFORMAT_R8_UINT) + (r8g8-uint SDL_GPU_TEXTUREFORMAT_R8G8_UINT) + (r8g8b8a8-uint SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT) + (r16-uint SDL_GPU_TEXTUREFORMAT_R16_UINT) + (r16g16-uint SDL_GPU_TEXTUREFORMAT_R16G16_UINT) + (r16g16b16a16-uint SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT) + (r32-uint SDL_GPU_TEXTUREFORMAT_R32_UINT) + (r32g32-uint SDL_GPU_TEXTUREFORMAT_R32G32_UINT) + (r32g32b32a32-uint SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT) + (r8-int SDL_GPU_TEXTUREFORMAT_R8_INT) + (r8g8-int SDL_GPU_TEXTUREFORMAT_R8G8_INT) + (r8g8b8a8-int SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT) + (r16-int SDL_GPU_TEXTUREFORMAT_R16_INT) + (r16g16-int SDL_GPU_TEXTUREFORMAT_R16G16_INT) + (r16g16b16a16-int SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT) + (r32-int SDL_GPU_TEXTUREFORMAT_R32_INT) + (r32g32-int SDL_GPU_TEXTUREFORMAT_R32G32_INT) + (r32g32b32a32-int SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT) + (r8g8b8a8-unorm-srgb SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB) + (b8g8r8a8-unorm-srgb SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB) + (bc1-unorm-srgb SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB) + (bc2-unorm-srgb SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM_SRGB) + (bc3-unorm-srgb SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB) + (bc7-unorm-srgb SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB) + (d16-unorm SDL_GPU_TEXTUREFORMAT_D16_UNORM) + (d24-unorm SDL_GPU_TEXTUREFORMAT_D24_UNORM) + (d32-float SDL_GPU_TEXTUREFORMAT_D32_FLOAT) + (d24-unorm-s8-uint SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT) + (d32-float-s8-uint SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT)) + +(define-bitmask (SDL_GPUTextureUsageFlags uint32) + symbols->gpu-texture-usage-flags + gpu-texture-usage-flags->symbols + (sampler SDL_GPU_TEXTUREUSAGE_SAMPLER) + (color-target SDL_GPU_TEXTUREUSAGE_COLOR_TARGET) + (depth-stencil-target SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET) + (graphics-storage-read SDL_GPU_TEXTUREUSAGE_GRAPHICS_STORAGE_READ) + (compute-storage-read SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_READ) + (compute-storage-write SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_WRITE) + (compute-storage-simultaneous-read-write + SDL_GPU_TEXTUREUSAGE_COMPUTE_STORAGE_SIMULTANEOUS_READ_WRITE)) + +(define-enum SDL_GPUTextureType + symbol->gpu-texture-type + gpu-texture-type->symbol + (2d SDL_GPU_TEXTURETYPE_2D) + (2d-array SDL_GPU_TEXTURETYPE_2D_ARRAY) + (3d SDL_GPU_TEXTURETYPE_3D) + (cube SDL_GPU_TEXTURETYPE_CUBE) + (cube-array SDL_GPU_TEXTURETYPE_CUBE_ARRAY)) + +(define-enum SDL_GPUSampleCount + int->gpu-sample-count + gpu-sample-count->int + (1 SDL_GPU_SAMPLECOUNT_1) + (2 SDL_GPU_SAMPLECOUNT_2) + (4 SDL_GPU_SAMPLECOUNT_4) + (8 SDL_GPU_SAMPLECOUNT_8)) + +(define-enum SDL_GPUCubeMapFace + symbol->gpu-cube-map-face + gpu-cube-map-face->symbol + (positive-x SDL_GPU_CUBEMAPFACE_POSITIVEX) + (negative-x SDL_GPU_CUBEMAPFACE_NEGATIVEX) + (positive-y SDL_GPU_CUBEMAPFACE_POSITIVEY) + (negative-y SDL_GPU_CUBEMAPFACE_NEGATIVEY) + (positive-z SDL_GPU_CUBEMAPFACE_POSITIVEZ) + (negative-z SDL_GPU_CUBEMAPFACE_NEGATIVEZ)) + +(define-bitmask (SDL_GPUBufferUsageFlags uint32) + symbols->gpu-buffer-usage-flags + gpu-buffer-usage-flags->symbols + (vertex SDL_GPU_BUFFERUSAGE_VERTEX) + (index SDL_GPU_BUFFERUSAGE_INDEX) + (indirect SDL_GPU_BUFFERUSAGE_INDIRECT) + (graphics-storage-read SDL_GPU_BUFFERUSAGE_GRAPHICS_STORAGE_READ) + (compute-storage-read SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_READ) + (compute-storage-write SDL_GPU_BUFFERUSAGE_COMPUTE_STORAGE_WRITE)) + +(define-enum SDL_GPUTransferBufferUsage + symbol->gpu-transfer-buffer-usage + gpu-transfer-buffer-usage->symbol + (upload SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD) + (download SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD)) + +(define-enum SDL_GPUShaderStage + symbol->gpu-shader-stage + gpu-shader-stage->symbol + (vertex SDL_GPU_SHADERSTAGE_VERTEX) + (fragment SDL_GPU_SHADERSTAGE_FRAGMENT)) + +(define-bitmask (SDL_GPUShaderFormat uint32) + symbols->gpu-shader-format + gpu-shader-format->symbols + (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)) +(define SDL_GPU_SHADERFORMAT_INVALID 0) + +(define-enum SDL_GPUVertexElementFormat + symbol->gpu-vertex-element-format + gpu-vertex-element-format->symbol + (invalid SDL_GPU_VERTEXELEMENTFORMAT_INVALID) + (int SDL_GPU_VERTEXELEMENTFORMAT_INT) + (int2 SDL_GPU_VERTEXELEMENTFORMAT_INT2) + (int3 SDL_GPU_VERTEXELEMENTFORMAT_INT3) + (int4 SDL_GPU_VERTEXELEMENTFORMAT_INT4) + (uint SDL_GPU_VERTEXELEMENTFORMAT_UINT) + (uint2 SDL_GPU_VERTEXELEMENTFORMAT_UINT2) + (uint3 SDL_GPU_VERTEXELEMENTFORMAT_UINT3) + (uint4 SDL_GPU_VERTEXELEMENTFORMAT_UINT4) + (float SDL_GPU_VERTEXELEMENTFORMAT_FLOAT) + (float2 SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2) + (float3 SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3) + (float4 SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4) + (byte2 SDL_GPU_VERTEXELEMENTFORMAT_BYTE2) + (byte4 SDL_GPU_VERTEXELEMENTFORMAT_BYTE4) + (ubyte2 SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2) + (ubyte4 SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4) + (byte2-norm SDL_GPU_VERTEXELEMENTFORMAT_BYTE2_NORM) + (byte4-norm SDL_GPU_VERTEXELEMENTFORMAT_BYTE4_NORM) + (ubyte2-norm SDL_GPU_VERTEXELEMENTFORMAT_UBYTE2_NORM) + (ubyte4-norm SDL_GPU_VERTEXELEMENTFORMAT_UBYTE4_NORM) + (short2 SDL_GPU_VERTEXELEMENTFORMAT_SHORT2) + (short4 SDL_GPU_VERTEXELEMENTFORMAT_SHORT4) + (ushort2 SDL_GPU_VERTEXELEMENTFORMAT_USHORT2) + (ushort4 SDL_GPU_VERTEXELEMENTFORMAT_USHORT4) + (short2-norm SDL_GPU_VERTEXELEMENTFORMAT_SHORT2_NORM) + (short4-norm SDL_GPU_VERTEXELEMENTFORMAT_SHORT4_NORM) + (ushort2-norm SDL_GPU_VERTEXELEMENTFORMAT_USHORT2_NORM) + (ushort4-norm SDL_GPU_VERTEXELEMENTFORMAT_USHORT4_NORM) + (half2 SDL_GPU_VERTEXELEMENTFORMAT_HALF2) + (half4 SDL_GPU_VERTEXELEMENTFORMAT_HALF4)) + +(define-enum SDL_GPUVertexInputRate + symbol->gpu-vertex-input-rate + gpu-vertex-input-rate->symbol + (vertex SDL_GPU_VERTEXINPUTRATE_VERTEX) + (instance SDL_GPU_VERTEXINPUTRATE_INSTANCE)) + +(define-enum SDL_GPUFillMode + symbol->gpu-fill-mode + gpu-fill-mode->symbol + (fill SDL_GPU_FILLMODE_FILL) + (line SDL_GPU_FILLMODE_LINE)) + +(define-enum SDL_GPUCullMode + symbol->gpu-cull-mode + gpu-cull-mode->symbol + (none SDL_GPU_CULLMODE_NONE) + (front SDL_GPU_CULLMODE_FRONT) + (back SDL_GPU_CULLMODE_BACK)) + +(define-enum SDL_GPUFrontFace + symbol->gpu-front-face + gpu-front-face->symbol + (counter-clockwise SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE) + (clockwise SDL_GPU_FRONTFACE_CLOCKWISE)) + +(define-enum SDL_GPUCompareOp + symbol->gpu-compare-op + gpu-compare-op->symbol + (invalid SDL_GPU_COMPAREOP_INVALID) + (never SDL_GPU_COMPAREOP_NEVER) + (less SDL_GPU_COMPAREOP_LESS) + (equal SDL_GPU_COMPAREOP_EQUAL) + (less-or-equal SDL_GPU_COMPAREOP_LESS_OR_EQUAL) + (greater SDL_GPU_COMPAREOP_GREATER) + (not-equal SDL_GPU_COMPAREOP_NOT_EQUAL) + (greater-or-equal SDL_GPU_COMPAREOP_GREATER_OR_EQUAL) + (always SDL_GPU_COMPAREOP_ALWAYS)) + +(define-enum SDL_GPUStencilOp + symbol->gpu-stencil-op + gpu-stencil-op->symbol + (invalid SDL_GPU_STENCILOP_INVALID) + (keep SDL_GPU_STENCILOP_KEEP) + (zero SDL_GPU_STENCILOP_ZERO) + (replace SDL_GPU_STENCILOP_REPLACE) + (increment-and-clamp SDL_GPU_STENCILOP_INCREMENT_AND_CLAMP) + (decrement-and-clamp SDL_GPU_STENCILOP_DECREMENT_AND_CLAMP) + (invert SDL_GPU_STENCILOP_INVERT) + (increment-and-wrap SDL_GPU_STENCILOP_INCREMENT_AND_WRAP) + (decrement-and-wrap SDL_GPU_STENCILOP_DECREMENT_AND_WRAP)) + +(define-enum SDL_GPUBlendOp + symbol->gpu-blend-op + gpu-blend-op->symbol + (invalid SDL_GPU_BLENDOP_INVALID) + (add SDL_GPU_BLENDOP_ADD) + (subtract SDL_GPU_BLENDOP_SUBTRACT) + (reverse-subtract SDL_GPU_BLENDOP_REVERSE_SUBTRACT) + (min SDL_GPU_BLENDOP_MIN) + (max SDL_GPU_BLENDOP_MAX)) + +(define-enum SDL_GPUBlendFactor + symbol->gpu-blend-factor + gpu-blend-factor->symbol + (invalid SDL_GPU_BLENDFACTOR_INVALID) + (zero SDL_GPU_BLENDFACTOR_ZERO) + (one SDL_GPU_BLENDFACTOR_ONE) + (src-color SDL_GPU_BLENDFACTOR_SRC_COLOR) + (one-minus-src-color SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR) + (dst-color SDL_GPU_BLENDFACTOR_DST_COLOR) + (one-minus-dst-color SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR) + (src-alpha SDL_GPU_BLENDFACTOR_SRC_ALPHA) + (one-minus-src-alpha SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA) + (dst-alpha SDL_GPU_BLENDFACTOR_DST_ALPHA) + (one-minus-dst-alpha SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA) + (constant-color SDL_GPU_BLENDFACTOR_CONSTANT_COLOR) + (one-minus-constant-color SDL_GPU_BLENDFACTOR_ONE_MINUS_CONSTANT_COLOR) + (alpha-saturate SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE)) + +(define-bitmask (SDL_GPUColorComponentFlags uint8) + symbols->gpu-color-component-flags + gpu-color-component-flags->symbols + (r SDL_GPU_COLORCOMPONENT_R) + (g SDL_GPU_COLORCOMPONENT_G) + (b SDL_GPU_COLORCOMPONENT_B) + (a SDL_GPU_COLORCOMPONENT_A)) + +(define-enum SDL_GPUFilter + symbol->gpu-filter + gpu-filter->symbol + (nearest SDL_GPU_FILTER_NEAREST) + (linear SDL_GPU_FILTER_LINEAR)) + +(define-enum SDL_GPUSamplerMipmapMode + symbol->gpu-sampler-mipmap-mode + gpu-sampler-mipmap-mode->symbol + (nearest SDL_GPU_SAMPLERMIPMAPMODE_NEAREST) + (linear SDL_GPU_SAMPLERMIPMAPMODE_LINEAR)) + +(define-enum SDL_GPUSamplerAddressMode + symbol->gpu-sampler-address-mode + gpu-sampler-address-mode->symbol + (repease SDL_GPU_SAMPLERADDRESSMODE_REPEAT) + (mirrored-repeat SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT) + (clamp-to-edge SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE)) + +(define-enum SDL_GPUPresentMode + symbol->gpu-present-mode + gpu-present-mode->symbol + (vsync SDL_GPU_PRESENTMODE_VSYNC) + (immediate SDL_GPU_PRESENTMODE_IMMEDIATE) + (mailbox SDL_GPU_PRESENTMODE_MAILBOX)) + +(define-enum SDL_GPUSwapchainComposition + symbol->gpu-swapchain-composition + gpu-swapchain-composition->symbol + (sdr SDL_GPU_SWAPCHAINCOMPOSITION_SDR) + (sdr-linear SDL_GPU_SWAPCHAINCOMPOSITION_SDR_LINEAR) + (hdr-extended-linear SDL_GPU_SWAPCHAINCOMPOSITION_HDR_EXTENDED_LINEAR) + (hdr10-st2048 SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2048)) + +(define-bstruct SDL_GPUViewport + (struct + (x float) + (y float) + (w float) + (h float) + (min_depth float) + (max_depth float))) + +(define-bstruct SDL_GPUTextureTransferInfo + (struct + (transfer_buffer (* SDL_GPUTransferBuffer)) + (offset uint32) + (pixels_per_row uint32) + (rows_per_layer uint32))) + +(define-bstruct SDL_GPUTransferBufferLocation + (struct + (transfer_buffer (* SDL_GPUTransferBuffer)) + (offset uint32))) + +(define-bstruct SDL_GPUTextureLocation + (struct + (texture (* SDL_GPUTexture)) + (mip_level uint32) + (layer uint32) + (x uint32) + (y uint32) + (z uint32))) + +(define-bstruct SDL_GPUTextureRegion + (struct + (texture (* SDL_GPUTexture)) + (mip_level uint32) + (layer uint32) + (x uint32) + (y uint32) + (z uint32) + (w uint32) + (h uint32) + (d uint32))) + +(define-bstruct SDL_GPUBlitRegion + (struct + (texture (* SDL_GPUTexture)) + (mip_level uint32) + (layer_or_depth_plane uint32) + (x uint32) + (y uint32) + (w uint32) + (h uint32))) + +(define-bstruct SDL_GPUBufferLocation + (struct + (buffer (* SDL_GPUBuffer)) + (offset uint32))) + +(define-bstruct SDL_GPUBufferRegion + (struct + (buffer (* SDL_GPUBuffer)) + (offset uint32) + (size uint32))) + +(define-bstruct SDL_GPUVertexBufferDescription + (struct + (slot uint32) + (pitch uint32) + (input_rate int) ; SDL_GPUVertexInputRate + (instance_step_rate uint32))) + +(define-bstruct SDL_GPUVertexAttribute + (struct + (location uint32) + (buffer_slot uint32) + (format int) ; SDL_GPUVertexElementFormat + (offset uint32))) + +(define-bstruct SDL_GPUVertexInputState + (struct + (vertex_buffer_descriptions (* SDL_GPUVertexBufferDescription)) + (num_vertex_buffers uint32) + (vertex_attributes (* SDL_GPUVertexAttribute)) + (num_vertex_attributes uint32))) + +(define-bstruct SDL_GPUStencilOpState + (struct + (fail_op int) ; SDL_GPUStencilOp + (pass_op int) ; SDL_GPUStencilOp + (depth_fail_op int) ; SDL_GPUStencilOp + (compare_op int) ; SDL_GPUCompareOp + )) + +(define-bstruct SDL_GPUColorTargetBlendState + (struct + (src_color_blendfactor int) ; SDL_GPUBlendFactor + (dst_color_blendfactor int) ; SDL_GPUBlendFactor + (color_blend_op int) ; SDL_GPUBlendOp + (src_alpha_blendfactor int) ; SDL_GPUBlendFactor + (dst_alpha_blendfactor int) ; SDL_GPUBlendFactor + (alpha_blend_op int) ; SDL_GPUBlendOp + (color_write_mask uint8) ; SDL_GPUColorComponentFlags + (enable_blend uint8) ; bool + (enable_color_write_mask uint8) ; bool + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUShaderCreateInfo + (struct + (code_size size_t) + (code (* uint8)) + (entrypoint (* uint8)) ; char* + (format uint32) ; SDL_GPUShaderFormat + (stage int) ; SDL_GPUShaderStage + (num_samplers uint32) + (num_storage_textures uint32) + (num_storage_buffers uint32) + (num_uniform_buffers uint32) + (props uint32) ; SDL_PropertiesID + )) + +(define-bstruct SDL_GPUTextureCreateInfo + (struct + (type int) ; SDL_GPUTextureType + (format int) ; SDL_GPUTextureFormat + (usage uint32) ; SDL_GPUTextureUsageFlags + (width uint32) + (height uint32) + (layer_count_or_depth uint32) + (num_levels uint32) + (sample_count int) ; SDL_GPUSampleCount + (props uint32) ; SDL_PropertiesID + )) + +(define-bstruct SDL_GPUBufferCreateInfo + (struct + (usage uint32) ; SDL_GPUBufferUsageFlags + (size uint32) + (props uint32) ; SDL_PropertiesID + )) + +(define-bstruct SDL_GPUTransferBufferCreateInfo + (struct + (usage uint32) ; SDL_GPUTransferBufferUsage + (size uint32) + (props uint32) ; SDL_PropertiesID + )) + +(define-bstruct SDL_GPURasterizerState + (struct + (fill_mode int) ; SDL_GPUFillMode + (cull_mode int) ; SDL_GPUCullMode + (front_face int) ; SDL_GPUFrontFace + (depth_bias_constant_factor float) + (depth_bias_clamp float) + (depth_bias_slope_factor float) + (enable_depth_bias uint8) ; bool + (enable_depth_clip uint8) ; bool + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUMultisampleState + (struct + (sample_count int) ; SDL_GPUSampleCount + (sample_mask uint32) + (enable_mask uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUDepthStencilState + (struct + (compare_op uint32) ; SDL_GPUCompareOp + (back_stencil_state SDL_GPUStencilOpState) + (front_stencil_state SDL_GPUStencilOpState) + (compare_mask uint8) + (write_mask uint8) + (enable_depth_test uint8) ; bool + (enable_depth_write uint8) ; bool + (enable_stencil_test uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUColorTargetDescription + (struct + (format uint32) ; SDL_GPUTextureFormat + (blend_state SDL_GPUColorTargetBlendState))) + +(define-bstruct SDL_GPUGraphicsPipelineTargetInfo + (struct + (color_target_descriptions (* SDL_GPUColorTargetDescription)) + (num_color_targets uint32) + (depth_stencil_format uint32) ; SDL_GPUTextureFormat + (has_depth_stencil_target uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUGraphicsPipelineCreateInfo + (struct + (vertex_shader (* SDL_GPUShader)) + (fragment_shader (* SDL_GPUShader)) + (vertex_input_state SDL_GPUVertexInputState) + (primitive_type int) ; SDL_GPUPrimitiveType + (rasterizer_state SDL_GPURasterizerState) + (multisample_state SDL_GPUMultisampleState) + (depth_stencil_state SDL_GPUDepthStencilState) + (target_info SDL_GPUGraphicsPipelineTargetInfo) + (props uint32) ; SDL_PropertiesID + )) + +(define-bstruct SDL_GPUComputePipelineCreateInfo + (struct + (code_size size_t) + (code (* uint8)) + (entrypoint (* uint8)) ; char + (format int) ; SDL_GPUShaderFormat + (num_samplers uint32) + (num_readonly_storage_textures uint32) + (num_readonly_storage_buffers uint32) + (num_readwrite_storage_textures uint32) + (num_readwrite_storage_buffers uint32) + (num_uniform_buffers uint32) + (threadcount_x uint32) + (threadcount_y uint32) + (threadcount_z uint32) + (props uint32) ; SDL_PropertiesID + )) + +(define-bstruct SDL_GPUColorTargetInfo + (struct + (texture (* SDL_GPUTexture)) + (mip_level uint32) + (layer_or_depth_plane uint32) + (clear_color SDL_FColor) + (load_op int) ; SDL_GPULoadOp + (store_op int) ; SDL_GPUStoreOp + (resolve_texture (* SDL_GPUTexture)) + (resolve_mip_level uint32) + (resolve_layer uint32) + (cycle uint8) ; bool + (cycle_resolve_texture uint8) ; bool + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUDepthStencilTargetInfo + (struct + (texture (* SDL_GPUTexture)) + (clear_depth float) + (load_op int) ; SDL_GPULoadOp + (store_op int) ; SDL_GPUStoreOp + (stencil_load_op int) ; SDL_GPULoadOp + (stencil_store_op int) ; SDL_GPUStoreOp + (cycle uint8) ; bool + (clear_stencil uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUBlitInfo + (struct + (source SDL_GPUBlitRegion) + (destination SDL_GPUBlitRegion) + (load_op int) ; SDL_GPULoadOp + (clear_color SDL_FColor) + (flip_mode int) ; SDL_FlipMode + (filter int) ; SDL_GPUFilter + (cycle uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUBufferBinding + (struct + (buffer (* SDL_GPUBuffer)) + (offset uint32))) + +(define-bstruct SDL_GPUTextureSamplerBinding + (struct + (texture (* SDL_GPUTexture)) + (sampler (* SDL_GPUSampler)))) + +(define-bstruct SDL_GPUStorageBufferReadWriteBinding + (struct + (buffer (* SDL_GPUBuffer)) + (cycle uint8) ; bool + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-bstruct SDL_GPUStorageTextureReadWriteBinding + (struct + (texture (* SDL_GPUTexture)) + (mip_level uint32) + (layer uint32) + (cycle uint8) + (_ uint8) + (_ uint8) + (_ uint8))) + +(define-sdl SDL_AcquireGPUCommandBuffer '* -> '*) +(define-sdl SDL_AcquireGPUSwapchainTexture '* '* '* '* '* -> bool) +(define-sdl SDL_BeginGPUCopyPass '* -> '*) +(define-sdl SDL_BeginGPURenderPass '* '* uint32 '* -> '*) +(define-sdl SDL_BindGPUGraphicsPipeline '* '*) +(define-sdl SDL_BindGPUVertexBuffers '* uint32 '* uint32) +(define-sdl SDL_BlitGPUTexture '* '*) +(define-sdl SDL_CreateGPUBuffer '* '* -> '*) +(define-sdl SDL_CreateGPUDevice SDL_GPUShaderFormat bool '* -> '*) +(define-sdl SDL_CreateGPUGraphicsPipeline '* '* -> '*) +(define-sdl SDL_CreateGPUShader '* '* -> '*) +(define-sdl SDL_CreateGPUTexture '* '* -> '*) +(define-sdl SDL_CreateGPUTransferBuffer '* '* -> '*) +(define-sdl SDL_ClaimWindowForGPUDevice '* '* -> bool) +(define-sdl SDL_DestroyGPUDevice '*) +(define-sdl SDL_DrawGPUPrimitives '* uint32 uint32 uint32 uint32) +(define-sdl SDL_EndGPUCopyPass '*) +(define-sdl SDL_EndGPURenderPass '*) +(define-sdl SDL_GetGPUDeviceDriver '* -> '*) +(define-sdl SDL_GetGPUDriver int -> '*) +(define-sdl SDL_GetGPUSwapchainTextureFormat '* '* -> SDL_GPUTextureFormat) +(define-sdl SDL_GetNumGPUDrivers -> int) +(define-sdl SDL_GPUTextureSupportsSampleCount '* SDL_GPUTextureFormat SDL_GPUSampleCount -> bool) +(define-sdl SDL_MapGPUTransferBuffer '* '* bool -> '*) +(define-sdl SDL_PushGPUFragmentUniformData '* uint32 '* uint32) +(define-sdl SDL_PushGPUVertexUniformData '* uint32 '* uint32) +(define-sdl SDL_ReleaseGPUBuffer '* '*) +(define-sdl SDL_ReleaseGPUGraphicsPipeline '* '*) +(define-sdl SDL_ReleaseGPUShader '* '*) +(define-sdl SDL_ReleaseGPUTexture '* '*) +(define-sdl SDL_ReleaseGPUTransferBuffer '* '*) +(define-sdl SDL_ReleaseWindowFromGPUDevice '* '*) +(define-sdl SDL_SetGPUBufferName '* '* '*) +(define-sdl SDL_SubmitGPUCommandBuffer '* -> bool) +(define-sdl SDL_UnmapGPUTransferBuffer '* '*) +(define-sdl SDL_UploadToGPUBuffer '* '* '* 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/pixels.scm b/sdl3/bindings/pixels.scm new file mode 100644 index 0000000..19d2420 --- /dev/null +++ b/sdl3/bindings/pixels.scm @@ -0,0 +1,41 @@ +;;; 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_pixels.h. +;; +;;; Code: + +(define-module (sdl3 bindings pixels) + #:use-module (bstruct) + #:use-module (sdl3 bindings utils) + #:use-module (system foreign) + #:export (SDL_Color + SDL_FColor)) + +(define-bstruct SDL_Color + (struct + (r uint8) + (g uint8) + (b uint8) + (a uint8))) + +(define-bstruct SDL_FColor + (struct + (r float) + (g float) + (b float) + (a float))) diff --git a/sdl3/bindings/surface.scm b/sdl3/bindings/surface.scm new file mode 100644 index 0000000..d9ebd15 --- /dev/null +++ b/sdl3/bindings/surface.scm @@ -0,0 +1,36 @@ +;;; 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_surface.h. +;; +;;; Code: + +(define-module (sdl3 bindings surface) + #:use-module (sdl3 bindings utils) + #:export (SDL_FlipMode + symbol->flip-mode + flip-mode->symbol + SDL_FLIP_NONE + SDL_FLIP_HORIZONTAL + SDL_FLIP_VERTICAL)) + +(define-enum SDL_FlipMode + symbol->flip-mode + flip-mode->symbol + (none SDL_FLIP_NONE) + (horizontal SDL_FLIP_HORIZONTAL) + (vertical SDL_FLIP_VERTICAL)) diff --git a/sdl3/bindings/utils.scm b/sdl3/bindings/utils.scm new file mode 100644 index 0000000..bdc6942 --- /dev/null +++ b/sdl3/bindings/utils.scm @@ -0,0 +1,133 @@ +;;; 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 (ice-9 match) + #:use-module (sdl3 config) + #:use-module (sdl3 guardian) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-9) + #:use-module (srfi srfi-9 gnu) + #:use-module (system foreign) + #:use-module (system foreign-library) + #:export (bool + define-enum + define-bitmask + define-sdl + define-sdl-pointer-type + define-symbol<->enum + flags->bitmask)) + +;; Type aliases: +(define bool uint8) + +(define-syntax enum-case + (syntax-rules () + ((_ x) (error "no matching enum" x)) + ((_ x (var val) . rest) + (if (eq? x var) val (enum-case x . rest))))) + +(define-syntax define-enum + (lambda (stx) + (syntax-case stx () + ((_ type-name atom->enum enum->atom (atom name . id) ...) + (every identifier? #'(name ...)) + (with-syntax (((defs ...) + (let lp ((i 0) (specs #'((name . id) ...))) + (syntax-case specs () + (() '()) + (((name) . rest) + (cons #`(define name #,i) + (lp (1+ i) #'rest))) + (((name id) . rest) + (cons #`(define name id) + (lp (1+ (syntax->datum #'id)) #'rest))))))) + #'(begin + (define type-name int) + defs ... + (define (atom->enum x) + (match x ('atom name) ...)) + (define (enum->atom x) + (enum-case x (name 'atom) ...)))))))) + +(define-syntax bitmask-case + (syntax-rules () + ((_ x) (error "no matching flag" x)) + ((_ x (var val) . rest) + (let ((cont (lambda () (bitmask-case x . rest)))) + (if (zero? (logand x var)) + (cont) + (cons val (cont))))))) + +(define-syntax define-bitmask + (lambda (stx) + (syntax-case stx () + ((_ (type-name c-type) + symbols->bitmask + bitmask->symbols + (sym name) ...) + (every identifier? #'(name ...)) + (with-syntax (((defs ...) + (let lp ((i 1) (names #'(name ...))) + (syntax-case names () + (() '()) + ((name . rest) + (cons #`(define name #,i) + (lp (ash i 1) #'rest))))))) + #'(begin + (define type-name c-type) + defs ... + (define (symbols->bitmask flags) + (fold (lambda (flag result) + (logior (match flag ('sym name) ...) + result)) + 0 flags)) + (define (bitmask->symbols x) + (bitmask-case x (name 'sym) ...)))))))) + + +(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 + (field accessors ...) ...) + (begin + (define-record-type name + (ctor ptr) + pred + (ptr unwrap) + (destroyed? destroyed-pred set-destroyed) + (field accessors ...) ...) + (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..40ee4cc --- /dev/null +++ b/sdl3/bindings/video.scm @@ -0,0 +1,103 @@ +;;; 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_DisplayID + SDL_WindowID + + 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 + SDL_GetWindowSizeInPixels)) + +(define SDL_DisplayID uint32) +(define SDL_WindowID uint32) + +(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 '*) +(define-sdl SDL_GetWindowSizeInPixels '* '* '* -> bool) |