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;
71 my ($options,@valid_options) = @_;
72 for (keys %$options) {
73 croak "Invalid option $_\n" unless in ($_, @valid_options);
83 SDL_perl - Simple DirectMedia Layer for Perl
91 SDL_perl is a package of perl modules that provides both functional and object orient
92 interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some
93 liberties with the SDL API, and attempts to adhere to the spirit of both the SDL
94 and Perl. This document describes the low-level functional SDL_perl API. For the
95 object oriented programming interface please see the documentation provided on a
100 As with the C language API, SDL_perl initializes the SDL environment through
101 the C<SDL::Init> subroutine. This routine takes a mode flag constructed through
102 the bitwise OR product of the following functions:
128 C<SDL::Init> returns 0 on success, or -1 on error.
132 The last error message set by the SDL library can be retrieved using the subroutine
133 C<SDL::GetError>, which returns a scalar containing the text of the message if any.
137 This subroutine allows an application to delay further operations for atleast a
138 number of milliseconds provided as the argument. The actual delay may be longer
139 than the specified depending on the underlying OS.
143 An application may retrieve the number of milliseconds expired since the initilization
144 of the application through this subroutine. This value resets rougly ever 49 days.
146 =head2 AddTimer(interval,callback,param)
148 C<AddTimer> will register a SDL_NewTimerCallback function to be executed after
149 C<interval> milliseconds, with parameter C<param>. SDL_NewTimerCallback objects
150 can be constructed with the C<NewTimer> subroutine. C<SDL::PerlTimerCallback>
151 will return a valid callback for executing a perl subroutine or closure.
152 This subroutine returns a SDL_TimerID for the newly registered callback, or NULL
155 =head2 NewTimer(interval,subroutine)
157 The C<NewTimer> takes an interval in milliseconds and a reference to a subroutine
158 to call at that interval. The subroutine will be invoked in a void context
159 and accepts no parameters. The callback used is that returned by C<SDL::PerlTimerCallback>.
160 C<NewTimer> returns the SDL_TimerID for the new timer or NULL on error.
162 =head2 RemoveTimer(id)
164 This subroutine taks a SDL_TimerID and removes it from the list of active callbacks.
165 RemoveTimer returns false on failure.
169 This subroutine is depreciated, please use C<NewTimer> or C<AddTimer> instead.
173 C<SDL::CDNumDrives> returns the number of available CD-ROM drives in the system.
177 The subroutine C<SDL::CDName> returns the system specific human readable device name
178 for the given CD-ROM drive.
182 This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy
183 or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM
186 =head2 CDTrackListing(cd)
188 C<SDL::CDTrackListing> returns a human readable description of a CD-ROM. For each
189 track one line will be produced with the following format:
191 Track index: %d, id %d, %2d.%2d
193 This is provided to ease the creation of human readable descriptions and debugging.
195 =head2 CDTrackId(track)
197 C<CDTrackId> returns the id field of the given SDL_CDtrack structure.
199 =head2 CDTrackType(track)
201 C<CDTrackType> returns the type field of the given SDL_CDtrack structure.
203 =head2 CDTrackLength(track)
205 C<CDTrackLength> returns the length field of the given SDL_CDtrack structure.
207 =head2 CDTrackOffset(track)
209 C<CDTrackOffset> returns the offset field of the given SDL_CDtrack structure.
213 The function C<CDStatus> returns the current status of the given SDL_CDrom.
214 C<CDStatus>'s return values are:
235 =head2 CDPlayTracks(cd,track,tracks,frame,frames)
237 To start playing from an arbitrary portion of a CD, one can provide
238 C<SDL::CDPlayTracks> with a CD, a starting track, the number of tracks,
239 a starting frame, and the number of frames to be played.
241 =head2 CDPlay(cd,track,length)
243 C<SDL::CDPlay> plays the next C<length> tracks starting from C<track>
247 This function will pause CD playback until resume is called.
251 This function will resume CD playback if paused.
255 C<SDL::CDStop> will stop CD playback if playing.
259 This function will eject the CD
263 This function will release an opened CD.
299 =head2 MOUSEBUTTONDOWN
309 =head2 ActiveEventGain
311 =head2 ActiveEventState
321 =head2 SDLK_BACKSPACE
343 =head2 SDLK_AMPERSAND
347 =head2 SDLK_LEFTPAREN
349 =head2 SDLK_RIGHTPAREN
385 =head2 SDLK_SEMICOLON
397 =head2 SDLK_LEFTBRACKET
399 =head2 SDLK_BACKSLASH
401 =head2 SDLK_RIGHTBRACKET
405 =head2 SDLK_UNDERSCORE
407 =head2 SDLK_BACKQUOTE
483 =head2 SDLK_KP_PERIOD
485 =head2 SDLK_KP_DIVIDE
487 =head2 SDLK_KP_MULTIPLY
495 =head2 SDLK_KP_EQUALS
549 =head2 SDLK_SCROLLOCK
615 =head2 KeyEventUnicode
617 =head2 KeyEventScanCode
619 =head2 MouseMotionState
625 =head2 MouseMotionXrel
627 =head2 MouseMotionYrel
629 =head2 MouseButtonState
641 =head2 EnableKeyRepeat
649 =head2 CreateRGBSurface
651 =head2 CreateRGBSurfaceFrom
657 =head2 SurfacePalette
659 =head2 SurfaceBitsPerPixel
661 =head2 SurfaceBytesPerPixel
679 =head2 SurfaceColorKey
699 =head2 GetVideoSurface
727 =head2 PaletteNColors
759 =head2 MapRGB (surface,r,g,b)
761 C<SDL::MapRGB> translates the composite red (r), green (g), blue (b)
762 colors according to the given surface to a interger color value. This
763 integer can be used in functions like C<SDL::FillRect>, and is not
764 the same as the format independent Color object returned by C<SDL::NewColor>.
766 =head2 MapRGBA (surface,r,g,b,a)
768 C<SDL::MapRGBA> works as C<SDL::MapRGB> but takes an additional alpha (a)
769 component for semi-transperant colors.
791 =head2 FillRect(surface,rect,color)
793 C<SDL::FillRect> draws a solid rectangle of color on the given surface.
794 If the rectangle is NULL, the entire surface will be painted.
834 =head2 ConvertAudioData
850 =head2 MIX_MAX_VOLUME
852 =head2 MIX_DEFAULT_FREQUENCY
854 =head2 MIX_DEFAULT_FORMAT
856 =head2 MIX_DEFAULT_CHANNELS
860 =head2 MIX_FADING_OUT
866 =head2 MixAllocateChannels
874 =head2 MixQuickLoadWAV
880 =head2 MixSetPostMixCallback
882 =head2 MixSetMusicHook
884 =head2 MixSetMusicFinishedHook
886 =head2 MixGetMusicHookData
888 =head2 MixReverseChannels
890 =head2 MixGroupChannel
892 =head2 MixGroupChannels
894 =head2 MixGroupAvailable
898 =head2 MixGroupOldest
902 =head2 MixPlayChannel
904 =head2 MixPlayChannelTimed
908 =head2 MixFadeInChannel
910 =head2 MixFadeInChannelTimed
912 =head2 MixFadeInMusic
916 =head2 MixVolumeChunk
918 =head2 MixVolumeMusic
920 =head2 MixHaltChannel
926 =head2 MixExpireChannel
928 =head2 MixFadeOutChannel
930 =head2 MixFadeOutGroup
932 =head2 MixFadeOutMusic
934 =head2 MixFadingMusic
936 =head2 MixFadingChannel
946 =head2 MixResumeMusic
948 =head2 MixRewindMusic
950 =head2 MixPausedMusic
954 =head2 MixPlayingMusic
974 =head2 GL_ACCUM_RED_SIZE
976 =head2 GL_ACCUM_GREEN_SIZE
978 =head2 GL_ACCUM_BLUE_SIZE
980 =head2 GL_ACCUM_ALPHA_SIZE
982 =head2 GL_BUFFER_SIZE
986 =head2 GL_STENCIL_SIZE
988 =head2 GL_DOUBLEBUFFER
990 =head2 GL_SetAttribute
992 =head2 GL_GetAttribute
994 =head2 GL_SwapBuffers
1004 =head2 JoystickOpened
1006 =head2 JoystickIndex
1008 =head2 JoystickNumAxes
1010 =head2 JoystickNumBalls
1012 =head2 JoystickNumHats
1014 =head2 JoystickNumButtons
1016 =head2 JoystickUpdate
1018 =head2 JoystickGetAxis
1020 =head2 JoystickGetHat
1022 =head2 JoystickGetButton
1024 =head2 JoystickGetBall
1026 =head2 JoystickClose
1034 David J. Goehrig, Wayne Keenan, Guillaume Cottenceau
1038 perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3)
1039 SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3)