You are looking at historical revision 32878 of this page. It may differ significantly from its current revision.

sdl2

Introduction

The sdl2 egg provides bindings to Simple DirectMedia Layer version 2 (SDL2). SDL is a popular library used in games and other media-rich software.

The sdl2 egg provides a programmer-friendly, convenient, and CHICKEN-idiomatic interface to SDL2. It takes care of the annoying low-level C stuff for you, so you can focus on making your game.

If a feature you need is not yet available, please file a feature request or contact a maintainer, so we can prioritize adding it.

Project / Source Code Repository
https://gitlab.com/chicken-sdl2/chicken-sdl2
Issue Tracker
https://gitlab.com/chicken-sdl2/chicken-sdl2/issues
Maintainer
John Croisant (john+chicken at croisant dot net)
License
BSD 2-Clause

Help Wanted!

This egg needs volunteers to help with several things:

If you wish to help in any way, please contact the project maintainer.

Requirements

The sdl2 egg requires Simple DirectMedia Layer version 2.0.0 or higher. It will not work with older versions of SDL.

The unit tests depend on the test egg, and many demos and examples depend on the miscmacros egg. Some demos and examples have other dependencies as well.

Installation

ATTENTION: The sdl2 egg has not been released yet. For now, you must download it from its source code repository and follow the instructions in the README.

When installing the egg, you should set the SDL2_FLAGS environment variable to a string of compiler flags to be used when compiling the egg. If you have the sdl2-config helper program installed on your system, you can set appropriate flags and install the extension like so (notice these are back ticks, not quotes):

export SDL2_FLAGS=`sdl2-config --cflags --libs`
chicken-install sdl2

If you do not have the sdl2-config helper program installed on your computer, you may manually specify SDL-related compiler flags (notice these are double quotes, not back ticks):

export SDL2_FLAGS="-I/usr/local/include/SDL2 -L/usr/local/lib -lSDL2"
chicken-install sdl2

The SDL2_FLAGS environment variable only needs to be set during installation of the egg, not during normal use.

Usage and Examples

It is recommended that you import the sdl2 module using the prefix "sdl2:", like so:

