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 );
53 print "$VERSION" if (defined($ARGV[0]) && ($ARGV[0] eq '--SDLperl'));
63 return 0 unless defined $k;
68 my ($options,@valid_options) = @_;
69 for (keys %$options) {
70 croak "Invalid option $_\n" unless in ($_, @valid_options);
80 SDL_perl - Simple DirectMedia Layer for Perl
88 SDL_perl is a package of perl modules that provides both functional and object orient
89 interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some
90 liberties with the SDL API, and attempts to adhere to the spirit of both the SDL
91 and Perl. This document describes the low-level functional SDL_perl API. For the
92 object oriented programming interface please see the documentation provided on a
97 As with the C language API, SDL_perl initializes the SDL environment through
98 the C<SDL::Init> subroutine. This routine takes a mode flag constructed through
99 the bitwise OR product of the following functions:
125 C<SDL::Init> returns 0 on success, or -1 on error.
129 The last error message set by the SDL library can be retrieved using the subroutine
130 C<SDL::GetError>, which returns a scalar containing the text of the message if any.
134 This subroutine allows an application to delay further operations for atleast a
135 number of milliseconds provided as the argument. The actual delay may be longer
136 than the specified depending on the underlying OS.
140 An application may retrieve the number of milliseconds expired since the initilization
141 of the application through this subroutine. This value resets rougly ever 49 days.
143 =head2 AddTimer(interval,callback,param)
145 C<AddTimer> will register a SDL_NewTimerCallback function to be executed after
146 C<interval> milliseconds, with parameter C<param>. SDL_NewTimerCallback objects
147 can be constructed with the C<NewTimer> subroutine. C<SDL::PerlTimerCallback>
148 will return a valid callback for executing a perl subroutine or closure.
149 This subroutine returns a SDL_TimerID for the newly registered callback, or NULL
152 =head2 NewTimer(interval,subroutine)
154 The C<NewTimer> takes an interval in milliseconds and a reference to a subroutine
155 to call at that interval. The subroutine will be invoked in a void context
156 and accepts no parameters. The callback used is that returned by C<SDL::PerlTimerCallback>.
157 C<NewTimer> returns the SDL_TimerID for the new timer or NULL on error.
159 =head2 RemoveTimer(id)
161 This subroutine taks a SDL_TimerID and removes it from the list of active callbacks.
162 RemoveTimer returns false on failure.
166 This subroutine is depreciated, please use C<NewTimer> or C<AddTimer> instead.
170 C<SDL::CDNumDrives> returns the number of available CD-ROM drives in the system.
174 The subroutine C<SDL::CDName> returns the system specific human readable device name
175 for the given CD-ROM drive.
179 This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy
180 or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM
183 =head2 CDTrackListing(cd)
185 C<SDL::CDTrackListing> returns a human readable description of a CD-ROM. For each
186 track one line will be produced with the following format:
188 Track index: %d, id %d, %2d.%2d
190 This is provided to ease the creation of human readable descriptions and debugging.
192 =head2 CDTrackId(track)
194 C<CDTrackId> returns the id field of the given SDL_CDtrack structure.
196 =head2 CDTrackType(track)
198 C<CDTrackType> returns the type field of the given SDL_CDtrack structure.
200 =head2 CDTrackLength(track)
202 C<CDTrackLength> returns the length field of the given SDL_CDtrack structure.
204 =head2 CDTrackOffset(track)
206 C<CDTrackOffset> returns the offset field of the given SDL_CDtrack structure.
210 The function C<CDStatus> returns the current status of the given SDL_CDrom.
211 C<CDStatus>'s return values are:
232 =head2 CDPlayTracks(cd,track,tracks,frame,frames)
234 To start playing from an arbitrary portion of a CD, one can provide
235 C<SDL::CDPlayTracks> with a CD, a starting track, the number of tracks,
236 a starting frame, and the number of frames to be played.
238 =head2 CDPlay(cd,track,length)
240 C<SDL::CDPlay> plays the next C<length> tracks starting from C<track>
244 This function will pause CD playback until resume is called.
248 This function will resume CD playback if paused.
252 C<SDL::CDStop> will stop CD playback if playing.
256 This function will eject the CD
260 This function will release an opened CD.
296 =head2 MOUSEBUTTONDOWN
306 =head2 ActiveEventGain
308 =head2 ActiveEventState
318 =head2 SDLK_BACKSPACE
340 =head2 SDLK_AMPERSAND
344 =head2 SDLK_LEFTPAREN
346 =head2 SDLK_RIGHTPAREN
382 =head2 SDLK_SEMICOLON
394 =head2 SDLK_LEFTBRACKET
396 =head2 SDLK_BACKSLASH
398 =head2 SDLK_RIGHTBRACKET
402 =head2 SDLK_UNDERSCORE
404 =head2 SDLK_BACKQUOTE
480 =head2 SDLK_KP_PERIOD
482 =head2 SDLK_KP_DIVIDE
484 =head2 SDLK_KP_MULTIPLY
492 =head2 SDLK_KP_EQUALS
546 =head2 SDLK_SCROLLOCK
612 =head2 KeyEventUnicode
614 =head2 KeyEventScanCode
616 =head2 MouseMotionState
622 =head2 MouseMotionXrel
624 =head2 MouseMotionYrel
626 =head2 MouseButtonState
638 =head2 EnableKeyRepeat
646 =head2 CreateRGBSurface
648 =head2 CreateRGBSurfaceFrom
654 =head2 SurfacePalette
656 =head2 SurfaceBitsPerPixel
658 =head2 SurfaceBytesPerPixel
676 =head2 SurfaceColorKey
696 =head2 GetVideoSurface
724 =head2 PaletteNColors
756 =head2 MapRGB (surface,r,g,b)
758 C<SDL::MapRGB> translates the composite red (r), green (g), blue (b)
759 colors according to the given surface to a interger color value. This
760 integer can be used in functions like C<SDL::FillRect>, and is not
761 the same as the format independent Color object returned by C<SDL::NewColor>.
763 =head2 MapRGBA (surface,r,g,b,a)
765 C<SDL::MapRGBA> works as C<SDL::MapRGB> but takes an additional alpha (a)
766 component for semi-transperant colors.
788 =head2 FillRect(surface,rect,color)
790 C<SDL::FillRect> draws a solid rectangle of color on the given surface.
791 If the rectangle is NULL, the entire surface will be painted.
831 =head2 ConvertAudioData
847 =head2 MIX_MAX_VOLUME
849 =head2 MIX_DEFAULT_FREQUENCY
851 =head2 MIX_DEFAULT_FORMAT
853 =head2 MIX_DEFAULT_CHANNELS
857 =head2 MIX_FADING_OUT
863 =head2 MixAllocateChannels
871 =head2 MixQuickLoadWAV
877 =head2 MixSetPostMixCallback
879 =head2 MixSetMusicHook
881 =head2 MixSetMusicFinishedHook
883 =head2 MixGetMusicHookData
885 =head2 MixReverseChannels
887 =head2 MixGroupChannel
889 =head2 MixGroupChannels
891 =head2 MixGroupAvailable
895 =head2 MixGroupOldest
899 =head2 MixPlayChannel
901 =head2 MixPlayChannelTimed
905 =head2 MixFadeInChannel
907 =head2 MixFadeInChannelTimed
909 =head2 MixFadeInMusic
913 =head2 MixVolumeChunk
915 =head2 MixVolumeMusic
917 =head2 MixHaltChannel
923 =head2 MixExpireChannel
925 =head2 MixFadeOutChannel
927 =head2 MixFadeOutGroup
929 =head2 MixFadeOutMusic
931 =head2 MixFadingMusic
933 =head2 MixFadingChannel
943 =head2 MixResumeMusic
945 =head2 MixRewindMusic
947 =head2 MixPausedMusic
951 =head2 MixPlayingMusic
971 =head2 GL_ACCUM_RED_SIZE
973 =head2 GL_ACCUM_GREEN_SIZE
975 =head2 GL_ACCUM_BLUE_SIZE
977 =head2 GL_ACCUM_ALPHA_SIZE
979 =head2 GL_BUFFER_SIZE
983 =head2 GL_STENCIL_SIZE
985 =head2 GL_DOUBLEBUFFER
987 =head2 GL_SetAttribute
989 =head2 GL_GetAttribute
991 =head2 GL_SwapBuffers
1001 =head2 JoystickOpened
1003 =head2 JoystickIndex
1005 =head2 JoystickNumAxes
1007 =head2 JoystickNumBalls
1009 =head2 JoystickNumHats
1011 =head2 JoystickNumButtons
1013 =head2 JoystickUpdate
1015 =head2 JoystickGetAxis
1017 =head2 JoystickGetHat
1019 =head2 JoystickGetButton
1021 =head2 JoystickGetBall
1023 =head2 JoystickClose
1031 David J. Goehrig, Wayne Keenan, Guillaume Cottenceau
1035 perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3)
1036 SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3)