5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
37 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
46 @ISA = qw(Exporter DynaLoader);
47 @EXPORT = qw( in verify &NULL );
50 # Give our caller SDL::Constant's stuff as well as ours.
54 $self->export_to_level(1, @_);
55 SDL::Constants->export_to_level(1);
57 $VERSION = '2.2.2.17';
59 print "$VERSION" if (defined($ARGV[0]) && ($ARGV[0] eq '--SDLperl'));
69 return 0 unless defined $k;
70 my $r = ((scalar grep { defined $_ && $_ eq $k } @t) <=> 0);
77 my ($options,@valid_options) = @_;
78 for (keys %$options) {
79 croak "Invalid option $_\n" unless in ($_, @valid_options);
89 SDL_perl - Simple DirectMedia Layer for Perl
97 SDL_perl is a package of perl modules that provides both functional and object orient
98 interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some
99 liberties with the SDL API, and attempts to adhere to the spirit of both the SDL
100 and Perl. This document describes the low-level functional SDL_perl API. For the
101 object oriented programming interface please see the documentation provided on a
106 As with the C language API, SDL_perl initializes the SDL environment through
107 the C<SDL::Init> subroutine. This routine takes a mode flag constructed through
108 the bitwise OR product of the following functions:
135 C<SDL::Init> returns 0 on success, or -1 on error.
139 The last error message set by the SDL library can be retrieved using the subroutine
140 C<SDL::GetError>, which returns a scalar containing the text of the message if any.
144 This subroutine allows an application to delay further operations for atleast a
145 number of milliseconds provided as the argument. The actual delay may be longer
146 than the specified depending on the underlying OS.
150 An application may retrieve the number of milliseconds expired since the initilization
151 of the application through this subroutine. This value resets rougly ever 49 days.
153 =head2 AddTimer(interval,callback,param)
155 C<AddTimer> will register a SDL_NewTimerCallback function to be executed after
156 C<interval> milliseconds, with parameter C<param>. SDL_NewTimerCallback objects
157 can be constructed with the C<NewTimer> subroutine. C<SDL::PerlTimerCallback>
158 will return a valid callback for executing a perl subroutine or closure.
159 This subroutine returns a SDL_TimerID for the newly registered callback, or NULL
162 =head2 NewTimer(interval,subroutine)
164 The C<NewTimer> takes an interval in milliseconds and a reference to a subroutine
165 to call at that interval. The subroutine will be invoked in a void context
166 and accepts no parameters. The callback used is that returned by C<SDL::PerlTimerCallback>.
167 C<NewTimer> returns the SDL_TimerID for the new timer or NULL on error.
169 =head2 RemoveTimer(id)
171 This subroutine taks a SDL_TimerID and removes it from the list of active callbacks.
172 RemoveTimer returns false on failure.
176 This subroutine is depreciated, please use C<NewTimer> or C<AddTimer> instead.
180 C<SDL::CDNumDrives> returns the number of available CD-ROM drives in the system.
184 The subroutine C<SDL::CDName> returns the system specific human readable device name
185 for the given CD-ROM drive.
189 This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy
190 or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM
193 =head2 CDTrackListing(cd)
195 C<SDL::CDTrackListing> returns a human readable description of a CD-ROM. For each
196 track one line will be produced with the following format:
198 Track index: %d, id %d, %2d.%2d
200 This is provided to ease the creation of human readable descriptions and debugging.
202 =head2 CDTrackId(track)
204 C<CDTrackId> returns the id field of the given SDL_CDtrack structure.
206 =head2 CDTrackType(track)
208 C<CDTrackType> returns the type field of the given SDL_CDtrack structure.
210 =head2 CDTrackLength(track)
212 C<CDTrackLength> returns the length field of the given SDL_CDtrack structure.
214 =head2 CDTrackOffset(track)
216 C<CDTrackOffset> returns the offset field of the given SDL_CDtrack structure.
220 The function C<CDStatus> returns the current status of the given SDL_CDrom.
221 C<CDStatus>'s return values are:
242 =head2 CDPlayTracks(cd,track,tracks,frame,frames)
244 To start playing from an arbitrary portion of a CD, one can provide
245 C<SDL::CDPlayTracks> with a CD, a starting track, the number of tracks,
246 a starting frame, and the number of frames to be played.
248 =head2 CDPlay(cd,track,length)
250 C<SDL::CDPlay> plays the next C<length> tracks starting from C<track>
254 This function will pause CD playback until resume is called.
258 This function will resume CD playback if paused.
262 C<SDL::CDStop> will stop CD playback if playing.
266 This function will eject the CD
270 This function will release an opened CD.
282 Pumps the event loop, gathering events from the input devices.
284 PumpEvents gathers all the pending input information from devices and places
285 it on the event queue.
286 Without calls to PumpEvents no events would ever be placed on the queue.
287 Often the need for calls to PumpEvents is hidden from the user
288 since L</ PollEvent> and WaitEvent implicitly call PumpEvents.
289 However, if you are not polling or waiting for events (e.g. you are filtering them),
290 then you must call PumpEvents to force an event queue update.
292 Note: You can only call this function in the thread that set the video mode.
318 =head2 MOUSEBUTTONDOWN
328 =head2 ActiveEventGain
330 =head2 ActiveEventState
340 =head2 SDLK_BACKSPACE
362 =head2 SDLK_AMPERSAND
366 =head2 SDLK_LEFTPAREN
368 =head2 SDLK_RIGHTPAREN
404 =head2 SDLK_SEMICOLON
416 =head2 SDLK_LEFTBRACKET
418 =head2 SDLK_BACKSLASH
420 =head2 SDLK_RIGHTBRACKET
424 =head2 SDLK_UNDERSCORE
426 =head2 SDLK_BACKQUOTE
502 =head2 SDLK_KP_PERIOD
504 =head2 SDLK_KP_DIVIDE
506 =head2 SDLK_KP_MULTIPLY
514 =head2 SDLK_KP_EQUALS
568 =head2 SDLK_SCROLLOCK
634 =head2 KeyEventUnicode
636 =head2 KeyEventScanCode
638 =head2 MouseMotionState
644 =head2 MouseMotionXrel
646 =head2 MouseMotionYrel
648 =head2 MouseButtonState
660 =head2 EnableKeyRepeat
668 =head2 CreateRGBSurface
670 =head2 CreateRGBSurfaceFrom
676 =head2 SurfacePalette
678 =head2 SurfaceBitsPerPixel