(use (prefix sdl2 sdl2:))
(sdl2:init! '(everything))
(sdl2:create-window! "Test" 0 0 600 400)
(sdl2:delay! 1000)
(sdl2:quit!)

The demos directory contains small programs demonstrating how to use various features of sdl2. E.g. to compile and run the basics demo:

csc demos/basics.scm
demos/basics

The chicken-sdl2-examples repository contains complete example games and programs made with sdl2.

The sdl2-image egg provides bindings to version 2 of the SDL_image library. It is built to be compatible with sdl2.

The sdl-base egg provides bindings to older versions of SDL. Its API is not cross-compatible with sdl2.

Version History

The sdl2 egg has not yet been released. Coming soon!

Backwards Compatibility and Stability

The sdl2 egg follows "semantic versioning". The API is not stable until version 1.0 is released. That means the API may change in ways that break backwards compatibility with previous versions. After version 1.0 is released, the API will remain stable (no backwards-incompatible changes) until the next new major version (e.g. going from version 1.x to 2.0, or 2.x to 3.0).

The sdl2 egg's API is not cross-compatible with the sdl-base egg.

API

Conventions

Enums

The sdl2 egg uses symbols instead of integer constants, for things like event types, keyboard keys, and init flags. See the enum tables for details.

Struct Record Types

The sdl2 egg has many "struct record types", which are record types that wrap a pointer to a certain kind of C structure from SDL. For example, the sdl2:surface record type wraps a pointer to an SDL_Surface struct.

Each struct record type has some associated procedures, which get or set the value of a certain field of the underlying C struct.

Struct Memory Management

Some struct record types have procedures for allocating or freeing an instance of that type. Each type that can be allocated has two "make" procedures:

Certain other procedures that return new struct records also follow this convention, for example load-bmp vs. load-bmp*.

In general, it is recommended to create managed struct records, so that you don't have to worry about manually freeing them. However, there is a slight performance overhead for each managed struct record, so if you are creating and destroying very many struct records, you can improve performance by creating unmanaged struct records and manually freeing them when you are done with them. (But be careful! If you forget to free them, your program will leak memory.)

If you create an unmanaged struct record but later change your mind, you can start managing it by using set-finalizer! with the appropriate "free" procedure. (Note: it is not currently possible to stop managing a struct record.) For example:

;; Allocate an unmanaged sdl2:event.
(let ((my-event (sdl2:make-event*)))
  ;; Overwrite its data with the next pending event.
  (sdl2:wait-event! my-event)

  (case (sdl2:event-type my-event)
    ;; Put keyboard events in a queue for later processing. We aren't
    ;; sure how long it will live, so start managing it, to be safe.
    ((key-down key-up)
     (set-finalizer! my-event sdl2:free-event!)
     (put-in-queue my-event))
    ;; If it is any other type of event, perform an immediate action
    ;; on it, then free it.
    (else
     (perform-immediate-action my-event)
     (sdl2:free-event! my-event))))

It is safe to manually free managed struct records. In fact, doing so can be beneficial to your program's memory footprint and performance, because there will be less memory waiting to be freed by the garbage collector. For example:

(let ((my-surf (sdl2:make-surface 800 600 32)))
  ;; ... do stuff with my-surf ...
  ;; Once you are done with my-surf, manually free it.
  (sdl2:free-surface! my-surf))

As soon as you free a struct record, its pointer will be set to null, and it will no longer be usable for most purposes. You cannot get or set its fields, or pass it as an argument to most procedures. So be careful not to free struct records that you still want to use!

Some struct record types, such as sdl2:window, are not managed in this way. Instead, you use certain SDL functions to work with them, such as create-window! and destroy-window!.

[procedure] (struct-null? record) → boolean

Returns #t if the given record is wrapping a null pointer (i.e. a pointer with memory address 0). This procedure can be used with any struct record type provided by this library.

There are two common reasons why a record might be wrapping a null pointer:

It is an error to get or set any field of a record that is wrapping a null pointer. And, it is an error to pass null struct records to many procedures. So, you can use this procedure to check whether it is safe to use the record.

sdl2:audio-cvt

sdl2:audio-cvt is a record type that wraps a pointer to an SDL_AudioCVT struct.

[procedure] (audio-cvt? obj) → boolean

Returns #t if obj is an sdl2:audio-cvt.

[procedure] (audio-cvt-needed audio-cvt) → fixnum

Get the sdl2:audio-cvt's needed field, as an integer.

[procedure] (audio-cvt-src-format audio-cvt) → symbol

Get the sdl2:audio-cvt's src-format field, as an audio format symbol.

[procedure] (audio-cvt-src-format-raw audio-cvt) → fixnum

Get the sdl2:audio-cvt's src-format field, as an integer. See also audio-cvt-src-format.

[procedure] (audio-cvt-dst-format audio-cvt) → symbol

Get the sdl2:audio-cvt's dst-format field, as an audio format symbol.

[procedure] (audio-cvt-dst-format-raw audio-cvt) → fixnum

Get the sdl2:audio-cvt's dst-format field, as an integer. See also audio-cvt-dst-format.

[procedure] (audio-cvt-rate-incr audio-cvt) → double

Get the sdl2:audio-cvt's rate-incr field, as a double precision floating point number.

[procedure] (audio-cvt-buf-raw audio-cvt) → pointer

Get the sdl2:audio-cvt's buf field, as a pointer to a C array of Uint8 numbers. Use audio-cvt-len to get the length of the array.

[procedure] (audio-cvt-len audio-cvt) → fixnum

Get the sdl2:audio-cvt's len field, as an integer. This is the length of the array returned by audio-cvt-buf-raw.

[procedure] (audio-cvt-len-cvt audio-cvt) → fixnum

Get the sdl2:audio-cvt's len-cvt field, as an integer.

[procedure] (audio-cvt-len-mult audio-cvt) → fixnum

Get the sdl2:audio-cvt's len-mult field, as an integer.

[procedure] (audio-cvt-len-ratio audio-cvt) → double

Get the sdl2:audio-cvt's len-ratio field, as a double precision floating point number.

sdl2:audio-spec

sdl2:audio-spec is a record type that wraps a pointer to an SDL_AudioSpec struct.

[procedure] (audio-spec? obj) → boolean

Returns #t if obj is an sdl2:audio-spec.

[procedure] (audio-spec-freq audio-spec) → fixnum
[setter] (set! (audio-spec-freq audio-spec) val)
[setter] (audio-spec-freq-set! audio-spec freq)

Get or set the sdl2:audio-spec's freq field, as an integer (int).

[procedure] (audio-spec-format audio-spec) → symbol
[setter] (set! (audio-spec-format audio-spec) format)
[setter] (audio-spec-format-set! audio-spec format)

Get or set the sdl2:audio-spec's format field, as an audio format symbol. When setting, either a symbol or an integer will be accepted.

[procedure] (audio-spec-format-raw audio-spec) → fixnum
[setter] (set! (audio-spec-format-raw audio-spec) val)

Get or set the sdl2:audio-spec's format field, as an integer. See also audio-spec-format.

[procedure] (audio-spec-channels audio-spec) → fixnum
[setter] (set! (audio-spec-channels audio-spec) val)
[setter] (audio-spec-channels-set! audio-spec channels)

Get or set the sdl2:audio-spec's channels field, as an integer (Uint8).

[procedure] (audio-spec-silence audio-spec) → fixnum

Get the sdl2:audio-spec's silence field, as an integer (Uint8).

[procedure] (audio-spec-samples audio-spec) → fixnum
[setter] (set! (audio-spec-samples audio-spec) val)
[setter] (audio-spec-samples-set! audio-spec samples)

Get or set the sdl2:audio-spec's samples field, as an integer (Uint16).

[procedure] (audio-spec-size audio-spec) → fixnum

Get the sdl2:audio-spec's size field, as an integer (Uint32).

[procedure] (audio-spec-userdata-raw audio-spec) → pointer
[setter] (set! (audio-spec-userdata-raw audio-spec) val)
[setter] (audio-spec-userdata-raw-set! audio-spec userdata)

Get or set the sdl2:audio-spec's userdata field, as a pointer.

sdl2:color

sdl2:color is a record type that wraps a pointer to an SDL_Color struct.

[procedure] (color? obj) → boolean
[procedure] (colour? obj) → boolean

Returns #t if obj is an sdl2:color.

[procedure] (make-color #!optional r g b a) → sdl2:color
[procedure] (make-colour #!optional r g b a) → sdl2:color

Allocate and initialize a new managed sdl2:color record.

r g b and a are the red, green, blue, and alpha (opacity) fields of the color. They must be integers in the range 0 to 255 (inclusive). r g and b default to 0. a defaults to 255 (full opacity).

[procedure] (make-color* #!optional r g b a) → sdl2:color
[procedure] (make-colour* #!optional r g b a) → sdl2:color

Allocate and initialize a new unmanaged sdl2:color record. This is similar to make-color, except you must call free-color! on the record when you are done with it.

[procedure] (free-color! color)
[procedure] (free-colour! color)

Free the memory of the sdl2:color's underlying struct. color's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:color records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (color-r color) → fixnum
[procedure] (colour-r color) → fixnum
[setter] (set! (color-r color) r)
[setter] (set! (colour-r color) r)
[setter] (color-r-set! color r)
[setter] (colour-r-set! color r)

Get or set the sdl2:color's r (red) field, as an integer in the range 0 to 255 (inclusive).

[procedure] (color-g color) → fixnum
[procedure] (colour-g color) → fixnum
[setter] (set! (color-g color) g)
[setter] (set! (colour-g color) g)
[setter] (color-g-set! color g)
[setter] (colour-g-set! color g)

Get or set the sdl2:color's g (green) field, as an integer in the range 0 to 255 (inclusive).

[procedure] (color-b color) → fixnum
[procedure] (colour-b color) → fixnum
[setter] (set! (color-b color) b)
[setter] (set! (colour-b color) b)
[setter] (color-b-set! color b)
[setter] (colour-b-set! color b)

Get or set the sdl2:color's b (blue) field, as an integer in the range 0 to 255 (inclusive).

[procedure] (color-a color) → fixnum
[procedure] (colour-a color) → fixnum
[setter] (set! (color-a color) a)
[setter] (set! (colour-a color) a)
[setter] (color-a-set! color a)
[setter] (colour-a-set! color a)

Get or set the sdl2:color's a (alpha) field, as an integer in the range 0 to 255 (inclusive).

[setter] (color-set! color #!optional r g b a) → color
[setter] (colour-set! color #!optional r g b a) → color

Convenient way of setting multiple fields of the sdl2:color. Any arguments that are #f will cause no change to that field. E.g. (color-set! my-color 42 #f 255 #f) will set the r field to 42 and the b field to 255, but will not change the g or a fields. Returns color after it is modified.

[procedure] (color->list color) → list of fixnums
[procedure] (colour->list color) → list of fixnums

Returns a list (r g b a) containing the value of each field of the sdl2:color.

[procedure] (color=? color1 color2) → boolean

Returns #t if both sdl2:color records have the same values.

[procedure] (copy-color color) → sdl2:color

Returns a new managed sdl2:color with the same values as the given sdl2:color.

[procedure] (copy-color* color) → sdl2:color

Returns a new unmanaged sdl2:color with the same values as the given sdl2:color. You must call free-color! on the record when you are done with it.

sdl2:cursor

sdl2:cursor is a record type that wraps a pointer to an SDL_Cursor struct.

[procedure] (cursor? obj) → boolean

Returns #t if obj is an sdl2:cursor.

sdl2:display-mode

sdl2:display-mode is a record type that wraps a pointer to an SDL_DisplayMode struct.

[procedure] (display-mode? obj) → boolean

Returns #t if obj is an sdl2:display-mode.

[procedure] (make-display-mode #!optional format w h refresh-rate) → sdl2:display-mode

Allocate and initialize a new managed sdl2:display-mode record.

format defaults to 'unknown. It must be a pixel format symbol or equivalent integer.

w, h, and refresh-rate default to 0. They must be integers.

[procedure] (make-display-mode* #!optional format w h refresh-rate) → sdl2:display-mode

Allocate and initialize a new unmanaged sdl2:display-mode record. This is similar to make-display-mode, except you must call free-display-mode! on the record when you are done with it.

[procedure] (free-display-mode! display-mode)

Free the memory of the sdl2:display-mode's underlying struct. display-mode's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:display-mode records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (display-mode-format display-mode) → symbol
[setter] (set! (display-mode-format display-mode) val)
[setter] (display-mode-format-set! display-mode)

Get or set the sdl2:display-mode's format field, as a pixel format symbol.

[procedure] (display-mode-format-raw display-mode) → fixnum
[setter] (set! (display-mode-format-raw display-mode) val)

Get or set the sdl2:display-mode's format field, as an integer. See also display-mode-format.

[procedure] (display-mode-w display-mode) → fixnum
[setter] (set! (display-mode-w display-mode) val)
[setter] (display-mode-w-set! display-mode)

Get or set the sdl2:display-mode's w field, as an integer.

[procedure] (display-mode-h display-mode) → fixnum
[setter] (set! (display-mode-h display-mode) val)
[setter] (display-mode-h-set! display-mode)

Get or set the sdl2:display-mode's h field, as an integer.

[procedure] (display-mode-refresh-rate display-mode) → fixnum
[setter] (set! (display-mode-refresh-rate display-mode) val)
[setter] (display-mode-refresh-rate-set! display-mode)

Get or set the sdl2:display-mode's refresh-rate field, as an integer.

sdl2:event

sdl2:event is a record type that wraps a pointer to an SDL_Event. There are many specific event structs in SDL, and the sdl2:event record type wraps them all. Each event struct has a corresponding variant of sdl2:event, described below. Each variant has one or more associated event type symbols.

Variant of sdl2:event Underlying struct Event type symbol(s)
sdl2:controller-axis-event SDL_ControllerAxisEvent controller-axis-motion
sdl2:controller-button-event SDL_ControllerButtonEvent controller-button-down
controller-button-up
sdl2:controller-device-event SDL_ControllerDeviceEvent controller-device-added
controller-device-removed
controller-device-remapped
sdl2:dollar-gesture-event SDL_DollarGestureEvent dollar-gesture
dollar-record
sdl2:drop-event SDL_DropEvent drop-file
sdl2:joy-axis-event SDL_JoyAxisEvent joy-axis-motion
sdl2:joy-ball-event SDL_JoyBallEvent joy-ball-motion
sdl2:joy-button-event SDL_JoyButtonEvent joy-button-down
joy-button-up
sdl2:joy-device-event SDL_JoyDeviceEvent joy-device-added
joy-device-removed
sdl2:joy-hat-event SDL_JoyHatEvent joy-hat-motion
sdl2:keyboard-event SDL_KeyboardEvent key-down
key-up
sdl2:mouse-button-event SDL_MouseButtonEvent mouse-button-down
mouse-button-up
sdl2:mouse-motion-event SDL_MouseMotionEvent mouse-motion
sdl2:mouse-wheel-event SDL_MouseWheelEvent mouse-wheel
sdl2:multi-gesture-event SDL_MultiGestureEvent multi-gesture
sdl2:quit-event SDL_QuitEvent quit
sdl2:sys-wm-event SDL_SysWMEvent sys-wm
sdl2:text-editing-event SDL_TextEditingEvent text-editing
sdl2:text-input-event SDL_TextInputEvent text-input
sdl2:touch-finger-event SDL_TouchFingerEvent finger-down
finger-up
finger-motion
sdl2:user-event SDL_UserEvent Call register-events! to register your own custom event type symbols
sdl2:window-event SDL_WindowEvent window
[procedure] (event? obj) → boolean

Returns #t if obj is any variant of sdl2:event.

[procedure] (make-event #!optional type) → sdl2:event

Allocate and set the type of a new managed sdl2:event record.

type defaults to 'first. It must be a event type symbol or equivalent integer.

[procedure] (make-event* #!optional type) → sdl2:event

Allocate and set the type of a new unmanaged sdl2:event record. This is similar to make-event, except you must call free-event! on the record when you are done with it.

[procedure] (free-event! event)

Free the memory of the sdl2:event's underlying struct. You can call this procedure with any variant of sdl2:event. event's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:event records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (event-type event) → symbol
[setter] (set! (event-type event) val)
[setter] (event-type-set! event val)

Get or set the sdl2:event's event type, as an event type symbol. You can use this procedure with any variant of sdl2:event. Setting this will change what variant of sdl2:event it is. E.g. if you set it to 'key-down, the event will become an sdl2:keyboard-event.

[procedure] (event-type-raw event) → fixnum
[setter] (set! (event-type-raw event) val)
[setter] (event-type-raw-set! event val)

Get or set the sdl2:event's event type, as a nonnegative integer. You can use this procedure with any variant of sdl2:event. See also event-type.

[procedure] (event-timestamp event) → fixnum
[setter] (set! (event-timestamp event) val)
[setter] (event-timestamp-set! event val)

Get or set the event timestamp, as a nonnegative integer representing the time that the event occurred, in milliseconds since the SDL timer system was initialized. You can use this procedure with any variant of sdl2:event.

sdl2:controller-axis-event

sdl2:controller-axis-event is a variant of sdl2:event that wraps a pointer to an SDL_ControllerAxisEvent.

[procedure] (controller-axis-event? obj) → boolean

Returns #t if obj is an sdl2:controller-axis-event.

[procedure] (controller-axis-event-which event) → fixnum
[setter] (set! (controller-axis-event-which event) val)
[setter] (controller-axis-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the controller (joystick) that the event is related to.

[procedure] (controller-axis-event-axis event) → fixnum
[setter] (set! (controller-axis-event-axis event) val)
[setter] (controller-axis-event-axis-set! event val)

Get or set the event's axis field, as an integer indicating the axis that the event is related to. E.g. 0 indicates the first axis on the controller.

[procedure] (controller-axis-event-value event) → fixnum
[setter] (set! (controller-axis-event-value event) val)
[setter] (controller-axis-event-value-set! event val)

Get or set the event's value field, as an integer in the range -32768 to 32767 (inclusive), indicating the new value of the axis.

sdl2:controller-button-event

sdl2:controller-button-event is a variant of sdl2:event that wraps a pointer to an SDL_ControllerButtonEvent.

[procedure] (controller-button-event? obj) → boolean

Returns #t if obj is an sdl2:controller-button-event.

[procedure] (controller-button-event-which event) → fixnum
[setter] (set! (controller-button-event-which event) val)
[setter] (controller-button-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the controller (joystick) that the event is related to.

[procedure] (controller-button-event-button event) → fixnum
[setter] (set! (controller-button-event-button event) val)
[setter] (controller-button-event-button-set! event val)

Get or set the event's button field, as an integer indicating the button that the event is related to. E.g. 0 indicates the first button on the controller.

[procedure] (controller-button-event-state event) → boolean
[setter] (set! (controller-button-event-state event) val)
[setter] (controller-button-event-state-set! event val)

Get or set the event's state field, as a boolean indicating whether the button was pressed (#t) or released (#f). You can also find out by checking the event type: 'controller-button-down for pressed, or 'controller-button-up for released.

sdl2:controller-device-event

sdl2:controller-device-event is a variant of sdl2:event that wraps a pointer to an SDL_ControllerDeviceEvent.

[procedure] (controller-device-event? obj) → boolean

Returns #t if obj is an sdl2:controller-device-event.

[procedure] (controller-device-event-which event) → fixnum
[setter] (set! (controller-device-event-which event) val)
[setter] (controller-device-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the controller (joystick) that the event is related to.

sdl2:dollar-gesture-event

sdl2:dollar-gesture-event is a variant of sdl2:event that wraps a pointer to an SDL_DollarGestureEvent.

[procedure] (dollar-gesture-event? obj) → boolean

Returns #t if obj is an sdl2:dollar-gesture-event.

[procedure] (dollar-gesture-event-touch-id event) → fixnum
[setter] (set! (dollar-gesture-event-touch-id event) val)
[setter] (dollar-gesture-event-touch-id-set! event val)

Get or set the event's touch-id field, as an integer indicating the ID number of the touch device this event is related to.

[procedure] (dollar-gesture-event-gesture-id event) → fixnum
[setter] (set! (dollar-gesture-event-gesture-id event) val)
[setter] (dollar-gesture-event-gesture-id-set! event val)

Get or set the event's gesture-id field, as an integer indicating the ID number of the closest gesture to the performed stroke.

[procedure] (dollar-gesture-event-num-fingers event) → fixnum
[setter] (set! (dollar-gesture-event-num-fingers event) val)
[setter] (dollar-gesture-event-num-fingers-set! event val)

Get or set the event's num-fingers field, as an integer indicating the number of fingers used to draw the stroke.

[procedure] (dollar-gesture-event-error event) → float
[setter] (set! (dollar-gesture-event-error event) val)
[setter] (dollar-gesture-event-error-set! event val)

Get or set the event's error field, as a float indicating the difference between the gesture template and the actual performed gesture. Lower error is a better match.

[procedure] (dollar-gesture-event-x event) → float
[setter] (set! (dollar-gesture-event-x event) val)
[setter] (dollar-gesture-event-x-set! event val)

Get or set the event's x field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized X coordinate of the center of the gesture.

[procedure] (dollar-gesture-event-y event) → float
[setter] (set! (dollar-gesture-event-y event) val)
[setter] (dollar-gesture-event-y-set! event val)

Get or set the event's y field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized Y coordinate of the center of the gesture.

sdl2:drop-event

sdl2:drop-event is a variant of sdl2:event that wraps a pointer to an SDL_DropEvent.

[procedure] (drop-event? obj) → boolean

Returns #t if obj is an sdl2:drop-event.

[procedure] (drop-event-file event) → string
[setter] (set! (drop-event-file event) val)
[setter] (drop-event-file-set! event val)

Get or set the event's file field, as a string indicating the path to a file that was dropped onto the application.

sdl2:joy-axis-event

sdl2:joy-axis-event is a variant of sdl2:event that wraps a pointer to an SDL_JoyAxisEvent.

[procedure] (joy-axis-event? obj) → boolean

Returns #t if obj is an sdl2:joy-axis-event.

[procedure] (joy-axis-event-which event) → fixnum
[setter] (set! (joy-axis-event-which event) val)
[setter] (joy-axis-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the joystick that the event is related to.

[procedure] (joy-axis-event-axis event) → fixnum
[setter] (set! (joy-axis-event-axis event) val)
[setter] (joy-axis-event-axis-set! event val)

Get or set the event's axis field, as an integer indicating the axis that the event is related to. E.g. 0 indicates the first axis on the joystick.

[procedure] (joy-axis-event-value event) → fixnum
[setter] (set! (joy-axis-event-value event) val)
[setter] (joy-axis-event-value-set! event val)

Get or set the event's value field, as an integer in the range -32768 to 32767 (inclusive), indicating the new value of the axis.

sdl2:joy-ball-event

sdl2:joy-ball-event is a variant of sdl2:event that wraps a pointer to an SDL_JoyBallEvent.

[procedure] (joy-ball-event? obj) → boolean

Returns #t if obj is an sdl2:joy-ball-event.

[procedure] (joy-ball-event-which event) → fixnum
[setter] (set! (joy-ball-event-which event) val)
[setter] (joy-ball-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the joystick that the event is related to.

[procedure] (joy-ball-event-ball event) → fixnum
[setter] (set! (joy-ball-event-ball event) val)
[setter] (joy-ball-event-ball-set! event val)

Get or set the event's ball field, as an integer indicating the trackball that the event is related to. E.g. 0 indicates the first trackball on the joystick.

[procedure] (joy-ball-event-xrel event) → fixnum
[setter] (set! (joy-ball-event-xrel event) val)
[setter] (joy-ball-event-xrel-set! event val)

Get or set the event's xrel field, as an integer (possibly negative) indicating how the trackball's X position changed relative to its previous position.

[procedure] (joy-ball-event-yrel event) → fixnum
[setter] (set! (joy-ball-event-yrel event) val)
[setter] (joy-ball-event-yrel-set! event val)

Get or set the event's yrel field, as an integer (possibly negative) indicating how the trackball's Y position changed relative to its previous position.

sdl2:joy-button-event

sdl2:joy-button-event is a variant of sdl2:event that wraps a pointer to an SDL_JoyButtonEvent.

[procedure] (joy-button-event? obj) → boolean

Returns #t if obj is an sdl2:joy-button-event.

[procedure] (joy-button-event-which event) → fixnum
[setter] (set! (joy-button-event-which event) val)
[setter] (joy-button-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the joystick that the event is related to.

[procedure] (joy-button-event-button event) → fixnum
[setter] (set! (joy-button-event-button event) val)
[setter] (joy-button-event-button-set! event val)

Get or set the event's button field, as an integer indicating the button that the event is related to. E.g. 0 indicates the first button on the joystick.

[procedure] (joy-button-event-state event) → boolean
[setter] (set! (joy-button-event-state event) val)
[setter] (joy-button-event-state-set! event val)

Get or set the value of the event's state field, as a boolean indicating whether the button was pressed (#t) or released (#f). You can also find out by checking the event type: 'joy-button-down for pressed, or 'joy-button-up for released.

sdl2:joy-device-event

sdl2:joy-device-event is a variant of sdl2:event that wraps a pointer to an SDL_JoyDeviceEvent.

[procedure] (joy-device-event? obj) → boolean

Returns #t if obj is an sdl2:joy-device-event.

[procedure] (joy-device-event-which event) → fixnum
[setter] (set! (joy-device-event-which event) val)
[setter] (joy-device-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the joystick that the event is related to.

sdl2:joy-hat-event

sdl2:joy-hat-event is a variant of sdl2:event that wraps a pointer to an SDL_JoyHatEvent.

[procedure] (joy-hat-event? obj) → boolean

Returns #t if obj is an sdl2:joy-hat-event.

[procedure] (joy-hat-event-which event) → fixnum
[setter] (set! (joy-hat-event-which event) val)
[setter] (joy-hat-event-which-set! event val)

Get or set the event's which field, as an integer indicating the device index of the joystick that the event is related to.

[procedure] (joy-hat-event-hat event) → fixnum
[setter] (set! (joy-hat-event-hat event) val)
[setter] (joy-hat-event-hat-set! event val)

Get or set the event's hat field, as an integer indicating the hat switch that the event is related to. E.g. 0 indicates the first hat switch on the joystick.

[procedure] (joy-hat-event-value event) → symbol
[setter] (set! (joy-hat-event-value event) val)
[setter] (joy-hat-event-value-set! event val)

Get or set the event's value field, as a joystick hat position symbol indicating the new position of the hat switch.

[procedure] (joy-hat-event-value-raw event) → fixnum
[setter] (set! (joy-hat-event-value-raw event) val)
[setter] (joy-hat-event-value-raw-set! event val)

Get or set the event's value field, as an integer indicating the new position of the hat switch. See also joy-hat-event-value.

sdl2:keyboard-event

sdl2:keyboard-event is a variant of sdl2:event that wraps a pointer to an SDL_KeyboardEvent.

[procedure] (keyboard-event? obj) → boolean

Returns #t if obj is an sdl2:keyboard-event.

[procedure] (keyboard-event-window-id event) → fixnum
[setter] (set! (keyboard-event-window-id event) val)
[setter] (keyboard-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window that had keyboard focus at the time this event occurred, or 0 if no sdl2:window had keyboard focus.

[procedure] (keyboard-event-state event) → boolean
[setter] (set! (keyboard-event-state event) val)
[setter] (keyboard-event-state-set! event val)

Get or set the event's state field, as a boolean indicating whether the key was pressed (#t) or released (#f). You can also find out by checking the event type: 'key-down for pressed, or 'key-up for released.

[procedure] (keyboard-event-repeat event) → fixnum
[setter] (set! (keyboard-event-repeat event) val)
[setter] (keyboard-event-repeat-set! event val)

Get or set the event's repeat field, as a integer. Non-zero indicates that this is a key repeat, caused by the user pressing and holding the key for some time. Zero indicates this is not a key repeat.

[procedure] (keyboard-event-keysym event) → sdl2:keysym
[setter] (set! (keyboard-event-keysym event) val)
[setter] (keyboard-event-keysym-set! event val)

Get or set the event's keysym field, as an sdl2:keysym indicating the key that was pressed or released. The getter returns a copy of the sdl2:keysym stored in the event. Modifying the returned sdl2:keysym will not modify the event, but setting this field to a sdl2:keysym will modify the event.

Instead of using this procedure, it is more efficient and convenient to directly access the fields of the event's sdl2:keysym, using these procedures:

[procedure] (keyboard-event-scancode event) → symbol
[setter] (set! (keyboard-event-scancode event) val)
[setter] (keyboard-event-scancode-set! event val)

Get or set the scancode field of the event's keysym field, as a keyboard scancode symbol indicating the key that was pressed or released. Setting this will modify the event.

[procedure] (keyboard-event-scancode-raw event) → fixnum
[setter] (set! (keyboard-event-scancode-raw event) val)
[setter] (keyboard-event-scancode-raw-set! event val)

Get or set the scancode field of the event's keysym field, as an integer indicating the key that was pressed or released. Setting this will modify the event. See also keyboard-event-scancode.

[procedure] (keyboard-event-sym event) → symbol
[setter] (set! (keyboard-event-sym event) val)
[setter] (keyboard-event-sym-set! event val)

Get or set the sym field of the event's keysym field, as a keyboard keycode symbol indicating the key that was pressed or released. Setting this will modify the event.

[procedure] (keyboard-event-sym-raw event) → fixnum
[setter] (set! (keyboard-event-sym-raw event) val)
[setter] (keyboard-event-sym-raw-set! event val)

Get or set the sym field of the event's keysym field, as an integer indicating the key that was pressed or released. Setting this will modify the event. See also keyboard-event-sym.

[procedure] (keyboard-event-mod event) → list of symbols
[setter] (set! (keyboard-event-mod event) val)
[setter] (keyboard-event-mod-set! event val)

Get or set the sym field of the event's keysym field, as a list of zero or more keyboard modifier symbols, indicating the modifier keys that were being pressed at the time the event occurred. Setting this will modify the event.

[procedure] (keyboard-event-mod-raw event) → fixnum
[setter] (set! (keyboard-event-mod-raw event) val)
[setter] (keyboard-event-mod-raw-set! event val)

Get or set the sym field of the event's keysym field, as an integer bitfield, indicating the modifier keys that were being pressed at the time the event occurred. Setting this will modify the event. See also keyboard-event-mod.

sdl2:mouse-button-event

sdl2:mouse-button-event is a variant of sdl2:event that wraps a pointer to an SDL_MouseButtonEvent.

[procedure] (mouse-button-event? obj) → boolean

Returns #t if obj is an sdl2:mouse-button-event.

[procedure] (mouse-button-event-window-id event) → fixnum
[setter] (set! (mouse-button-event-window-id event) val)
[setter] (mouse-button-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window that had mouse focus at the time this event occurred, or 0 if no sdl2:window had mouse focus.

[procedure] (mouse-button-event-which event) → fixnum
[setter] (set! (mouse-button-event-which event) val)
[setter] (mouse-button-event-which-set! event val)

Get or set the event's which field, as an integer indicating the mouse instance ID.

[procedure] (mouse-button-event-button event) → symbol
[setter] (set! (mouse-button-event-button event) val)
[setter] (mouse-button-event-button-set! event val)

Get or set the event's button field, as a mouse button symbol indicating the button that the event is related to:

[procedure] (mouse-button-event-button-raw event) → fixnum
[setter] (set! (mouse-button-event-button-raw event) val)
[setter] (mouse-button-event-button-raw-set! event val)

Get or set the event's button field, as an integer indicating the button that the event is related to. See also mouse-button-event-button.

[procedure] (mouse-button-event-state event) → boolean
[setter] (set! (mouse-button-event-state event) val)
[setter] (mouse-button-event-state-set! event val)

Get or set the event's state field, as a boolean indicating whether the button was pressed (#t) or released (#f). You can also find out by checking the event type: 'mouse-button-down for pressed, or 'mouse-button-up for released.

[procedure] (mouse-button-event-x event) → fixnum
[setter] (set! (mouse-button-event-x event) val)
[setter] (mouse-button-event-x-set! event val)

Get or set the event's x field, as an integer indicating the X position (in pixels) of the mouse at the time this event occurred.

[procedure] (mouse-button-event-y event) → fixnum
[setter] (set! (mouse-button-event-y event) val)
[setter] (mouse-button-event-y-set! event val)

Get or set the event's y field, as an integer indicating the Y position (in pixels) of the mouse at the time this event occurred.

sdl2:mouse-motion-event

sdl2:mouse-motion-event is a variant of sdl2:event that wraps a pointer to an SDL_MouseMotionEvent.

[procedure] (mouse-motion-event? obj) → boolean

Returns #t if obj is an sdl2:mouse-motion-event.

[procedure] (mouse-motion-event-window-id event) → fixnum
[setter] (set! (mouse-motion-event-window-id event) val)
[setter] (mouse-motion-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window that had mouse focus at the time this event occurred, or 0 if no sdl2:window had mouse focus.

[procedure] (mouse-motion-event-which event) → fixnum
[setter] (set! (mouse-motion-event-which event) val)
[setter] (mouse-motion-event-which-set! event val)

Get or set the event's which field, as an integer indicating the mouse instance ID.

[procedure] (mouse-motion-event-state event) → list of symbols
[setter] (set! (mouse-motion-event-state event) val)
[setter] (mouse-motion-event-state-set! event val)

Get or set the event's state field, as a list of zero or more mouse button mask symbols, indicating the mouse buttons that were being pressed at the time this event occurred:

[procedure] (mouse-motion-event-state-raw event) → fixnum
[setter] (set! (mouse-motion-event-state-raw event) val)
[setter] (mouse-motion-event-state-raw-set! event val)

Get or set the event's state field, as an integer indicating the mouse buttons that were being pressed at the time this event occurred. See also mouse-motion-event-state

[procedure] (mouse-motion-event-x event) → fixnum
[setter] (set! (mouse-motion-event-x event) val)
[setter] (mouse-motion-event-x-set! event val)

Get or set the event's x field, as an integer indicating the X position (in pixels) of the mouse at the time this event occurred.

[procedure] (mouse-motion-event-y event) → fixnum
[setter] (set! (mouse-motion-event-y event) val)
[setter] (mouse-motion-event-y-set! event val)

Get or set the event's y field, as an integer indicating the Y position (in pixels) of the mouse at the time this event occurred.

[procedure] (mouse-motion-event-xrel event) → fixnum
[setter] (set! (mouse-motion-event-xrel event) val)
[setter] (mouse-motion-event-xrel-set! event val)

Get or set the event's xrel field, as an integer (possibly negative) indicating the amount the mouse's X position changed since its previous position.

[procedure] (mouse-motion-event-yrel event) → fixnum
[setter] (set! (mouse-motion-event-yrel event) val)
[setter] (mouse-motion-event-yrel-set! event val)

Get or set the event's yrel field, as an integer (possibly negative) indicating the amount the mouse's Y position changed since its previous position.

sdl2:mouse-wheel-event

sdl2:mouse-wheel-event is a variant of sdl2:event that wraps a pointer to an SDL_MouseWheelEvent.

[procedure] (mouse-wheel-event? obj) → boolean

Returns #t if obj is an sdl2:mouse-wheel-event.

[procedure] (mouse-wheel-event-window-id event) → fixnum
[setter] (set! (mouse-wheel-event-window-id event) val)
[setter] (mouse-wheel-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window that had mouse focus at the time this event occurred, or 0 if no sdl2:window had mouse focus.

[procedure] (mouse-wheel-event-which event) → fixnum
[setter] (set! (mouse-wheel-event-which event) val)
[setter] (mouse-wheel-event-which-set! event val)

Get or set the event's which field, as an integer indicating the mouse instance ID.

[procedure] (mouse-wheel-event-x event) → fixnum
[setter] (set! (mouse-wheel-event-x event) val)
[setter] (mouse-wheel-event-x-set! event val)

Get or set the event's x field, as an integer (possibly negative) indicating the amount the wheel scrolled horizontally. Positive numbers indicate scrolling to the right, negative numbers indicate scrolling to the left.

[procedure] (mouse-wheel-event-y event) → fixnum
[setter] (set! (mouse-wheel-event-y event) val)
[setter] (mouse-wheel-event-y-set! event val)

Get or set the event's y field, as an integer (possibly negative) indicating the amount the wheel scrolled vertically. Positive numbers indicate scrolling away from the user, negative numbers indicate scrolling toward the user.

sdl2:multi-gesture-event

sdl2:multi-gesture-event is a variant of sdl2:event that wraps a pointer to an SDL_MultiGestureEvent.

[procedure] (multi-gesture-event? obj) → boolean

Returns #t if obj is an sdl2:multi-gesture-event.

[procedure] (multi-gesture-event-touch-id event) → fixnum
[setter] (set! (multi-gesture-event-touch-id event) val)
[setter] (multi-gesture-event-touch-id-set! event val)

Get or set the event's touch-id field, as an integer indicating the ID number of the touch device this event is related to.

[procedure] (multi-gesture-event-dtheta event) → float
[setter] (set! (multi-gesture-event-dtheta event) val)
[setter] (multi-gesture-event-dtheta-set! event val)

Get or set the event's dtheta field, as a float indicating the amount that the fingers rotated during this motion.

[procedure] (multi-gesture-event-ddist event) → float
[setter] (set! (multi-gesture-event-ddist event) val)
[setter] (multi-gesture-event-ddist-set! event val)

Get or set the event's ddist field, as a float indicating the amount that the fingers pinched during this motion.

[procedure] (multi-gesture-event-x event) → float
[setter] (set! (multi-gesture-event-x event) val)
[setter] (multi-gesture-event-x-set! event val)

Get or set the event's x field, as a float indicating the normalized X coordinate of the center of the gesture.

[procedure] (multi-gesture-event-y event) → float
[setter] (set! (multi-gesture-event-y event) val)
[setter] (multi-gesture-event-y-set! event val)

Get or set the event's y field, as a float indicating the normalized Y coordinate of the center of the gesture.

[procedure] (multi-gesture-event-num-fingers event) → fixnum
[setter] (set! (multi-gesture-event-num-fingers event) val)
[setter] (multi-gesture-event-num-fingers-set! event val)

Get or set the event's num-fingers field, as an integer indicating the number of fingers used in the gesture.

sdl2:quit-event

sdl2:quit-event is a variant of sdl2:event that wraps a pointer to an SDL_QuitEvent.

[procedure] (quit-event? obj) → boolean

Returns #t if obj is an sdl2:quit-event.

sdl2:sys-wm-event

sdl2:sys-wm-event is a variant of sdl2:event that wraps a pointer to an SDL_SysWMEvent. This event is for very advanced use cases. Most people can ignore it.

[procedure] (sys-wm-event? obj) → boolean

Returns #t if obj is an sdl2:sys-wm-event.

[procedure] (sys-wm-event-msg-raw event) → pointer
[setter] (set! (sys-wm-event-msg-raw event) val)
[setter] (sys-wm-event-msg-raw-set! event val)

Get or set the event's msg field, as a raw pointer to a SDL_SysWMmsg struct describing the platform-specific event that occurred. This is for very advanced use cases. Most people can ignore it.

sdl2:text-editing-event

sdl2:text-editing-event is a variant of sdl2:event that wraps a pointer to an SDL_TextEditingEvent.

[procedure] (text-editing-event? obj) → boolean

Returns #t if obj is an sdl2:text-editing-event.

[procedure] (text-editing-event-window-id event) → fixnum
[setter] (set! (text-editing-event-window-id event) val)
[setter] (text-editing-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window that had keyboard focus at the time this event occurred, or 0 if no sdl2:window had keyboard focus.

[procedure] (text-editing-event-text event) → string
[setter] (set! (text-editing-event-text event) val)
[setter] (text-editing-event-text-set! event val)

Get or set the event's text event, as a UTF8 string up to 32 bytes long (including the null byte), holding the text being edited.

[procedure] (text-editing-event-start event) → fixnum
[setter] (set! (text-editing-event-start event) val)
[setter] (text-editing-event-start-set! event val)

Get or set the event's start field, as an integer indicating the location to begin editing from.

[procedure] (text-editing-event-length event) → fixnum
[setter] (set! (text-editing-event-length event) val)
[setter] (text-editing-event-length-set! event val)

Get or set the event's length field, as an integer indicating the number of characters to edit from the start point.

sdl2:text-input-event

sdl2:text-input-event is a variant of sdl2:event that wraps a pointer to an SDL_TextInputEvent.

[procedure] (text-input-event? obj) → boolean

Returns #t if obj is an sdl2:text-input-event.

[procedure] (text-input-event-window-id event) → fixnum
[setter] (set! (text-input-event-window-id event) val)
[setter] (text-input-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window that had keyboard focus at the time this event occurred, or 0 if no sdl2:window had keyboard focus.

[procedure] (text-input-event-text event) → string
[setter] (set! (text-input-event-text event) val)
[setter] (text-input-event-text-set! event val)

Get or set the event's text event, as a UTF8 string up to 32 bytes long (including the null byte), holding the text that was inputted.

sdl2:touch-finger-event

sdl2:touch-finger-event is a variant of sdl2:event that wraps a pointer to an SDL_TouchFingerEvent.

[procedure] (touch-finger-event? obj) → boolean

Returns #t if obj is an sdl2:touch-finger-event.

[procedure] (touch-finger-event-touch-id event) → fixnum
[setter] (set! (touch-finger-event-touch-id event) val)
[setter] (touch-finger-event-touch-id-set! event val)

Get or set the event's touch-id field, as an integer indicating the ID number of the touch device this event is related to.

[procedure] (touch-finger-event-finger-id event) → fixnum
[setter] (set! (touch-finger-event-finger-id event) val)
[setter] (touch-finger-event-finger-id-set! event val)

Get or set the event's finger-id field, as an integer indicating the ID number of the finger this event is related to.

[procedure] (touch-finger-event-x event) → float
[setter] (set! (touch-finger-event-x event) val)
[setter] (touch-finger-event-x-set! event val)

Get or set the event's x field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized X coordinate of the touch event.

[procedure] (touch-finger-event-y event) → float
[setter] (set! (touch-finger-event-y event) val)
[setter] (touch-finger-event-y-set! event val)

Get or set the event's y field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized Y coordinate of the touch event.

[procedure] (touch-finger-event-dx event) → float
[setter] (set! (touch-finger-event-dx event) val)
[setter] (touch-finger-event-dx-set! event val)

Get or set the event's dx field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized distance moved on the X axis.

[procedure] (touch-finger-event-dy event) → float
[setter] (set! (touch-finger-event-dy event) val)
[setter] (touch-finger-event-dy-set! event val)

Get or set the event's dy field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized distance moved on the Y axis.

[procedure] (touch-finger-event-pressure event) → float
[setter] (set! (touch-finger-event-pressure event) val)
[setter] (touch-finger-event-pressure-set! event val)

Get or set the event's pressure field, as a float in the range 0.0 to 1.0 (inclusive), indicating the pressure being applied.

sdl2:user-event

sdl2:user-event is a variant of sdl2:event that wraps a pointer to an SDL_UserEvent.

Call register-events! to register your own custom event type symbols.

[procedure] (user-event? obj) → boolean

Returns #t if obj is an sdl2:user-event.

[procedure] (user-event-window-id event) → fixnum
[setter] (set! (user-event-window-id event) val)
[setter] (user-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID number of the sdl2:window associated with this event.

[procedure] (user-event-code event) → fixnum
[setter] (set! (user-event-code event) val)
[setter] (user-event-code-set! event val)

Get or set the event's code field, as an integer in the range -32768 to 32767 (inclusive). The meaning of this field is for you to decide.

[procedure] (user-event-data1-raw event) → pointer or #f
[setter] (set! (user-event-data1-raw event) val)
[setter] (user-event-data1-rawset! event val)

Get or set the event's data1 field, as a raw pointer or #f. The meaning of this field is for you to decide.

If you want to store a pointer to a Scheme object here, be sure to evict the object first. Otherwise the object's location in memory might change, rendering the pointer invalid.

[procedure] (user-event-data2-raw event) → pointer or #f
[setter] (set! (user-event-data2-raw event) val)
[setter] (user-event-data2-raw-set! event val)

Get or set the event's data2 field, as a raw pointer or #f. The meaning of this field is for you to decide.

If you want to store a pointer to a Scheme object here, be sure to evict the object first. Otherwise the object's location in memory might change, rendering the pointer invalid.

sdl2:window-event

sdl2:window-event is a variant of sdl2:event that wraps a pointer to an SDL_WindowEvent.

[procedure] (window-event? obj) → boolean

Returns #t if obj is an sdl2:window-event.

[procedure] (window-event-window-id event) → fixnum
[setter] (set! (window-event-window-id event) val)
[setter] (window-event-window-id-set! event val)

Get or set the event's window-id field, as an integer indicating the ID of the sdl2:window that the event is related to.

[procedure] (window-event-event event) → symbol
[setter] (set! (window-event-event event) val)
[setter] (window-event-event-set! event val)

Get or set the event's event field, as a window event type symbol indicating what happened to the window.

[procedure] (window-event-event-raw event) → fixnum
[setter] (set! (window-event-event-raw event) val)
[setter] (window-event-event-raw-set! event val)

Get or set the event's event field, as an integer indicating what happened to the window. See also window-event-event.

[procedure] (window-event-data1 event) → fixnum
[setter] (set! (window-event-data1 event) val)
[setter] (window-event-data1-set! event val)

Get or set the sdl2:window-event's "data1" field, as an integer. The meaning of this value depends on what kind of window event it was (see window-event-event). E.g. if the window was resized, this will hold the new window width; if the window was moved, this will hold the new x position.

[procedure] (window-event-data2 event) → fixnum
[setter] (set! (window-event-data2 event) val)
[setter] (window-event-data2-set! event val)

Get or set the sdl2:window-event's "data2" field, as an integer. The meaning of this value depends on what kind of window event it was (see window-event-event). E.g. if the window was resized, this will hold the new window height; if the window was moved, this will hold the new y position.

sdl2:finger

sdl2:finger is a record type that wraps a pointer to an SDL_Finger struct.

[procedure] (finger? obj) → boolean

Returns #t if obj is an sdl2:finger.

[procedure] (finger-id finger) → fixnum

Get the sdl2:finger's id field, as an integer.

[procedure] (finger-x finger) → float

Get the sdl2:finger's x field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized X position of the finger.

[procedure] (finger-y finger) → float

Get the sdl2:finger's y field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized Y position of the finger.

[procedure] (finger-pressure finger) → float

Get the sdl2:finger's pressure field, as a float in the range 0.0 to 1.0 (inclusive), indicating the normalized pressure of the finger.

sdl2:joystick

sdl2:joystick is a record type that wraps a pointer to an SDL_Joystick struct.

[procedure] (joystick? obj) → boolean

Returns #t if obj is an sdl2:joystick.

sdl2:joystick-guid

sdl2:joystick-guid is a record type that wraps a pointer to an SDL_JoystickGUID struct.

[procedure] (joystick-guid? obj) → boolean

Returns #t if obj is an sdl2:joystick-guid.

[procedure] (free-joystick-guid! guid)

Free the memory of the sdl2:joystick-guid's underlying struct. guid's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:joystick-guid records. It is safe (but has no effect) to free a struct record multiple times.

sdl2:keysym

sdl2:keysym is a record type that wraps a pointer to an SDL_Keysym struct.

[procedure] (keysym? obj) → boolean

Returns #t if obj is an sdl2:keysym.

[procedure] (make-keysym #!optional scancode sym mod) → sdl2:keysym

Allocate and initialize a new managed sdl2:keysym record.

scancode defaults to 'unknown. It must be a keyboard scancode symbol or equivalent integer.

sym defaults to 'unknown. It must be a keyboard keycode symbol or equivalent integer.

mod defaults to '(). It must be a list of zero or more keyboard modifier symbols or an equivalent integer bitfield.

[procedure] (make-keysym* #!optional scancode sym mod) → sdl2:keysym

Allocate and initialize a new unmanaged sdl2:keysym record. This is similar to make-keysym, except you must call free-keysym! on the record when you are done with it.

[procedure] (free-keysym! keysym)

Free the memory of the sdl2:keysym's underlying struct. keysym's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:keysym records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (keysym-scancode keysym) → symbol
[setter] (set! (keysym-scancode keysym) val)
[setter] (keysym-scancode-set! keysym)

Get or set the sdl2:keysym's scancode field, as a keyboard scancode symbol.

[procedure] (keysym-scancode-raw keysym) → fixnum
[setter] (set! (keysym-scancode-raw keysym) val)
[setter] (keysym-scancode-raw-set! keysym)

Get or set the sdl2:keysym's scancode field, as an integer. See also keysym-scancode.

[procedure] (keysym-sym keysym) → symbol
[setter] (set! (keysym-sym keysym) val)
[setter] (keysym-sym-set! keysym)

Get or set the sdl2:keysym's sym field, as a keyboard keycode symbol.

[procedure] (keysym-sym-raw keysym) → fixnum
[setter] (set! (keysym-sym-raw keysym) val)
[setter] (keysym-sym-raw-set! keysym)

Get or set the sdl2:keysym's sym field, as an integer. See also keysym-sym.

[procedure] (keysym-mod keysym) → list of symbols
[setter] (set! (keysym-mod keysym) val)
[setter] (keysym-mod-set! keysym)

Get or set the sdl2:keysym's mod field, as a list of zero or more keyboard modifier symbols.

[procedure] (keysym-mod-raw keysym) → fixnum
[setter] (set! (keysym-mod-raw keysym) val)
[setter] (keysym-mod-raw-set! keysym)

Get or set the sdl2:keysym's mod field, as an integer. See also keysym-mod.

sdl2:palette

sdl2:palette is a record type that wraps a pointer to an SDL_Palette struct.

[procedure] (palette? obj) → boolean

Returns #t if obj is an sdl2:palette.

[procedure] (make-palette #!optional ncolors) → sdl2:palette

Allocate and initialize a new managed sdl2:palette record with the given number of colors. See SDL_AllocPalette.

ncolors defaults to 256. Common values are 2 (for a 1-bit surface), 16 (for a 4-bit surface), and 256 (for an 8-bit surface).

NOTE: Usually you do not need to manually allocate a palette. A palette will be created for you when you create a surface with a depth of 8 or lower, and the palette will be automatically freed when the surface is freed (unless the palette is still being used by other surfaces).

[procedure] (make-palette* #!optional ncolors) → sdl2:palette

Allocate and initialize a new unmanaged sdl2:palette record. This is similar to make-palette, except you must call free-palette! on the record when you are done with it.

[procedure] (free-palette! palette)

Free the memory of the sdl2:palette's underlying struct. palette's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:palette records. It is safe (but has no effect) to free a struct record multiple times.

See SDL_FreePalette.

[procedure] (palette-ncolors palette) → fixnum
[procedure] (palette-ncolours palette) → fixnum

Returns the number of colors in the palette. Common values are 2 (for a 1-bit surface), 16 (for a 4-bit surface), and 256 (for an 8-bit surface).

sdl2:pixel-format

sdl2:pixel-format is a record type that wraps a pointer to an SDL_PixelFormat struct.

[procedure] (pixel-format? obj) → boolean

Returns #t if obj is an sdl2:pixel-format.

[procedure] (make-pixel-format #!optional format) → sdl2:pixel-format

Allocate and initialize a new managed sdl2:pixel-format record with the given format.

format defaults to 'unknown. It must be a pixel format symbol or equivalent integer. See SDL_AllocFormat.

[procedure] (make-pixel-format* #!optional format) → sdl2:pixel-format

Allocate and initialize a new unmanaged sdl2:pixel-format record. This is similar to make-pixel-format, except you must call free-pixel-format! on the record when you are done with it.

[procedure] (free-pixel-format! pixel-format)

Free the memory of the sdl2:pixel-format's underlying struct. pixel-format's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:pixel-format records. It is safe (but has no effect) to free a struct record multiple times.

See SDL_FreeFormat.

[procedure] (pixel-format-format pixel-format) → symbol

Get the sdl2:pixel-format's format field, as a pixel format symbol.

[procedure] (pixel-format-format-raw pixel-format) → fixnum

Get the sdl2:pixel-format's format field, as an integer. See also pixel-format-format.

[procedure] (pixel-format-palette pixel-format) → sdl2:palette or #f
[setter] (set! (pixel-format-palette pixel-format) val)
[setter] (pixel-format-palette-set! pixel-format palette)

Get or set the sdl2:pixel-format's palette field, as an sdl2:palette, or #f if it does not have a palette. Only sdl2:pixel-formats with bits-per-pixel of 8 or less can have a palette.

See SDL_SetPixelFormatPalette.

[procedure] (pixel-format-bits-per-pixel pixel-format) → fixnum

Get the sdl2:pixel-format's bits-per-pixel field, as an integer. Common values are 32, 24, 16, 15, 8, 4, and 1.

[procedure] (pixel-format-bytes-per-pixel pixel-format) → fixnum

Get the sdl2:pixel-format's bits-per-pixel field, as an integer. Possible values are 4, 3, 2, and 1.

[procedure] (pixel-format-rmask pixel-format) → fixnum

Get the sdl2:pixel-format's rmask (red mask) field, as a nonnegative integer.

[procedure] (pixel-format-gmask pixel-format) → fixnum

Get the sdl2:pixel-format's gmask (green mask) field, as a nonnegative integer.

[procedure] (pixel-format-bmask pixel-format) → fixnum

Get the sdl2:pixel-format's bmask (blue mask) field, as a nonnegative integer.

[procedure] (pixel-format-amask pixel-format) → fixnum

Get the sdl2:pixel-format's amask (alpha mask) field, as a nonnegative integer. Will be 0 if there is no alpha channel.

sdl2:point

sdl2:point is a record type that wraps a pointer to an SDL_Point struct.

[procedure] (point? obj) → boolean

Returns #t if obj is an sdl2:point.

[procedure] (make-point #!optional x y) → sdl2:point

Allocate and initialize a new managed sdl2:point record.

x and y are the x and y fields of the point. They must be integers in the range -2147483648 to 2147483647 (inclusive). They both default to 0.

[procedure] (make-point #!optional x y) → sdl2:point

Allocate and initialize a new unmanaged sdl2:point record. This is similar to make-point, except you must call free-point! on the record when you are done with it.

[procedure] (free-point! point)

Free the memory of the sdl2:point's underlying struct. point's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:point records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (point-x point) → fixnum
[setter] (set! (point-x point) x)
[setter] (point-x-set! point x)

Get or set the sdl2:point's x field, as an integer in the range -2147483648 to 2147483647 (inclusive).

[procedure] (point-y point) → fixnum
[setter] (set! (point-y point) y)
[setter] (point-y-set! point y)

Get or set the sdl2:point's y field, as an integer in the range -2147483648 to 2147483647 (inclusive).

[procedure] (point-set! point #!optional x y) → point

Convenient way of setting multiple fields of the sdl2:point. Any arguments that are #f will cause no change to that field. E.g. (point-set! my-point 42 #f) will set the x field to 42, but will not change the y field. Returns point after it is modified.

[procedure] (point->list point) → list of fixnums

Returns a list (x y) containing the value of each field of the sdl2:point.

[procedure] (point=? point1 point2) → boolean

Returns #t if both sdl2:point records have the same values.

[procedure] (copy-point point) → sdl2:point

Returns a new managed sdl2:point with the same values as the given sdl2:point.

[procedure] (copy-point* point) → sdl2:point

Returns a new unmanaged sdl2:point with the same values as the given sdl2:point. You must call free-point! on the record when you are done with it.

sdl2:rect

sdl2:rect is a record type that wraps a pointer to an SDL_Rect struct.

[procedure] (rect? obj) → boolean

Returns #t if obj is an sdl2:rect.

[procedure] (make-rect #!optional x y w h) → sdl2:rect

Allocate and initialize a new managed sdl2:rect record.

x, y, w, and h are the fields of the sdl2:rect. They must be integers in the range -2147483648 to 2147483647 (inclusive). They all default to 0.

[procedure] (make-rect* #!optional x y w h) → sdl2:rect

Allocate and initialize a new unmanaged sdl2:rect record. This is similar to make-rect, except you must call free-rect! on the record when you are done with it.

[procedure] (free-rect! rect)

Free the memory of the sdl2:rect's underlying struct. rect's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:rect records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (rect-x rect) → fixnum
[setter] (set! (rect-x rect) x)
[setter] (rect-x-set! rect x)

Get or set the sdl2:rect's x field, as an integer in the range -2147483648 to 2147483647 (inclusive).

[procedure] (rect-y rect) → fixnum
[setter] (set! (rect-y rect) y)
[setter] (rect-y-set! rect y)

Get or set the sdl2:rect's y field, as an integer in the range -2147483648 to 2147483647 (inclusive).

[procedure] (rect-w rect) → fixnum
[setter] (set! (rect-w rect) w)
[setter] (rect-w-set! rect w)

Get or set the sdl2:rect's w (width) field, as an integer in the range -2147483648 to 2147483647 (inclusive).

[procedure] (rect-h rect) → fixnum
[setter] (set! (rect-h rect) h)
[setter] (rect-h-set! rect h)

Get or set the sdl2:rect's h (height) field, as an integer in the range -2147483648 to 2147483647 (inclusive).

[procedure] (rect-set! rect #!optional x y w h) → rect

Convenient way of setting multiple fields of the sdl2:rect. Any arguments that are #f will cause no change to that field. E.g. (rect-set! my-rect 42 #f 1337 #f) will set the x field to 42 and the w field to 1337, but will not change the y or h fields. Returns rect after it is modified.

[procedure] (rect->list rect) → list of fixnums

Returns a list (x y w h) containing the value of each field of the sdl2:rect.

[procedure] (rect=? rect1 rect2) → boolean

Returns #t if both sdl2:rect records have the same values. See SDL_RectEquals.

[procedure] (copy-rect rect) → sdl2:rect

Returns a new managed sdl2:rect with the same values as the given sdl2:rect.

[procedure] (copy-rect* rect) → sdl2:rect

Returns a new unmanaged sdl2:rect with the same values as the given sdl2:rect. You must call free-rect! on the record when you are done with it.

sdl2:rwops

sdl2:rwops is a record type that wraps a pointer to an SDL_RWops struct.

[procedure] (rwops? obj) → boolean

Returns #t if obj is an sdl2:rwops.

[procedure] (rwops-type rwops) → symbol

Returns a RWops type symbol indicating the sdl2:rwops' source type:

[procedure] (rwops-type-raw rwops) → fixnum

Returns an integer indicating the sdl2:rwops' source type. See also rwops-type.

sdl2:surface

sdl2:surface is a record type that wraps a pointer to an SDL_Surface struct.

[procedure] (surface? obj) → boolean

Returns #t if obj is an sdl2:surface.

[procedure] (free-surface! surface)

Free the memory of the sdl2:surface's underlying struct. surface's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:surface records. It is safe (but has no effect) to free a struct record multiple times.

See SDL_FreeSurface.

NOTE: if surface was created using create-rgb-surface-from, then the pixel data is not freed.

[procedure] (surface-format surface) → sdl2:pixel-format

Returns a sdl2:pixel-format describing the pixel format of the sdl2:surface's pixels.

[procedure] (surface-w surface) → fixnum

Get the sdl2:surface's w field, as a nonnegative integer indicating the surface's width in pixels.

[procedure] (surface-h surface) → fixnum

Get the sdl2:surface's h field, as a nonnegative integer indicating the surface's height in pixels.

[procedure] (surface-pitch surface) → fixnum

Get the sdl2:surface's pitch field, as a nonnegative integer indicating how many bytes are used to represent one row of pixel data.

[procedure] (surface-pixels-raw surface) → pointer or #f

Returns a raw pointer to the sdl2:surface's pixels. Don't use this unless you really know what you are doing!

If you just want to get or set a pixel, use surface-ref and surface-set! instead. They are much safer, more convenient, and more efficient than using this pointer.

[procedure] (surface-userdata-raw surface) → pointer or #f
[setter] (set! (surface-userdata-raw surface) val)
[setter] (surface-userdata-raw-set! surface)

Get or set the sdl2:surface's userdata field, as a pointer or #f.

If you want to store a pointer to a Scheme object here, be sure to evict the object first. Otherwise the object's location in memory might change, rendering the pointer invalid.

[procedure] (surface-refcount surface) → fixnum
[setter] (set! (surface-refcount surface) val)
[setter] (surface-refcount-set! surface)

Get or set the sdl2:surface's refcount field, as an integer.

sdl2:texture

sdl2:texture is a record type that wraps a pointer to an SDL_Texture struct.

[procedure] (texture? obj) → boolean

Returns #t if obj is an sdl2:texture.

sdl2:version

sdl2:version is a record type that wraps a pointer to an SDL_version struct.

[procedure] (version? obj) → boolean

Returns #t if obj is an sdl2:version.

[procedure] (make-version #!optional major minor patch) → sdl2:version

Allocate and initialize a new managed sdl2:version record.

major, minor, and patch are the fields of the version. They must be integers in the range 0 to 255 (inclusive). They all default to 0.

[procedure] (make-version* #!optional major minor patch) → sdl2:version

Allocate and initialize a new unmanaged sdl2:version record. This is similar to make-version, except you must call free-version! on the record when you are done with it.

[procedure] (free-version! version)

Free the memory of the sdl2:version's underlying struct. version's pointer will be set to null (see struct-null?). It is safe to call this procedure with managed or unmanaged sdl2:version records. It is safe (but has no effect) to free a struct record multiple times.

[procedure] (version-major version) → fixnum
[setter] (set! (version-major version) major)
[setter] (version-major-set! version major)

Get or set the sdl2:version's major field, as an integer in the range 0 to 255 (inclusive).

[procedure] (version-minor version) → fixnum
[setter] (set! (version-minor version) minor)
[setter] (version-minor-set! version minor)

Get or set the sdl2:version's minor field, as an integer in the range 0 to 255 (inclusive).

[procedure] (version-patch version) → fixnum
[setter] (set! (version-patch version) patch)
[setter] (version-patch-set! version patch)

Get or set the sdl2:version's patch field, as an integer in the range 0 to 255 (inclusive).

[procedure] (version-set! version #!optional major minor patch) → version

Convenient way of setting multiple fields of the sdl2:version. Any arguments that are #f will cause no change to that field. E.g. (version-set! my-version 42 #f 255) will set the major field to 42 and the patch field to 255, but will not change the minor field. Returns version after it is modified.

[procedure] (version->list version) → list of fixnums

Returns a list (major minor patch) containing the value of each field of the sdl2:version.

[procedure] (version=? version1 version2) → boolean

Returns #t if both sdl2:version records have the same values.

sdl2:window

sdl2:window is a record type that wraps a pointer to an SDL_Window struct.

[procedure] (window? obj) → boolean

Returns #t if obj is an sdl2:window.

Procedures

General / Miscellaneous

[procedure] (init! #!optional flags-list) → fixnum

See SDL_Init. Returns zero if successful.

flags-list defaults to '(everything). It must be a list of one or more init flag symbols:

[procedure] (init-subsystem! flags-list) → fixnum

See SDL_InitSubSystem. Returns zero if successful.

flags-list must be a list of one or more init flag symbols.

[procedure] (quit!)

See SDL_Quit.

[procedure] (quit-subsystem! flags-list)

See SDL_QuitSubSystem.

flags-list must be a list of one or more init flag symbols.

[procedure] (was-init #!optional flags-list) → list of symbols

See SDL_WasInit.

flags-list defaults to '(everything). It must be a list of one or more init flag symbols.

[procedure] (set-main-ready!)

See SDL_SetMainReady.

[procedure] (clear-error!)

See SDL_ClearError.

[procedure] (get-error) → string

See SDL_GetError.

[procedure] (set-error! message)

See SDL_SetError.

Unlike SDL_SetError, this procedure only accepts one argument, a string. You can use sprintf to do string substitution if desired.

[procedure] (get-platform) → string

See SDL_GetPlatform.

[procedure] (disable-screen-saver!)

See SDL_DisableScreenSaver.

[procedure] (enable-screen-saver!)

See SDL_EnableScreenSaver.

[procedure] (screen-saver-enabled?) → boolean

See SDL_IsScreenSaverEnabled.

[procedure] (has-clipboard-text?) → boolean

See SDL_HasClipboardText.

[procedure] (get-clipboard-text) → string

See SDL_GetClipboardText.

[procedure] (set-clipboard-text! text) → fixnum

See SDL_SetClipboardText. Returns zero if successful.

[procedure] (get-version) → sdl2:version

See SDL_GetVersion.

Returns an sdl2:version record containing the version number of SDL that the sdl2 egg is currently using. (This may be different than the version it was compiled with.)

[procedure] (get-compiled-version) → sdl2:version

See SDL_VERSION.

Returns an sdl2:version record containing the version number of SDL that the sdl2 egg was compiled with. (This may be different than the version it is currently using.)

[procedure] (version-at-least? major minor patch) → boolean

See SDL_VERSION_ATLEAST.

Returns #t if the sdl2 egg was compiled with a version of SDL at least as high as specified. E.g. (version-at-least? 2 0 1) returns #t if the sdl2 egg was compiled with SDL 2.0.1 or higher. Some SDL features are only available after a certain version, so you can use this procedure to check whether the feature is available.

Pixel Format / Palette

[procedure] (map-rgb pixel-format r g b) → fixnum

See SDL_MapRGB.

[procedure] (map-rgba pixel-format r g b a) → fixnum

See SDL_MapRGBA.

[procedure] (get-rgb pixel pixel-format) → [r g b]

See SDL_GetRGB.

This procedure returns multiple values.

[procedure] (get-rgba pixel pixel-format) → [r g b a]

See SDL_GetRGBA.

This procedure returns multiple values.

[procedure] (palette-ref palette i) → sdl2:color

Get a copy of the color at the given index of the palette, as a managed sdl2:color.

[setter] (set! (palette-ref palette i) color)
[setter] (palette-set! palette i color)

Set the given index of the palette to a copy of the given sdl2:color.

[procedure] (palette-colors palette) → vector of sdl2:colors
[procedure] (palette-colours palette) → vector of sdl2:colors

Get copies of all colors in the palette, as a Scheme vector of managed sdl2:colors.

[setter] (palette-colors-set! colors-vec #!optional start) -> fixnum
[setter] (palette-colours-set! colors-vec #!optional start) -> fixnum

See SDL_SetPaletteColors.

Set multiple colors in the palette to copies of the given colors. colors-vec must be a Scheme vector of sdl2:colors. start defaults to 0.

Returns zero if successful.

Events

[procedure] (event-state type) → boolean

Query whether the given event type is enabled or disabled. See SDL_EventState.

type must be an event type symbol or corresponding integer.

Returns #t if the given event type is currently enabled, or #f if it is currently disabled.

[setter] (set! (event-state type) state) → boolean
[setter] (event-state-set! type state) → boolean

Enable or disable the given event type. See SDL_EventState.

type must be an event type symbol or corresponding integer.

If state is #t, the given event type will be enabled. If state is #f, it will be disabled, i.e. all future events of that type will be ignored.

Returns the previous state of the given event type.

[procedure] (flush-event! type)

See SDL_FlushEvent.

Note: Contrary to what its name suggests, this procedure will flush ALL events matching the given type, not just a single event.

type must be an event type symbol or corresponding integer.

[procedure] (flush-events! #!optional min-type max-type)

See SDL_FlushEvents.

min-type and max-type must be event type symbols or corresponding integers. If omitted, min-type defaults to 'first and max-type defaults to 'last.

[procedure] (has-event? type) → boolean

See SDL_HasEvent.

type must be an event type symbol or corresponding integer.

[procedure] (has-events? #!optional min-type max-type) → boolean

See SDL_HasEvents.

min-type and max-type must be event type symbols or corresponding integers. If omitted, min-type defaults to 'first and max-type defaults to 'last.

[procedure] (quit-requested?) → boolean

See SDL_QuitRequested.

[procedure] (peek-events num #!optional min-type max-type) → list of sdl2:events

See SDL_PeepEvents.

This procedure is similar to get-events!, except that this procedure does not remove the events from the SDL event queue.

min-type and max-type must be event type symbols or corresponding integers. If omitted, min-type defaults to 'first and max-type defaults to 'last.

Returns a list of managed sdl2:events.

[procedure] (get-events! num #!optional min-type max-type) → list of sdl2:events

See SDL_PeepEvents.

This procedure is similar to peek-events, except that this procedure removes the events from the SDL event queue.

min-type and max-type must be an event type symbol or corresponding integer. If omitted, min-type defaults to 'first and max-type defaults to 'last.

Returns a list of managed sdl2:events.

[procedure] (poll-event! #!optional result-event) → sdl2:event

See SDL_PollEvent.

If result-event is omitted or #f, a new managed sdl2:event will be allocated and returned. If result-event is an existing sdl2:event record, it will be modified and returned. This allows you to allocate a single event and reuse it many times in your event loop, so that your program does not create as much garbage for the garbage collector.

[procedure] (pump-events!)

See SDL_PumpEvents.

[procedure] (push-event! event) → fixnum

See SDL_PushEvent.

Returns 1 if successful.

[procedure] (wait-event! #!optional result-event) → sdl2:event

See SDL_WaitEvent.

If result-event is omitted or #f, a new managed sdl2:event will be allocated and returned. If result-event is an existing sdl2:event record, it will be modified and returned. This allows you to allocate a single event and reuse it many times in your event loop, so that your program does not create as much garbage for the garbage collector.

[procedure] (wait-event-timeout! timeout #!optional result-event) → sdl2:event

See SDL_WaitEventTimeout.

If result-event is omitted of #f, a new managed sdl2:event will be allocated and returned. If result-event is an existing sdl2:event record, it will be modified and returned. This allows you to allocate a single event and reuse it many times in your event loop, so that your program does not create as much garbage for the garbage collector.

Please note that the argument order is reversed compared to SDL_WaitEventTimeout. This is to allow the event argument to be optional.

[procedure] (register-events! event-symbols) → list of pairs

Register zero or more symbols as new user event types. After registration, the given symbols may be used as event types, e.g. with event-type-set!. The symbols will be associated with the sdl2:user-event variant of sdl2:event.

event-symbols must be a list of symbols that are not already being used as event types. If any symbol is already being used, or if any member of the list is not a symbol, an error will be signalled and none of the new event types will be registered.

There are 32767 user event type numbers available to register. Each symbol in event-symbols will be automatically assigned a distinct number. If there are not enough remaining numbers to register all the symbols in event-symbols, this procedure will signal an error, and none of the new event types will be registered.

This procedure returns an association list (list of pairs) of each of the new event type symbols (as the pair car) with its assigned number (as the pair cdr).

This procedure is based on SDL_RegisterEvents.

[procedure] (get-num-touch-devices) → fixnum

See SDL_GetNumTouchDevices.

[procedure] (get-num-touch-fingers touch-id) → fixnum

See SDL_GetNumTouchFingers.

[procedure] (get-touch-device device-id) → fixnum

See SDL_GetTouchDevice.

[procedure] (get-touch-finger touch-id index) → sdl2:finger

See SDL_GetTouchFinger.

OpenGL integration

[procedure] (gl-create-context! window) → sdl2:gl-context

See SDL_GL_CreateContext.

[procedure] (gl-delete-context! gl-context)

See SDL_GL_DeleteContext.

[procedure] (gl-make-current! window gl-context) → fixnum

See SDL_GL_MakeCurrent.

[procedure] (gl-get-current-window) → sdl2:window

See SDL_GL_GetCurrentWindow.

[procedure] (gl-get-current-context) → sdl2:gl-context

See SDL_GL_GetCurrentContext.

[procedure] (gl-get-attribute attr) → value

See SDL_GL_GetAttribute.

attr must be an OpenGL attribute symbol or corresponding integer.

The return type varies depending on attr:

[procedure] (gl-set-attribute! attr value) → fixnum

See SDL_GL_SetAttribute. Returns zero if successful.

attr must be an OpenGL attribute symbol or corresponding integer.

value must be one of these types, depending on what attr is:

[procedure] (gl-reset-attributes!)

See SDL_GL_ResetAttributes.

Requires SDL 2.0.2 or higher. Signals an error if the compiled version of SDL is not high enough. Use (version-at-least? 2 0 2) to check before calling this procedure.

[procedure] (gl-get-drawable-size window) → [width height]

See SDL_GL_GetDrawableSize.

This procedure returns multiple values.

Requires SDL 2.0.1 or higher. Signals an error if the compiled version of SDL is not high enough. Use (version-at-least? 2 0 1) to check before calling this procedure.

[procedure] (gl-swap-window!)

See SDL_GL_SwapWindow.

[procedure] (gl-get-swap-interval) → fixnum

See SDL_GL_GetSwapInterval.

[procedure] (gl-set-swap-interval! interval) → fixnum

See SDL_GL_SetSwapInterval.

Returns zero if successful

[procedure] (gl-extension-supported? name-string) → boolean

See SDL_GL_ExtensionSupported.

Joystick

[procedure] (num-joysticks) → fixnum

See SDL_NumJoysticks.

[procedure] (joystick-open! index) → sdl2:joystick

See SDL_JoystickOpen.

[procedure] (joystick-close! joystick)

See SDL_JoystickClose.

[procedure] (joystick-update!)

See SDL_JoystickUpdate.

[procedure] (joystick-event-state) → boolean

See SDL_JoystickEventState.

Like SDL_JoystickEventState with SDL_QUERY.

[setter] (set! (joystick-event-state) state) → boolean
[setter] (joystick-event-state-set! state) → boolean

See SDL_JoystickEventState.

Like SDL_JoystickEventState with SDL_ENABLE or SDL_IGNORE

[procedure] (joystick-attached? joystick) → boolean

See SDL_JoystickGetAttached.

[procedure] (joystick-num-axes joystick) → fixnum

See SDL_JoystickNumAxes.

[procedure] (joystick-num-balls joystick) → fixnum

See SDL_JoystickNumBalls.

[procedure] (joystick-num-buttons joystick) → fixnum

See SDL_JoystickNumButtons.

[procedure] (joystick-num-hats joystick) → fixnum

See SDL_JoystickNumHats.

[procedure] (joystick-get-axis joystick axis-num) → fixnum

See SDL_JoystickGetAxis.

[procedure] (joystick-get-ball joystick ball-num) → [dx dy]

See SDL_JoystickGetBall.

This procedure returns multiple values. Returns #f for both values if the ball values cannot be retrieved (e.g. because ball-num is invalid for the joystick).

[procedure] (joystick-get-button joystick button-num) → boolean

See SDL_JoystickGetButton.

[procedure] (joystick-get-hat joystick hat-num) → symbol

See SDL_JoystickGetHat.

[procedure] (joystick-get-hat-raw joystick hat-num) → fixnum

See SDL_JoystickGetHat. See also joystick-get-hat.

[procedure] (joystick-instance-id joystick) → fixnum

See SDL_JoystickInstanceID.

[procedure] (joystick-name joystick) → string

See SDL_JoystickName.

[procedure] (joystick-name-for-index device-index) → string

See SDL_JoystickNameForIndex.

[procedure] (joystick-get-device-guid device-index) → sdl2:joystick-guid

See SDL_JoystickGetDeviceGUID.

Returns a new managed sdl2:joystick-guid record.

[procedure] (joystick-get-guid joystick) → sdl2:joystick-guid

See SDL_JoystickGetGUID.

Returns a new managed sdl2:joystick-guid record.

[procedure] (joystick-get-guid-from-string str) → sdl2:joystick-guid

See SDL_JoystickGetGUIDFromString.

Returns a new managed sdl2:joystick-guid record.

[procedure] (joystick-get-guid-string guid) → string

See SDL_JoystickGetGUIDString.

Keyboard

[procedure] (get-key-from-name name-str) → symbol

See SDL_GetKeyFromName.

Returns a keyboard keycode symbol.

[procedure] (get-key-from-name-raw name-str) → fixnum

See SDL_GetKeyFromName.

Returns an integer representing a keyboard keycode. See also get-key-from-name.

[procedure] (get-key-from-scancode scancode) → symbol

See SDL_GetKeyFromScancode.

scancode must be a keyboard scancode symbol or an integer representing a keyboard scancode.

Returns a keyboard keycode symbol.

[procedure] (get-key-from-scancode-raw scancode) → fixnum

See SDL_GetKeyFromScancode.

scancode must be a keyboard scancode symbol or an integer representing a keyboard scancode.

Returns an integer representing a keyboard keycode. See also get-key-from-scancode.

[procedure] (get-key-name key) → string

See SDL_GetKeyName.

key must be a keyboard keycode symbol or an integer representing a keyboard keycode.

[procedure] (get-scancode-from-name name-str) → symbol

See SDL_GetScancodeFromName.

Returns a keyboard scancode symbol.

[procedure] (get-scancode-from-name-raw name-str) → fixnum

See SDL_GetScancodeFromName.

Returns an integer representing a keyboard scancode. See also get-scancode-from-name.

[procedure] (get-scancode-from-key key) → symbol

See SDL_GetScancodeFromKey.

key must be a keyboard keycode symbol or an integer representing a keyboard keycode.

Returns a keyboard scancode symbol.

[procedure] (get-scancode-from-key-raw key) → fixnum

See SDL_GetScancodeFromKey.

key must be a keyboard keycode symbol or an integer representing a keyboard keycode.

Returns an integer representing a keyboard scancode. See also get-scancode-from-key.

[procedure] (get-scancode-name scancode) → string

See SDL_GetScancodeName.

scancode must be a keyboard scancode symbol or an integer representing a keyboard scancode.

[procedure] (get-keyboard-focus) → window

See SDL_GetKeyboardFocus.

[procedure] (keyboard-scancode-pressed? scancode) → boolean

Returns #t if the specified key is being pressed on the keyboard.

scancode must be either a keyboard scancode symbol or an integer representing a scancode.

This procedure queries SDL's internal state, which is tied to the event system. Call pump-events! to update the keyboard state.

This procedure is based on SDL_GetKeyboardState.

[procedure] (mod-state) → list of symbols

See SDL_GetModState.

Returns a list of zero or more keyboard modifier symbols.

[procedure] (mod-state-raw) → fixnum

See SDL_GetModState.

Returns an integer representing a bitfield of keyboard modifiers. See also mod-state.

[setter] (set! (mod-state) state)
[setter] (mod-state-set! state)

See SDL_SetModState.

State can be either a list of keyboard modifier symbols or an integer representing a bitfield of keyboard modifiers.

[setter] (text-input-rect-set! rect)

rect can be an sdl2:rect or #f.

See SDL_SetTextInputRect.

[procedure] (start-text-input!)

See SDL_StartTextInput.

[procedure] (stop-text-input!)

See SDL_StopTextInput.

[procedure] (text-input-active?) → boolean

See SDL_IsTextInputActive.

[procedure] (screen-keyboard-support?) → boolean

See SDL_HasScreenKeyboardSupport.

[procedure] (screen-keyboard-shown? window) → boolean

See SDL_IsScreenKeyboardShown.

Rect / Point

[procedure] (rect-empty? rect) → boolean

See SDL_RectEmpty.

[procedure] (enclose-points points #!optional clip result-rect) → [rect any-enclosed?]

See SDL_EnclosePoints.

points must be a list of sdl2:points.

clip must be either an sdl2:rect or #f (the default). If clip is an sdl2:rect, points outside the clip rect will be ignored.

If result-rect is omitted or #f, a new managed sdl2:rect will be returned. If result-rect is an sdl2:rect, it will be modified and returned. result-rect must not be the same object as either rect1 or rect2.

This procedure returns multiple values:

rect
An sdl2:rect that encloses all matching points. Possibly the same object as result-rect.
any-enclosed?
#t if any points were enclosed, or #f if all points were clipped
[procedure] (has-intersection? rect1 rect2) → boolean

See SDL_HasIntersection.

[procedure] (intersect-rect rect1 rect2 #!optional result-rect) → [rect intersect?]

See SDL_IntersectRect.

If result-rect is omitted or #f, a new managed sdl2:rect will be returned. If result-rect is an sdl2:rect, it will be modified and returned. result-rect must not be the same object as either rect1 or rect2.

This procedure returns multiple values:

rect
An sdl2:rect of the intersection of rect1 and rect2. Possibly the same object as result-rect.
intersect?
#t if rect1 and rect2 intersect, otherwise #f
[procedure] (intersect-rect-and-line rect x1 y1 x2 y2) → [intersect? x1-new y1-new x2-new y2-new]

See SDL_IntersectRectAndLine.

This procedure returns multiple values:

intersect?
#t if the given line intersects with the rect
x1-new
the x value of the point within rect that is closest to the first point
y1-new
the y value ...
x2-new
the x value of the point within rect that is closest to the second point
y2-new
the y value ...
[procedure] (union-rect rect1 rect2 #!optional result-rect) → rect

See SDL_UnionRect.

If result-rect is omitted or #f, a new managed sdl2:rect will be returned. If result-rect is an sdl2:rect, it will be modified and returned. result-rect must not be the same object as either rect1 or rect2.

RWops

[procedure] (rw-from-file filepath) → sdl2:rwops

See SDL_RWFromFile.

You should close the sdl2:rwops when you are done with it, using rw-close! or one of the procedures that can automatically close the sdl2:rwops, such as load-bmp-rw.

[procedure] (rw-from-const-mem pointer) → sdl2:rwops

See SDL_RWFromConstMem.

You should close the sdl2:rwops when you are done with it, using rw-close! or one of the procedures that can automatically close the sdl2:rwops, such as load-bmp-rw.

[procedure] (rw-from-mem pointer) → sdl2:rwops

See SDL_RWFromMem.

You should close the sdl2:rwops when you are done with it, using rw-close! or one of the procedures that can automatically close the sdl2:rwops, such as load-bmp-rw.

[procedure] (rw-from-blob blob) → sdl2:rwops

Create a new sdl2:rwops that accesses the memory of the given blob. You should close the sdl2:rwops when you are done with it, using rw-close! or one of the procedures that can automatically close the sdl2:rwops, such as load-bmp-rw.

You can also use this procedure to create a sdl2:rwops from a SRFI-4 numeric vector, by first converting it to a blob using e.g. u8vector->blob/shared.

CAUTION: Creating a sdl2:rwops from a blob in CHICKEN-managed memory is unstable: the blob might be garbage collected or moved in memory, which would break the sdl2:rwops. To be safe, you should evict the blob and create the sdl2:rwops from the evicted blob (not the original). You may wish to release the evicted blob after you have closed the sdl2:rwops. Example:

(let* ((evicted-blob (object-evict '#${...}))
       (rwops (sdl2:rw-from-blob evicted-blob))
       (surf (sdl2:load-bmp-rw rwops #t)))
  (object-release evicted-blob)
  surf)
[procedure] (rw-from-string str) → sdl2:rwops

Create a new sdl2:rwops that accesses the memory of the given CHICKEN Scheme string. You should close the sdl2:rwops when you are done with it, using rw-close! or one of the procedures that can automatically close the sdl2:rwops, such as load-bmp-rw.

CAUTION: Creating a sdl2:rwops from a string in CHICKEN-managed memory is unstable: the string might be garbage collected or moved in memory, which would break the sdl2:rwops. To be safe, you should evict the string and create the sdl2:rwops from the evicted string (not the original). You may wish to release the evicted string after you have closed the sdl2:rwops. Example:

(let* ((evicted-string (object-evict "..."))
       (rwops (sdl2:rw-from-string evicted-string))
       (surf (sdl2:load-bmp-rw rwops #t)))
  (object-release evicted-string)
  surf)
[procedure] (rw-close! rwops) → fixnum

See SDL_RWclose.

Close and clean up the given sdl2:rwops. This frees the memory used by the SDL_RWops struct itself, but does not free or release the pointer, blob, or string that the sdl2:rwops was reading/writing from. (It does close files opened with rw-from-file, though.)

Returns zero if successful.

Surface

[procedure] (make-surface width height depth) → sdl2:surface or #f

Create a new managed sdl2:surface with the given width, height, and color depth (bits per pixel). This is a more convenient interface for create-rgb-surface. The sdl2:surface's pixel format and masks will be chosen automatically based on the requested depth and the current platform's byte order (little endian or big endian). Returns #f if the sdl2:surface could not be created (e.g. because the color depth is unsupported).

[procedure] (make-surface* width height depth) → sdl2:surface or #f

Similar to make-surface, except that the returned sdl2:surface will be unmanaged. You must call free-surface! when you are done with it.

[procedure] (create-rgb-surface flags width height depth rmask gmask bmask amask) → sdl2:surface

See SDL_CreateRGBSurface.

Returns a new unmanaged sdl2:surface with the given properties. You must call free-surface! when you are done with it.

See also make-surface for a more convenient interface.

[procedure] (create-rgb-surface-from pixels width height depth pitch rmask gmask bmask amask) → sdl2:surface

See SDL_CreateRGBSurfaceFrom.

Returns a new unmanaged sdl2:surface with the given properties, using existing pixel data (a pointer). You must call free-surface! when you are done with it.

[procedure] (convert-surface surface pixel-format) → sdl2:surface

See SDL_ConvertSurface.

Returns a managed sdl2:surface.

[procedure] (convert-surface* surface pixel-format) → sdl2:surface

See SDL_ConvertSurface.

Similar to convert-surface, except that the returned sdl2:surface will be unmanaged. You must call free-surface! when you are done with it.

[procedure] (load-bmp path-string) → sdl2:surface

See SDL_LoadBMP.

Attempts to load a BMP image file. Returns a managed sdl2:surface containing the image data, or #f if the image could not be loaded.

NOTE: This procedure only supports certain kinds of BMP image. Use the sdl2-image egg for better BMP support, plus support for loading other image formats like JPG, PNG, and GIF.

[procedure] (load-bmp* filepath) → sdl2:surface

Similar to load-bmp, except that the returned sdl2:surface will be unmanaged. You must call free-surface! when you are done with it.

[procedure] (load-bmp-rw rwops #!optional close?) → sdl2:surface

See SDL_LoadBMP_RW.

Attempts to load a BMP image from the given sdl2:rwops. Returns a managed sdl2:surface containing the image data, or #f if the image could not be loaded.

If close? is #t, rwops will be automatically closed (see rw-close!) after the image is loaded. If close? is #f or omitted, rwops will not be closed.

NOTE: This procedure only supports certain kinds of BMP image. Use the sdl2-image egg for better BMP support, plus support for loading other image formats like JPG, PNG, and GIF.

[procedure] (load-bmp-rw* rwops #!optional close?) → sdl2:surface

Similar to load-bmp-rw, except that the sdl2:surface will be unmanaged. You must call free-surface! when you are done with it.

[procedure] (save-bmp! surface filepath) → fixnum

See SDL_SaveBMP.

Returns zero if successful.

[procedure] (save-bmp-rw! surface rwops #!optional close?) → fixnum

See SDL_SaveBMP_RW.

If close? is #t, rwops will be automatically closed (see rw-close!) after the image is loaded. If close? is #f or omitted, rwops will not be closed.

Returns zero if successful.

[procedure] (lock-surface! surface) → fixnum

See SDL_LockSurface.

Returns zero if successful.

[procedure] (unlock-surface! surface)

See SDL_UnlockSurface.

[procedure] (must-lock? surface) → boolean

See SDL_MUSTLOCK.

[procedure] (blit-surface! src src-rect dest dest-rect) → fixnum

See SDL_BlitSurface.

Returns zero if successful. May modify dest-rect.

[procedure] (blit-scaled! src src-rect dest dest-rect) → fixnum

See SDL_BlitScaled.

Returns zero if successful. May modify dest-rect.

[procedure] (fill-rect! surface rect color) → fixnum

See SDL_FillRect.

rect may be an sdl2:rect to fill part of the surface, or #f to fill the entire surface.

color may be an sdl2:color or a mapped color (an integer, like returned by map-rgba).

Returns zero if successful.

[procedure] (fill-rects! surface rects color) → fixnum

See SDL_FillRects.

rects must be a list of sdl2:rects.

color may be an sdl2:color or a mapped color (an integer, like returned by map-rgba).

Returns zero if successful.

[procedure] (surface-ref surface x y) → sdl2:color

Returns the color of the specified pixel on the surface, as an sdl2:color. Signals an error if x or y is out of bounds.

[procedure] (surface-ref-raw surface x y) → fixnum

Similar to surface-ref, but returns a mapped color (an integer) instead of an sdl2:color. You can use get-rgba to convert the mapped color to color fields.

[setter] (set! (surface-ref surface x y) color)
[setter] (surface-set! surface x y color)

Set the color of the specified pixel on the surface. Automatically locks and unlocks the surface if needed. Signals an error if x or y is out of bounds. color can be either an sdl2:color or a mapped color (an integer). Note: This procedure ignores the surface's clip rect (if any).

[procedure] (surface-clip-rect surface) → sdl2:rect

See SDL_GetClipRect.

Returns a copy of the surface's clip rect.

[setter] (set! (surface-clip-rect surface) rect) → boolean
[setter] (surface-clip-rect-set! surface rect) → boolean

See SDL_SetClipRect.

Sets the surface's clip rect to a copy of the given rect. Or rect can be #f to disable clipping.

Returns #t if the given rect intersects the surface at all, or #f if the rect is out of bounds (completely clips out the surface).

[procedure] (surface-color-key surface) → sdl2:color or #f
[procedure] (surface-colour-key surface) → sdl2:color or #f

See SDL_GetColorKey.

[procedure] (surface-color-key-raw surface) → fixnum or #f
[procedure] (surface-colour-key-raw surface) → fixnum or #f

Similar to surface-color-key, but returns a mapped color (an integer) instead of an sdl2:color.

[setter] (set! (surface-color-key surface) color) → boolean
[setter] (set! (surface-colour-key surface) color) → boolean
[setter] (surface-color-key-set! surface color) → boolean
[setter] (surface-colour-key-set! surface color) → boolean

See SDL_SetColorKey.

color can be an sdl2:color, a mapped color (an integer), or #f to disable color keying.

Returns zero if successful.

[procedure] (surface-alpha-mod surface) → fixnum

See SDL_GetSurfaceAlphaMod.

[setter] (set! (surface-alpha-mod surface) mod) → fixnum
[setter] (surface-alpha-mod-set! surface mod) → fixnum

See SDL_SetSurfaceAlphaMod.

Returns zero on success.

[procedure] (surface-blend-mode surface) → symbol

See SDL_GetSurfaceBlendMode.

Returns a blend mode symbol:

[setter] (set! (surface-blend-mode surface) mode)
[setter] (surface-blend-mode-set! surface mode)

See SDL_SetSurfaceBlendMode.

mode must be a blend mode symbol or equivalent integer:

[procedure] (surface-color-mod surface) → [r g b]
[procedure] (surface-colour-mod surface) → [r g b]

See SDL_GetSurfaceColorMod.

This procedure returns multiple values.

[setter] (set! (surface-color-mod surface) rgb)
[setter] (set! (surface-colour-mod surface) rgb)
[setter] (surface-color-mod-set! surface rgb)
[setter] (surface-colour-mod-set! surface rgb)

See SDL_SetSurfaceColorMod.

rgb can be a list (r g b) of color values, or an sdl2:color (the sdl2:color's "a" field will be ignored).

[procedure] (surface-palette surface) → sdl2:palette or #f

Returns the surface's palette, or #f if it has no palette. This is equivalent to:

(pixel-format-palette
 (surface-format surface))
[setter] (set! (surface-palette surface) palette)
[setter] (surface-palette-set! surface palette)

See SDL_SetSurfacePalette.

[setter] (surface-rle-set! surface enable)

See SDL_SetSurfaceRLE.

enable is #t to enable RLE acceleration or #f to disable it.

Timer

[procedure] (delay! milliseconds)

See SDL_Delay.

NOTE: This will (probably) cause all CHICKEN threads to pause, not only the thread that this is called from.

[procedure] (get-ticks) → fixnum

See SDL_GetTicks.

[procedure] (get-performance-counter) → fixnum

See SDL_GetPerformanceCounter.

[procedure] (get-performance-frequency) → fixnum

See SDL_GetPerformanceFrequency.

[procedure] (ticks-passed? ticks-a ticks-b) → boolean

See SDL_TICKS_PASSED.

Requires SDL 2.0.1 or higher. Signals an error if the compiled version of SDL is not high enough. Use (version-at-least? 2 0 1) to check before calling this procedure.

Window

[procedure] (create-window! title x y w h #!optional flags) → sdl2:window

See SDL_CreateWindow.

x and y can be integers, the symbol 'centered, or the symbol 'undefined.

flags defaults to '(). It must be a list of zero or more window flag symbols (or an equivalent integer bitfield):

[procedure] (get-window-from-id id) → sdl2:window

See SDL_GetWindowFromID.

[procedure] (destroy-window! window)

See SDL_DestroyWindow.

[procedure] (update-window-surface! window) → fixnum

See SDL_UpdateWindowSurface.

Returns zero if successful.

[procedure] (update-window-surface-rects! window rects) → fixnum

See SDL_UpdateWindowSurfaceRects.

rects must be a list of sdl2:rects.

Returns zero if successful.

[procedure] (show-window! window)

See SDL_ShowWindow.

[procedure] (hide-window! window)

See SDL_HideWindow.

[procedure] (maximize-window! window)

See SDL_MaximizeWindow.

[procedure] (minimize-window! window)

See SDL_MinimizeWindow.

[procedure] (raise-window! window)

See SDL_RaiseWindow.

[procedure] (restore-window! window)

See SDL_RestoreWindow.

[setter] (window-bordered-set! window bordered)

See SDL_SetWindowBordered.

bordered is #t to enable window decoration or #f to disable window decoration.

(There is currently no getter.)

[procedure] (window-brightness window) → float

See SDL_GetWindowBrightness.

[setter] (set! (window-brightness window) brightness) → fixnum
[setter] (window-brightness-set! window brightness) → fixnum

See SDL_SetWindowBrightness.

Returns zero if successful.

[procedure] (window-display-index window) → fixnum

See SDL_GetWindowDisplayIndex.

[procedure] (window-display-mode window) → sdl2:display-mode

See SDL_GetWindowDisplayMode.

[setter] (set! (window-display-mode window) mode) → fixnum
[setter] (window-display-mode-set! window mode) → fixnum

See SDL_SetWindowDisplayMode.

This affects the display mode used when the window is fullscreen.

Returns zero if successful.

[procedure] (window-flags window) → list of symbols

See SDL_GetWindowFlags.

Returns a list of window flag symbols.

[setter] (window-fullscreen-set! window mode)

See SDL_SetWindowFullscreen.

mode can be:

'fullscreen or #t
fullscreen
'fullscreen-desktop
fullscreen desktop
#f
not fullscreen

Returns zero if successful.

[procedure] (window-grab window) → boolean

See SDL_GetWindowGrab.

[setter] (set! (window-grab window) grab?
[setter] (window-grab-set! window grab?)

See SDL_SetWindowGrab.

[setter] (window-icon-set! window icon-surface)

See SDL_SetWindowIcon.

[procedure] (window-id window) → fixnum

See SDL_GetWindowID.

[procedure] (window-maximum-size window) → [width height]

See SDL_GetWindowMaximumSize.

This procedure returns multiple values.

[setter] (set! (window-maximum-size window) size)
[setter] (window-maximum-size-set! window size)

See SDL_SetWindowMaximumSize.

size must be a list of integers (width height).

[procedure] (window-minimum-size window) → [width height]

See SDL_GetWindowMinimumSize.

This procedure returns multiple values.

[setter] (set! (window-minimum-size window) size)
[setter] (window-minimum-size-set! window size)

See SDL_SetWindowMinimumSize.

size must be a list of integers (width height).

[procedure] (window-pixel-format window) → sdl2:pixel-format

See SDL_GetWindowPixelFormat.

[procedure] (window-position window) → [x y]

See SDL_GetWindowPosition.

This procedure returns multiple values.

[setter] (set! (window-position window) pos)
[setter] (window-position-set! window pos)

See SDL_SetWindowPosition.

pos must be a list of integers (x y).

[procedure] (window-size window) → [width height]

See SDL_GetWindowSize.

This procedure returns multiple values.

[setter] (set! (window-size window) size)
[setter] (window-size-set! window size)

See SDL_SetWindowSize.

size must be a list of integers (width height).

[procedure] (window-surface window) → sdl2:surface

See SDL_GetWindowSurface.

[procedure] (window-title window) → string

See SDL_GetWindowTitle.

[setter] (set! (window-title window) title)
[setter] (window-title-set! window title)

See SDL_SetWindowTitle.