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

sdl-base

The sdl-base egg is a successor to the sdl egg (the latter is expected to become deprecated in the future).

Unlike sdl, sdl-base has only the binding for the basic SDL library. This allows for a fine-grained control over what gets linked with your program. For bindings to the complementary libraries see their respective eggs: sdl-img for SDL_Image, sdl-mixer for SDL_Mixer and sdl-ttf for SDL_TTF.

Naming conventions

The sdl-base egg uses roughtly the same naming conventions as the sdl egg and as the guile-sdl: SDL_ prefix is replaced with sdl-, and hyphens are used to separate words instead of camel-case.

Procedures

sdl-version is a structure for holding the version of the SDL library. This is a wrapper for SDL_version structure in the C library. SDL_version consists of 3 fields: major version number, minor version number and patch number. You don’t usually need to create new instances of this structure: you obtain the version of SDL program was compiled with or linked with, and then get individual fields or check if the version is not too old with ``sdl-version-at-least``.

[procedure] (make-sdl-version pointer)

Creates a new wrapper over the C’s SDL_version structure. Usually you won’t need to use this function directly. Instead, use (sdl-compiled-version) and (sdl-linked-version) to obtain the version information.

[procedure] (sdl-version-major sdl-version)

Evaluates to the major version number for an SDL version in question.

[procedure] (sdl-version-minor sdl-version)

Evaluates to the minor version number for an SDL version in question.

[procedure] (sdl-version-patch sdl-version)

Evaluates to the patch number for an SDL version in question.

[procedure] (sdl-version-at-least sdl-version major minor patch)

Convenient function to check all the three components at once: evaluates to #t if the version is newer or equal to the version denoted by the major, minor and patch arguments, or to #f otherwise. This is analogous to the SDL_VERSION_ATLEAST in the C interface.

[procedure] (sdl-compiled-version)

Returns the sdl-version structure describing the SDL version number of the SDL library used during the compilation. This is analogous to the SDL_COMPILEDVERSION macro in the C interface.

[procedure] (sdl-linked-version)

Returns the sdl-version structure describing the SDL version number of the SDL library used the program is linked against. This is analogous to the SDL_VERSION macro in the C interface.

sdl-rect is a structure for describing a rectangle. It is widely used in the SDL library. It has two fields, x and y, denoting its position and two fields, w and h denoting width and height respectively. All the values are integers and measured in pixels.

[procedure] (make-sdl-rect x y w h)

Creates a new sdl-rect structure with the values given in the arguments.

[procedure] (sdl-rect-buffer sdl-rect)

???

[procedure] (sdl-rect? obj)

Evaluates to #t if obj is sdl-rect, or #f otherwise.

[procedure] (sdl-rect-x sdl-rect)

Evaluates to the horizontal position of the leftmost part of a given sdl-rect in pixels.

[procedure] (sdl-rect-y sdl-rect)

Evaluates to the vertical position of the topmost part a given sdl-rect in pixels. Like in many programming libraries, in SDL the y axis runs from top to bottom.

[procedure] (sdl-rect-w sdl-rect)

Evaluates to the width of a given sdl-rect in pixels.

[procedure] (sdl-rect-h sdl-rect)

Evaluates to the height of a given sdl-rect in pixels.

The sdl-pixel-format structure describes the way pixels are stored in the surface. It is a wrapper for the SDL_PixelFormat structure in SDL’s C interface.

Currently the sdl egg exposes no function to work with the SDL_Palette structure.

[procedure] (make-sdl-pixel-format pointer)

Creates a new wrapper over the C’s SDL_PixelFormat structure. Usually you won’t need to use this function directly.

[procedure] (sdl-pixel-format? obj)

Evaluates to #t if obj is sdl-pixel-format, or to #f otherwise.

[procedure] (sdl-rect-bytes-per-pixel sdl-rect)

Evaluates to the number of bytes used to store one pixel in a given sdl-pixel-format. The result is always an integer value.

[procedure] (sdl-rect-rmask sdl-rect)

