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:
34 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
43 @ISA = qw(Exporter DynaLoader);
44 @EXPORT = qw( in verify &NULL );
50 print "$VERSION" if (defined($ARGV[0]) && ($ARGV[0] eq '--SDLperl'));
60 (scalar grep { defined $_ && $_ eq $k } @t) <=> 0;
64 my ($options,@valid_options) = @_;
65 for (keys %$options) {
66 die "Invalid option $_\n" unless in ($_, @valid_options);
76 SDL_perl - Simple DirectMedia Layer for Perl
84 SDL_perl is a package of perl modules that provides both functional and object orient
85 interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some
86 liberties with the SDL API, and attempts to adhere to the spirit of both the SDL
87 and Perl. This document describes the low-level functional SDL_perl API. For the
88 object oriented programming interface please see the documentation provided on a
93 As with the C language API, SDL_perl initializes the SDL environment through
94 the C<SDL::Init> subroutine. This routine takes a mode flag constructed through
95 the bitwise OR product of the following functions:
121 C<SDL::Init> returns 0 on success, or -1 on error.
125 The last error message set by the SDL library can be retrieved using the subroutine
126 C<SDL::GetError>, which returns a scalar containing the text of the message if any.
130 This subroutine allows an application to delay further operations for atleast a
131 number of milliseconds provided as the argument. The actual delay may be longer
132 than the specified depending on the underlying OS.
136 An application may retrieve the number of milliseconds expired since the initilization
137 of the application through this subroutine. This value resets rougly ever 49 days.
139 =head2 AddTimer(interval,callback,param)
141 C<AddTimer> will register a SDL_NewTimerCallback function to be executed after
142 C<interval> milliseconds, with parameter C<param>. SDL_NewTimerCallback objects
143 can be constructed with the C<NewTimer> subroutine. C<SDL::PerlTimerCallback>
144 will return a valid callback for executing a perl subroutine or closure.
145 This subroutine returns a SDL_TimerID for the newly registered callback, or NULL
148 =head2 NewTimer(interval,subroutine)
150 The C<NewTimer> takes an interval in milliseconds and a reference to a subroutine
151 to call at that interval. The subroutine will be invoked in a void context
152 and accepts no parameters. The callback used is that returned by C<SDL::PerlTimerCallback>.
153 C<NewTimer> returns the SDL_TimerID for the new timer or NULL on error.
155 =head2 RemoveTimer(id)
157 This subroutine taks a SDL_TimerID and removes it from the list of active callbacks.
158 RemoveTimer returns false on failure.
162 This subroutine is depreciated, please use C<NewTimer> or C<AddTimer> instead.
166 C<SDL::CDNumDrives> returns the number of available CD-ROM drives in the system.
170 The subroutine C<SDL::CDName> returns the system specific human readable device name
171 for the given CD-ROM drive.
175 This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy
176 or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM
179 =head2 CDTrackListing(cd)
181 C<SDL::CDTrackListing> returns a human readable description of a CD-ROM. For each
182 track one line will be produced with the following format:
184 Track index: %d, id %d, %2d.%2d
186 This is provided to ease the creation of human readable descriptions and debugging.
188 =head2 CDTrackId(track)
190 C<CDTrackId> returns the id field of the given SDL_CDtrack structure.
192 =head2 CDTrackType(track)
194 C<CDTrackType> returns the type field of the given SDL_CDtrack structure.
196 =head2 CDTrackLength(track)
198 C<CDTrackLength> returns the length field of the given SDL_CDtrack structure.
200 =head2 CDTrackOffset(track)
202 C<CDTrackOffset> returns the offset field of the given SDL_CDtrack structure.
206 The function C<CDStatus> returns the current status of the given SDL_CDrom.
207 C<CDStatus>'s return values are:
228 =head2 CDPlayTracks(cd,track,tracks,frame,frames)
230 To start playing from an arbitrary portion of a CD, one can provide
231 C<SDL::CDPlayTracks> with a CD, a starting track, the number of tracks,
232 a starting frame, and the number of frames to be played.
234 =head2 CDPlay(cd,track,length)
236 C<SDL::CDPlay> plays the next C<length> tracks starting from C<track>
240 This function will pause CD playback until resume is called.
244 This function will resume CD playback if paused.
248 C<SDL::CDStop> will stop CD playback if playing.
252 This function will eject the CD
256 This function will release an opened CD.
292 =head2 MOUSEBUTTONDOWN
302 =head2 ActiveEventGain
304 =head2 ActiveEventState
314 =head2 SDLK_BACKSPACE
336 =head2 SDLK_AMPERSAND
340 =head2 SDLK_LEFTPAREN
342 =head2 SDLK_RIGHTPAREN
378 =head2 SDLK_SEMICOLON
390 =head2 SDLK_LEFTBRACKET
392 =head2 SDLK_BACKSLASH
394 =head2 SDLK_RIGHTBRACKET
398 =head2 SDLK_UNDERSCORE
400 =head2 SDLK_BACKQUOTE
476 =head2 SDLK_KP_PERIOD
478 =head2 SDLK_KP_DIVIDE
480 =head2 SDLK_KP_MULTIPLY
488 =head2 SDLK_KP_EQUALS
542 =head2 SDLK_SCROLLOCK
608 =head2 KeyEventUnicode
610 =head2 KeyEventScanCode
612 =head2 MouseMotionState
618 =head2 MouseMotionXrel
620 =head2 MouseMotionYrel
622 =head2 MouseButtonState
634 =head2 EnableKeyRepeat
642 =head2 CreateRGBSurface
644 =head2 CreateRGBSurfaceFrom
650 =head2 SurfacePalette
652 =head2 SurfaceBitsPerPixel
654 =head2 SurfaceBytesPerPixel
672 =head2 SurfaceColorKey
692 =head2 GetVideoSurface
720 =head2 PaletteNColors
752 =head2 MapRGB (surface,r,g,b)
754 C<SDL::MapRGB> translates the composite red (r), green (g), blue (b)
755 colors according to the given surface to a interger color value. This
756 integer can be used in functions like C<SDL::FillRect>, and is not
757 the same as the format independent Color object returned by C<SDL::NewColor>.
759 =head2 MapRGBA (surface,r,g,b,a)
761 C<SDL::MapRGBA> works as C<SDL::MapRGB> but takes an additional alpha (a)
762 component for semi-transperant colors.
784 =head2 FillRect(surface,rect,color)
786 C<SDL::FillRect> draws a solid rectangle of color on the given surface.
787 If the rectangle is NULL, the entire surface will be painted.
827 =head2 ConvertAudioData
843 =head2 MIX_MAX_VOLUME
845 =head2 MIX_DEFAULT_FREQUENCY
847 =head2 MIX_DEFAULT_FORMAT
849 =head2 MIX_DEFAULT_CHANNELS
853 =head2 MIX_FADING_OUT
859 =head2 MixAllocateChannels
867 =head2 MixQuickLoadWAV
873 =head2 MixSetPostMixCallback
875 =head2 MixSetMusicHook
877 =head2 MixSetMusicFinishedHook
879 =head2 MixGetMusicHookData
881 =head2 MixReverseChannels
883 =head2 MixGroupChannel
885 =head2 MixGroupChannels
887 =head2 MixGroupAvailable
891 =head2 MixGroupOldest
895 =head2 MixPlayChannel
897 =head2 MixPlayChannelTimed
901 =head2 MixFadeInChannel
903 =head2 MixFadeInChannelTimed
905 =head2 MixFadeInMusic
909 =head2 MixVolumeChunk
911 =head2 MixVolumeMusic
913 =head2 MixHaltChannel
919 =head2 MixExpireChannel
921 =head2 MixFadeOutChannel
923 =head2 MixFadeOutGroup
925 =head2 MixFadeOutMusic
927 =head2 MixFadingMusic
929 =head2 MixFadingChannel
939 =head2 MixResumeMusic
941 =head2 MixRewindMusic
943 =head2 MixPausedMusic
947 =head2 MixPlayingMusic
967 =head2 GL_ACCUM_RED_SIZE
969 =head2 GL_ACCUM_GREEN_SIZE
971 =head2 GL_ACCUM_BLUE_SIZE
973 =head2 GL_ACCUM_ALPHA_SIZE
975 =head2 GL_BUFFER_SIZE
979 =head2 GL_STENCIL_SIZE
981 =head2 GL_DOUBLEBUFFER
983 =head2 GL_SetAttribute
985 =head2 GL_GetAttribute
987 =head2 GL_SwapBuffers
997 =head2 JoystickOpened
1001 =head2 JoystickNumAxes
1003 =head2 JoystickNumBalls
1005 =head2 JoystickNumHats
1007 =head2 JoystickNumButtons
1009 =head2 JoystickUpdate
1011 =head2 JoystickGetAxis
1013 =head2 JoystickGetHat
1015 =head2 JoystickGetButton
1017 =head2 JoystickGetBall
1019 =head2 JoystickClose
1027 David J. Goehrig, Wayne Keenan, Guillaume Cottenceau
1031 perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3)
1032 SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3)