Next: , Previous: , Up: The (sdl *) Modules   [Contents][Index]


3 Video

Procedure: create-cursor data mask w h x y

Return a new cursor from data and mask (both u8 uniform vectors), sized w by h and with hot pixel located at x,y.

Procedure: create-yuv-overlay width height format [display]

Create a new YUV overlay, sized width by height with overlay format (a symbol or an exact number). Optional arg display specifies a surface to use instead of creating a new one.

Procedure: get-video-surface

Return the current display surface.

Procedure: video-cmf

Return information about the video hardware as three values: capabilities (list of symbols), memory (integer), and format (pixel format object). The capabilities are:

hw-available
wm-available
blit-hw   blit-hw-CC   blit-hw-A
blit-sw   blit-sw-CC   blit-sw-A
blit-fill
Procedure: video-driver-name

Return the name of the video driver.

Procedure: list-modes [format [flags]]

Return a list of available screen dimensions for pixel format and flags (see video flags). Format defaults to that for the current screen. Flags default to none. Return #f if no modes are available, #t if all are available.

Procedure: video-mode-ok width height bpp [flags]

Check to see if a particular video mode is supported. Args are width, height, bpp (numbers), and flags (see video flags). Return #f if the mode is not supported, or a number indicating the bits-per-pixel of the closest available mode supporting width and height.

Procedure: set-video-mode width height bpp [flags]

Set the SDL video mode with width, height and bits-per-pixel bpp. Optional arg flags (see video flags) is supported. Return a new surface.

3.1 Rectangles

The external representation of a Rectangle object is:

#<SDL-Rect wxhsxsy>

where w and h are the width and height of the rectangle, and x and y are its horizontal and vertical coordinates. s may be ‘+’ or ‘-’.

Procedure: rect? obj

Return #t iff obj is an SDL-rectangle object.

Procedure: make-rect x y width height

Return a rectangle object with location x,y and dimensions width by height.

Procedure: rect:x rect

Get x from rect.

Procedure: rect:y rect

Get y from rect.

Procedure: rect:w rect

Get w from rect.

Procedure: rect:h rect

Get h from rect.

Procedure: rect:set-x! rect value

Set x in rect to value.

Procedure: rect:set-y! rect value

Set y in rect to value.

Procedure: rect:set-w! rect value

Set w in rect to value.

Procedure: rect:set-h! rect value

Set h in rect to value.

Procedure: update-rect surface x [y [w [h]]]

Update surface within a specified rectangle. The second arg can either be an SDL-Rect object, or the second through fifth args are numbers specifying the x, y, width and height of a rectangular area.

Procedure: update-rects surface ls

On surface, update the rectangles in ls, a list of rectangles.

Procedure: flip [surface]

Swap double buffers of the default surface, or of surface if specified.

3.2 Colors

The external representation of a Color object is:

#<SDL-Color r g b>

where r is the decimal value of the color object’s red component, and g and b the likewise respective green and blue components.

Procedure: color? obj

Return #t iff obj is an SDL-Color object.

Procedure: make-color r g b

Return a color object with r, g, and b components.

Procedure: color:r color

Get r from color.

Procedure: color:g color

Get g from color.

Procedure: color:b color

Get b from color.

Procedure: color:set-r! color value

Set r in color to value.

Procedure: color:set-g! color value

Set g in color to value.

Procedure: color:set-b! color value

Set b in color to value.

Procedure: set-colors! surface colors [start]

Set a portion of the colormap for the 8-bit surface using colors, a vector of SDL-Colors. Optional arg start (an integer in the range [0,255]) specifies the portion to be modified. It defaults to 0.

Procedure: set-palette surface flags colors [start]

Set the palette of an 8-bit surface using flags (see palette flags) and colors, a vector of SDL-Colors. Optional arg start (an integer in the range [0,255]) specifies the portion to be modified. It defaults to 0.

Procedure: set-gamma redgamma greengamma bluegamma

Set the color gamma function for the display using real numbers redgamma, greengamma and bluegamma.

Procedure: get-gamma-ramp

