SDL_perl - Simple DirectMedia Layer for Perl
use SDL;
SDL_perl is a package of perl modules that provides both functional and object orient interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some liberties with the SDL API, and attempts to adhere to the spirit of both the SDL and Perl. This document describes the low-level functional SDL_perl API. For the object oriented programming interface please see the documentation provided on a per class basis.
As with the C language API, SDL_perl initializes the SDL environment through the SDL::Init subroutine. This routine takes a mode flag constructed through the bitwise OR product of the following functions:
SDL::Init
INIT_VIDEO()
INIT_CDROM()
INIT_EVERYTHING()
INIT_NOPARACHUTE()
INIT_JOYSTICK()
INIT_TIMER()
SDL::Init returns 0 on success, or -1 on error.
The last error message set by the SDL library can be retrieved using the subroutine SDL::GetError, which returns a scalar containing the text of the message if any.
SDL::GetError
This subroutine allows an application to delay further operations for atleast a number of milliseconds provided as the argument. The actual delay may be longer than the specified depending on the underlying OS.
An application may retrieve the number of milliseconds expired since the initilization of the application through this subroutine. This value resets rougly ever 49 days.
AddTimer will register a SDL_NewTimerCallback function to be executed after interval milliseconds, with parameter param. SDL_NewTimerCallback objects can be constructed with the NewTimer subroutine. SDL::PerlTimerCallback will return a valid callback for executing a perl subroutine or closure. This subroutine returns a SDL_TimerID for the newly registered callback, or NULL on error.
AddTimer
interval
param
NewTimer
SDL::PerlTimerCallback
The NewTimer takes an interval in milliseconds and a reference to a subroutine to call at that interval. The subroutine will be invoked in a void context and accepts no parameters. The callback used is that returned by SDL::PerlTimerCallback. NewTimer returns the SDL_TimerID for the new timer or NULL on error.
This subroutine taks a SDL_TimerID and removes it from the list of active callbacks. RemoveTimer returns false on failure.
This subroutine is depreciated, please use NewTimer or AddTimer instead.
SDL::CDNumDrives returns the number of available CD-ROM drives in the system.
SDL::CDNumDrives
The subroutine SDL::CDName returns the system specific human readable device name for the given CD-ROM drive.
SDL::CDName
This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM drive.
SDL::CDTrackListing returns a human readable description of a CD-ROM. For each track one line will be produced with the following format:
SDL::CDTrackListing
Track index: %d, id %d, %2d.%2d
This is provided to ease the creation of human readable descriptions and debugging.
CDTrackId returns the id field of the given SDL_CDtrack structure.
CDTrackId
CDTrackType returns the type field of the given SDL_CDtrack structure.
CDTrackType
CDTrackLength returns the length field of the given SDL_CDtrack structure.
CDTrackLength
CDTrackOffset returns the offset field of the given SDL_CDtrack structure.
CDTrackOffset
The function CDStatus returns the current status of the given SDL_CDrom. CDStatus's return values are:
CDStatus
CD_TRAYEMPTY
CD_PLAYING
CD_STOPPED
CD_PAUSED
CD_ERROR
To start playing from an arbitrary portion of a CD, one can provide SDL::CDPlayTracks with a CD, a starting track, the number of tracks, a starting frame, and the number of frames to be played.
SDL::CDPlayTracks
SDL::CDPlay plays the next length tracks starting from track
SDL::CDPlay
length
track
This function will pause CD playback until resume is called.
This function will resume CD playback if paused.
SDL::CDStop will stop CD playback if playing.
SDL::CDStop
This function will eject the CD
This function will release an opened CD.
SDL::MapRGB translates the composite red (r), green (g), blue (b) colors according to the given surface to a interger color value. This integer can be used in functions like SDL::FillRect, and is not the same as the format independent Color object returned by SDL::NewColor.
SDL::MapRGB
SDL::FillRect
SDL::NewColor
SDL::MapRGBA works as SDL::MapRGB but takes an additional alpha (a) component for semi-transperant colors.
SDL::MapRGBA
SDL::FillRect draws a solid rectangle of color on the given surface. If the rectangle is NULL, the entire surface will be painted.
David J. Goehrig
David J. Goehrig, Wayne Keenan, Guillaume Cottenceau
perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3) SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3)
1 POD Error
The following errors were encountered while parsing the POD:
=over should be: '=over' or '=over positive_number'
To install SDL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL
CPAN shell
perl -MCPAN -e shell install SDL
For more information on module installation, please visit the detailed CPAN module installation guide.