Evaluates to the red mask, 32-bit integer number describing the way red-colour component is stored in a given sdl-pixel-format. The result is always an integer value. The red mask is an integer value in which the bits set to 1 represent bits used to store the red value. Red mask is not used for 8-bit (1-byte) pixel formats.

[procedure] (sdl-rect-gmask sdl-rect)

Evaluates to the green mask, 32-bit integer value. Green mask is not used for 8-bit (1-byte) pixel formats.

[procedure] (sdl-rect-bmask sdl-rect)

Evaluates to the blue mask, 32-bit integer value. Blue mask is not used for 8-bit (1-byte) pixel formats.

[procedure] (sdl-rect-amask sdl-rect)

Evaluates to the alpha mask, 32-bit integer value. Alpha mask is not used for 8-bit (1-byte) pixel formats.

The sdl_surface structure represents the object used to store image data. It is characterised by width (w), height (h), pixel format (pixel-format), flags describing additional information, the actual pixel values (pixels) and some other information. It is a wrapper over SDL_Surface structure in SDL’s C interface.

Unlike most other objects, surfaces must be explicitly disposed of after using with the sdl-free-surface function.

[procedure] (make-sdl-surface pointer)

Creates a new wrapper over the C’s SDL_PixelFormat structure. Usually you won’t need to use this function directly, its main purpose is interoperability with foreign C code. To create new empty surfaces, use the sdl-create-rgb-surface function. To create surface from files, use

[procedure] (sdl-surface? obj)

Evaluates to #t if obj is sdl-surface, or to #f otherwise.

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

Creates a RGB(A) surface with the given height, width, rmask, gmask, bmask and amask. This is a wrapper for SDL_CreateRGBSurface function.

Flags can be: SDL_SWSURFACE (store surface in general-purpose memory) or SDL_HWSURFACE (store surface in video memory), SDL_SRCCOLORKEY (turn on colour-keying; use sdl-set-color-key! to change the value of this flag after surface creation), SDL_SRCALPHA (use alpha-channel for surface; this flag is automatically set if amask is non-zero; sdl-set-alpha! allows to change this flag later). Flags can be combined with +.

[procedure] (sdl-surface-flags sdl-surface)

Evaluates to flags describing the given surface.

[procedure] (sdl-surface-pixel-format sdl-surface)

Evaluates to pixel format describing the given surface.

[procedure] (sdl-surface-width sdl-surface)

Evaluates to the width of a given surface.

[procedure] (sdl-surface-height sdl-surface)

Evaluates to the height of a given surface.

[procedure] (sdl-surface-pitch sdl-surface)

Evaluates to the actual number of bytes describing each row of a given surface.

[procedure] (sdl-surface-pixels sdl-surface)

Evaluates to the pixel data (??? how is it mapped to Scheme objects???) a given surface.

[procedure] (sdl-surface-pixels-length sdl-surface)

Evaluates to the size of pixel data in bytes.

[procedure] (sdl-free-surface sdl-surface)

Disposes of the unused surface. Surface should not be used after calling this function. Failing to call this function on used surfaces may result in memory leaks.

sdl-video-info is a read-only structure that contains information on the video mode. It is returned by sdl-get-video-info and cointains information either on the best available video mode (if called before sdl-set-video-mode) or on the current video mode.

[procedure] (make-sdl-video-info pointer)

Creates a new Scheme structure from the C’s structure. This function is usually not neccessary in Scheme programs: just use sdl-get-video-mode directly instead of calling it from C code.

[procedure] (sdl-video-info-pointer)

????

[procedure] (sdl-get-video-info)

Returns a sdl-video-info structure describing either the 'best' video mode (if called before sdl-set-video-mode) or the current video mode.

[procedure] (sdl-video-info-hw-available sdl-video-info)

Evaluates to 1 if it is possible to create hardware-accelerated surfaces according to the data in the sdl-video-info, to 0 otherwise.

[procedure] (sdl-video-info-wm-available sdl-video-info)