Return the gamma translation lookup tables currently used by the display as a list of three tables, for red, green and blue. Each table is a u16 uniform vector of length 256. Return #f if unsuccessful.

Procedure: set-gamma-ramp r g b

Set the gamma translation lookup tables currently used by the display to tables r, g and b, each a u16 uniform vector of length 256, or #f, in which case that particular component is unchanged. Return #t if successful.

Procedure: map-rgb format r [g [b]]

Map a RGB color value to the pixel format. The second arg can be an SDL-Color, otherwise the second through fourth args are red, green and blue values (numbers). Return the mapped components as an unsigned integer.

Procedure: map-rgba format r g [b [a]]

Map a RGB color value to the pixel format. If the second arg is an SDL-Color, the third is an alpha value (number). Otherwise, the second through fifth args are red, green, blue and alpha values (numbers). Return the mapped components as an unsigned integer.

Procedure: pixel-rgb pixel format

Return RGB info from pixel in the specified pixel format as three values: r, g and b (all integers).

Procedure: pixel-rgba pixel format

Return RGBA info from pixel in the specified pixel format as four values: r, g, b and a (all integers).

Procedure: fill-rect surface rect color

Fill surface rect with color (a number). If rect is #f, fill the entire surface. Return #t if successful.

Procedure: display-format surface

Return a new surface made by converting surface to the display format. Return #f if not successful.

Procedure: display-format-alpha surface

Return a new surface made by converting surface to the display format, with an alpha channel. Return #f if not successful.

Procedure: warp-mouse x y

Set the position of the mouse cursor to x,y.

Procedure: set-cursor cursor

Set the current mouse cursor to cursor.

Procedure: get-cursor

Get the current mouse cursor.

Procedure: show-cursor [setting]

Return the current visibility of the pointer (aka “mouse cursor”) as a boolean. If arg setting (a boolean) is specified, set the visibility to setting (the returned visibility corresponds to that before the call, regardless).

Procedure: gl-get-attribute attribute

Return the value of a special SDL/OpenGL attribute.

Procedure: gl-set-attribute attribute value

Set the special SDL/OpenGL attribute to value. Both args are numbers.

Procedure: gl-swap-buffers

Swap OpenGL framebuffers/Update Display.

Procedure: lock-yuv-overlay overlay

Lock the given YUV overlay. Return #f if successful.

Procedure: unlock-yuv-overlay overlay

Unlock the previously locked YUV overlay.

Procedure: display-yuv-overlay overlay dstrect

Blit the YUV overlay to the display dstrect over which it was created. Return #t if successful.

3.3 Windowing System Interaction

Procedure: get-wm-info

Return information on the window manager, as a list of the form: (VERSION SUBSYSTEM DISPLAY WINDOW FSWINDOW WMWINDOW). VERSION is a sub-list of form: (MAJOR MINOR PATCH), where element is an integer. SUBSYSTEM is either the symbol x11, or #f. DISPLAY is a pointer (machine address) of the X11 Display structure, converted to an integer. WINDOW, FSWINDOW and WMWINDOW are Window identifiers (also integers).

Procedure: set-caption title [icon]

Set the title-bar and icon name of the display window to title and icon (both strings), respectively. If icon is not specified, use title by default.

Procedure: caption-ti

