2 # Copyright (C) 2004 David J. Goehrig
8 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
17 @ISA = qw(Exporter DynaLoader);
18 @EXPORT = qw( in verify &NULL );
19 # reexport all SDL constants
20 for (@SDL::Constants::EXPORT) {
28 print "$VERSION" if (defined($ARGV[0]) && ($ARGV[0] eq '--SDLperl'));
38 (scalar grep { defined $_ && $_ eq $k } @t) <=> 0;
42 my ($options,@valid_options) = @_;
43 for (keys %$options) {
44 die "Invalid option $_\n" unless in ($_, @valid_options);
54 SDL_perl - Simple DirectMedia Layer for Perl
62 SDL_perl is a package of perl modules that provides both functional and object orient
63 interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some
64 liberties with the SDL API, and attempts to adhere to the spirit of both the SDL
65 and Perl. This document describes the low-level functional SDL_perl API. For the
66 object oriented programming interface please see the documentation provided on a
71 As with the C language API, SDL_perl initializes the SDL environment through
72 the C<SDL::Init> subroutine. This routine takes a mode flag constructed through
73 the bitwise OR product of the following functions:
100 C<SDL::Init> returns 0 on success, or -1 on error.
104 The last error message set by the SDL library can be retrieved using the subroutine
105 C<SDL::GetError>, which returns a scalar containing the text of the message if any.
109 This subroutine allows an application to delay further operations for atleast a
110 number of milliseconds provided as the argument. The actual delay may be longer
111 than the specified depending on the underlying OS.
115 An application may retrieve the number of milliseconds expired since the initilization
116 of the application through this subroutine. This value resets rougly ever 49 days.
118 =head2 AddTimer(interval,callback,param)
120 C<AddTimer> will register a SDL_NewTimerCallback function to be executed after
121 C<interval> milliseconds, with parameter C<param>. SDL_NewTimerCallback objects
122 can be constructed with the C<NewTimer> subroutine. C<SDL::PerlTimerCallback>
123 will return a valid callback for executing a perl subroutine or closure.
124 This subroutine returns a SDL_TimerID for the newly registered callback, or NULL
127 =head2 NewTimer(interval,subroutine)
129 The C<NewTimer> takes an interval in milliseconds and a reference to a subroutine
130 to call at that interval. The subroutine will be invoked in a void context
131 and accepts no parameters. The callback used is that returned by C<SDL::PerlTimerCallback>.
132 C<NewTimer> returns the SDL_TimerID for the new timer or NULL on error.
134 =head2 RemoveTimer(id)
136 This subroutine taks a SDL_TimerID and removes it from the list of active callbacks.
137 RemoveTimer returns false on failure.
141 This subroutine is depreciated, please use C<NewTimer> or C<AddTimer> instead.
145 C<SDL::CDNumDrives> returns the number of available CD-ROM drives in the system.
149 The subroutine C<SDL::CDName> returns the system specific human readable device name
150 for the given CD-ROM drive.
154 This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy
155 or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM
158 =head2 CDTrackListing(cd)
160 C<SDL::CDTrackListing> returns a human readable description of a CD-ROM. For each
161 track one line will be produced with the following format:
163 Track index: %d, id %d, %2d.%2d
165 This is provided to ease the creation of human readable descriptions and debugging.
167 =head2 CDTrackId(track)
169 C<CDTrackId> returns the id field of the given SDL_CDtrack structure.
171 =head2 CDTrackType(track)
173 C<CDTrackType> returns the type field of the given SDL_CDtrack structure.
175 =head2 CDTrackLength(track)
177 C<CDTrackLength> returns the length field of the given SDL_CDtrack structure.
179 =head2 CDTrackOffset(track)
181 C<CDTrackOffset> returns the offset field of the given SDL_CDtrack structure.
185 The function C<CDStatus> returns the current status of the given SDL_CDrom.
186 C<CDStatus>'s return values are:
207 =head2 CDPlayTracks(cd,track,tracks,frame,frames)
209 To start playing from an arbitrary portion of a CD, one can provide
210 C<SDL::CDPlayTracks> with a CD, a starting track, the number of tracks,
211 a starting frame, and the number of frames to be played.
213 =head2 CDPlay(cd,track,length)
215 C<SDL::CDPlay> plays the next C<length> tracks starting from C<track>
219 This function will pause CD playback until resume is called.
223 This function will resume CD playback if paused.
227 C<SDL::CDStop> will stop CD playback if playing.
231 This function will eject the CD
235 This function will release an opened CD.
271 =head2 MOUSEBUTTONDOWN
281 =head2 ActiveEventGain
283 =head2 ActiveEventState
293 =head2 SDLK_BACKSPACE
315 =head2 SDLK_AMPERSAND
319 =head2 SDLK_LEFTPAREN
321 =head2 SDLK_RIGHTPAREN
357 =head2 SDLK_SEMICOLON
369 =head2 SDLK_LEFTBRACKET
371 =head2 SDLK_BACKSLASH
373 =head2 SDLK_RIGHTBRACKET
377 =head2 SDLK_UNDERSCORE
379 =head2 SDLK_BACKQUOTE
455 =head2 SDLK_KP_PERIOD
457 =head2 SDLK_KP_DIVIDE
459 =head2 SDLK_KP_MULTIPLY
467 =head2 SDLK_KP_EQUALS
521 =head2 SDLK_SCROLLOCK
587 =head2 KeyEventUnicode
589 =head2 KeyEventScanCode
591 =head2 MouseMotionState
597 =head2 MouseMotionXrel
599 =head2 MouseMotionYrel
601 =head2 MouseButtonState
613 =head2 EnableKeyRepeat
621 =head2 CreateRGBSurface
623 =head2 CreateRGBSurfaceFrom
629 =head2 SurfacePalette
631 =head2 SurfaceBitsPerPixel
633 =head2 SurfaceBytesPerPixel
651 =head2 SurfaceColorKey
671 =head2 GetVideoSurface
699 =head2 PaletteNColors
731 =head2 MapRGB (surface,r,g,b)
733 C<SDL::MapRGB> translates the composite red (r), green (g), blue (b)
734 colors according to the given surface to a interger color value. This
735 integer can be used in functions like C<SDL::FillRect>, and is not
736 the same as the format independent Color object returned by C<SDL::NewColor>.
738 =head2 MapRGBA (surface,r,g,b,a)
740 C<SDL::MapRGBA> works as C<SDL::MapRGB> but takes an additional alpha (a)
741 component for semi-transperant colors.
763 =head2 FillRect(surface,rect,color)
765 C<SDL::FillRect> draws a solid rectangle of color on the given surface.
766 If the rectangle is NULL, the entire surface will be painted.
806 =head2 ConvertAudioData
822 =head2 MIX_MAX_VOLUME
824 =head2 MIX_DEFAULT_FREQUENCY
826 =head2 MIX_DEFAULT_FORMAT
828 =head2 MIX_DEFAULT_CHANNELS
832 =head2 MIX_FADING_OUT
838 =head2 MixAllocateChannels
846 =head2 MixQuickLoadWAV
852 =head2 MixSetPostMixCallback
854 =head2 MixSetMusicHook
856 =head2 MixSetMusicFinishedHook
858 =head2 MixGetMusicHookData
860 =head2 MixReverseChannels
862 =head2 MixGroupChannel
864 =head2 MixGroupChannels
866 =head2 MixGroupAvailable
870 =head2 MixGroupOldest
874 =head2 MixPlayChannel
876 =head2 MixPlayChannelTimed
880 =head2 MixFadeInChannel
882 =head2 MixFadeInChannelTimed
884 =head2 MixFadeInMusic
888 =head2 MixVolumeChunk
890 =head2 MixVolumeMusic
892 =head2 MixHaltChannel
898 =head2 MixExpireChannel
900 =head2 MixFadeOutChannel
902 =head2 MixFadeOutGroup
904 =head2 MixFadeOutMusic
906 =head2 MixFadingMusic
908 =head2 MixFadingChannel
918 =head2 MixResumeMusic
920 =head2 MixRewindMusic
922 =head2 MixPausedMusic
926 =head2 MixPlayingMusic
946 =head2 GL_ACCUM_RED_SIZE
948 =head2 GL_ACCUM_GREEN_SIZE
950 =head2 GL_ACCUM_BLUE_SIZE
952 =head2 GL_ACCUM_ALPHA_SIZE
954 =head2 GL_BUFFER_SIZE
958 =head2 GL_STENCIL_SIZE
960 =head2 GL_DOUBLEBUFFER
962 =head2 GL_SetAttribute
964 =head2 GL_GetAttribute
966 =head2 GL_SwapBuffers
976 =head2 JoystickOpened
980 =head2 JoystickNumAxes
982 =head2 JoystickNumBalls
984 =head2 JoystickNumHats
986 =head2 JoystickNumButtons
988 =head2 JoystickUpdate
990 =head2 JoystickGetAxis
992 =head2 JoystickGetHat
994 =head2 JoystickGetButton
996 =head2 JoystickGetBall
1006 David J. Goehrig, Wayne Keenan, Guillaume Cottenceau
1010 perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3)
1011 SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3)