Evaluates to 1 if the window manager is available according to the data in the sdl-video-info, to 0 otherwise.

[procedure] (sdl-video-info-blit-hw sdl-video-info)

Evaluates to 1} if blits from hardware memory to hardware memory are hardware-accelerated, according to the data in the {{sdl-video-info, 0 otherwise.

[procedure] (sdl-video-info-blit-hw-cc sdl-video-info)

Evaluates to 1 its from hardware memory to hardware memory with colour key are hardware-accelerated, according to the data in the sdl-video-info, 0 otherwise.

[procedure] (sdl-video-info-blit-hw-a sdl-video-info)

Evaluates to 1 its from hardware memory to hardware memory with alpha channel are hardware-accelerated, according to the data in the sdl-video-info, to 0 otherwise.

[procedure] (sdl-video-info-blit-sw sdl-video-info)

Evaluates to 1 if blits from software memory to hardware memory are hardware-accelerated, according to the data in the sdl-video-info, 0 otherwise.

[procedure] (sdl-video-info-blit-sw-cc sdl-video-info)

Evaluates to 1 if blits from software memory to hardware memory with colour key are hardware-accelerated, according to the data in the sdl-video-info, 0 otherwise.

[procedure] (sdl-video-info-blit-sw-a sdl-video-info)

Evaluates to 1 if blits from software memory to hardware memory with alpha channel are hardware-accelerated, according to the data in the sdl-video-info, 0 otherwise.

[procedure] (sdl-video-info-blit-fill sdl-video-info)

Evaluates to 1 if colour fills are hardware-accelerated, according to the data in the sdl-video-info, or to 0 otherwise.

[procedure] (sdl-video-info-video-mem sdl-video-info)

Evaluates to an integer representing the total amount of video memory in kilobytes, according to sdl-video-info.

[procedure] (sdl-video-info-vfmt sdl-video-info)

Evaluates to sdl-pixel-format structure describing the pixel format of the video mode described by sdl-video-info.

[procedure] (sdl-video-info-current-w sdl-video-info)

Evaluates to the width, in pixels, of the video mode described by sdl-video-info.

[procedure] (sdl-video-info-current-h sdl-video-info)

Evaluates to the height, in pixels, of the video mode described by sdl-video-info.

TODO: undocumented functions

[procedure] (make-sdl-color ...)
[procedure] (sdl-color-buffer ...)
[procedure] (sdl-color? ...)
[procedure] (sdl-color-r ...)
[procedure] (sdl-color-g ...)
[procedure] (sdl-color-b ...)
[procedure] (make-sdl-event ...)
[procedure] (sdl-event-buffer sdl-event-buffer-set! ...)
[procedure] (sdl-event-type ...)
[procedure] (sdl-event? ...)
[procedure] (sdl-event-gain ...)
[procedure] (set-sdl-event-gain! ...)
[procedure] (sdl-event-which ...)
[procedure] (set-sdl-event-which! ...)
[procedure] (sdl-event-state ...)
[procedure] (set-sdl-event-state! ...)
[procedure] (sdl-event-scancode ...)
[procedure] (set-sdl-event-scancode! ...)
[procedure] (sdl-event-sym ...)
[procedure] (set-sdl-event-sym! ...)
[procedure] (sdl-event-mod ...)
[procedure] (set-sdl-event-mod! ...)
[procedure] (sdl-event-unicode ...)
[procedure] (set-sdl-event-unicode! ...)
[procedure] (sdl-event-x ...)
[procedure] (set-sdl-event-x! ...)
[procedure] (sdl-event-y ...)
[procedure] (set-sdl-event-y! ...)
[procedure] (sdl-event-xrel ...)
[procedure] (set-sdl-event-xrel! ...)
[procedure] (sdl-event-yrel ...)
[procedure] (set-sdl-event-yrel! ...)
[procedure] (sdl-event-axis ...)
[procedure] (set-sdl-event-axis! ...)
[procedure] (sdl-event-ball ...)
[procedure] (set-sdl-event-ball! ...)
[procedure] (sdl-event-hat ...)
[procedure] (set-sdl-event-hat! ...)
[procedure] (sdl-event-value ...)
[procedure] (set-sdl-event-value! ...)
[procedure] (sdl-event-button ...)
[procedure] (set-sdl-event-button! ...)
[procedure] (sdl-event-w ...)
[procedure] (set-sdl-event-w! ...)
[procedure] (sdl-event-h ...)
[procedure] (set-sdl-event-h! ...)
[procedure] (sdl-get-clip-rect! ...)
[procedure] (sdl-set-clip-rect! ...)
[procedure] (sdl-set-color-key! ...)
[procedure] (sdl-set-alpha! ...)
[procedure] (sdl-display-format ...)
[procedure] (sdl-display-format-alpha ...)
[procedure] (sdl-convert-surface ...)
[procedure] (sdl-init ...)
[procedure] (sdl-init-sub-system ...)
[procedure] (sdl-quit-sub-system ...)
[procedure] (sdl-quit ...)
[procedure] (sdl-was-init ...)
[procedure] (sdl-get-error ...)
[procedure] (sdl-clear-error! ...)
[procedure] (sdl-wm-set-caption ...)
[procedure] (sdl-wm-get-caption-title ...)
[procedure] (sdl-wm-get-caption-icon ...)
[procedure] (sdl-wm-get-caption ...)
[procedure] (sdl-wm-set-icon ...)
[procedure] (sdl-wm-iconify-window ...)
[procedure] (sdl-wm-toggle-full-screen ...)
[procedure] (sdl-wm-grab-input ...)
[procedure] (sdl-get-ticks ...)
[procedure] (sdl-delay ...)
[procedure] (timer? ...)
[procedure] (get-time-of-day ...)
[procedure] (get-time-of-day ...)
[procedure] (sdl-add-relative-timer! ...)
[procedure] (sdl-pump-events ...)
[procedure] (sdl-poll-event! ...)
[procedure] (sdl-wait-event!* ...)
[procedure] (sdl-wait-event! ...)
[procedure] (sdl-push-event ...)
[procedure] (sdl-event-state! ...)
[procedure] (sdl-get-mouse-state ...)
[procedure] (sdl-warp-mouse ...)
[procedure] (sdl-enable-unicode ...)
[procedure] (sdl-get-video-surface ...)
[procedure] (sdl-video-driver-name ...)
[procedure] (sdl-set-video-mode ...)
[procedure] (sdl-video-mode-ok ...)
[procedure] (sdl-show-cursor ...)
[procedure] (sdl-map-rgb ...)
[procedure] (sdl-map-rgba ...)
[procedure] (sdl-fill-rect ...)
[procedure] (sdl-flip ...)
[procedure] (sdl-free-surface ...)
[procedure] (sdl-blit-surface ...)
[procedure] (sdl-with-clip-rect ...)
[procedure] (make-sdl-joystick ...)
[procedure] (sdl-joystick-pointer ...)
[procedure] (sdl-joystick? ...)
[procedure] (sdl-joystick-event-state ...)
[procedure] (sdl-joystick-update ...)
[procedure] (sdl-num-joysticks ...)
[procedure] (sdl-joystick-name ...)
[procedure] (sdl-joystick-open ...)
[procedure] (sdl-joystick-opened ...)
[procedure] (sdl-joystick-index ...)
[procedure] (sdl-joystick-num-axes ...)
[procedure] (sdl-joystick-num-balls ...)
[procedure] (sdl-joystick-num-hats ...)
[procedure] (sdl-joystick-num-buttons ...)
[procedure] (sdl-joystick-update ...)
[procedure] (sdl-joystick-get-axis ...)
[procedure] (sdl-joystick-get-hat ...)
[procedure] (sdl-joystick-get-button ...)
[procedure] (sdl-joystick-close ...)
[procedure] (sdl-gl-swap-buffers ...)
[procedure] (sdl-gl-set-attribute ...)
[procedure] (sdl-gl-get-attribute ...)
[procedure] (heap? ...)