Return display-window caption as two values: title and icon (both strings, or #f if not set).

Procedure: set-icon icon

Set icon for the display window.

Procedure: iconify-window

Iconify/Minimize the window. Return #t if successful.

Procedure: toggle-full-screen [surface]

Toggle the default video surface between windowed and fullscreen mode, if supported. Optional arg surface specifies another surface to toggle. Return #t if successful.

Procedure: grab-input [mode]

Grab mouse and keyboard input. Return new grab state. Optional arg mode (a symbol) specifies the kind of grab, one of query (the default), off or on.

Procedure: get-app-state

Return the current state of the application, a list of symbols. The list may include: ‘mousefocus’, ‘inputfocus’, ‘active’.

3.4 Surface

The external representation of a Surface object is:

;; normally:
#<SDL-Surface wxh depth bpp lock>

;; when the object is not associated with a SDL_Surface:
#<SDL-Surface NULL>

where w and h are the width and height of the surface, and depth is its bit-depth (e.g., ‘32’ for an RGBA surface). If the surface is locked, lock displays as ‘L’, otherwise nothing.

Procedure: make-surface width height [flags]

Return a new surface of dimensions width by height. Optional third arg flags (see video flags) further specifies the surface. Color depth and masks are those for the current video surface.

Procedure: create-rgb-surface flags width height depth rmask gmask bmask amask

Return an empty surface. The eight arguments, directly analagous to those for SDL_CreateRGBSurface, are: flags (list of symbols, see video flags), width, height, depth, rmask, gmask, bmask, amask (all numbers).

Procedure: surface:w surface

Get w from surface.

Procedure: surface:h surface

Get h from surface.

Procedure: surface:depth surface

Get format->BitsPerPixel from surface.

Procedure: surface:flags surface

Return flags from surface as a (possibly empty) list of symbols.

Procedure: surface-get-format surface

Return a new pixel format, the same used by surface.

Procedure: surface? obj

Return true iff obj is a surface.

Procedure: lock-surface surface

Lock surface for direct access. Return #t if successful.

Procedure: unlock-surface surface

Unlock previously locked surface.

Procedure: load-bmp filename

Load bitmap data from filename. Return a new surface if successful, otherwise #f.

Procedure: load-image filename

Load image data from filename. Return a new surface if successful, otherwise #f.

Procedure: save-bmp surface filename

Save surface to filename in Windows BMP format. Return #t if successful.

Procedure: surface-color-key! surface pixel [rle]

Set the color key for surface to pixel. If pixel is #f, clear the current color key. Otherwise, it should be an integer of the appropriate depth for surface (e.g., in the range [0,65535] for 16 bpp). If color key processing is enabled, optional arg rle is a boolean that enables (true) or disables (false, the default) RLE acceleration. Return #t if successful.

Procedure: surface-alpha! surface alpha [rle]

Set alpha blending for the entire surface to alpha. If alpha is #f, disable alpha blending. Otherwise it should be an integer in the range [0,255] or one of the symbols transparent or opaque. If alpha blending is enabled, optional arg rle is a boolean that enables (true) or disables (false, the default) RLE acceleration. Return #t if successful.

Procedure: set-clip-rect! surface [rect]

Set surface clipping rectangle to the whole surface. Optional arg rect, if non-#f, specifies a particular rectangle instead of using the whole surface.

Procedure: get-clip-rect surface

Return the clipping rectangle for surface.

Procedure: convert-surface surface format [flags]

Convert surface to the same format as another surface. Optional third arg flags is a list of flags (see video flags).

Procedure: blit-surface src [srcrect [dst [dstrect]]]

Perform a fast blit from the src surface srcrect to the dst surface dstrect. srcrect defaults to x=0, y=0, src surface dimensions. If unspecified dst is taken as the default video surface. dstrect likewise defaults to x=0, y=0, dst surface dimensions.

3.5 Misc Surface Operations

Procedure: vertical-flip-surface surface

Return a new surface created by flipping surface vertically.

Procedure: horizontal-flip-surface surface

Return a new surface created by flipping surface horizontally.

Procedure: vh-flip-surface surface

Return a new surface created by flipping surface both vertically and horizontally.

Procedure: surface-pixels surface [squash]

Return pixel data of surface as a new uniform vector. The uvec has type u8, u16 or u32, corresponding to the surface depth, with height x width elements. A 24bpp surface — depth-in-bytes of 3 — is expanded (per pixel) to u32, leaving the high byte clear.

Optional arg squash non-#f means to return a u8vector regardless of surface depth, with height x width x depth-in-bytes elements.

Procedure: must-lock? surface

Return #t if surface needs to be locked before access. Failure to do so may result in a segfault.


Next: Events, Previous: General SDL, Up: The (sdl *) Modules   [Contents][Index]