X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSDL.pm;h=094dd125c9db6a376d0a785f8d979c2a143cecf3;hb=bbe5d2f55f14c54f36188c75c8db6cd858682e4c;hp=6f012bae4829fd5a85616108cb368b163bdfb5da;hpb=7b6a53a1f5064ca5b8ab0243f7bcf6209e6bf5a4;p=sdlgit%2FSDL_perl.git diff --git a/lib/SDL.pm b/lib/SDL.pm index 6f012ba..094dd12 100644 --- a/lib/SDL.pm +++ b/lib/SDL.pm @@ -3,7 +3,7 @@ # SDL.pm # # Copyright (C) 2005 David J. Goehrig -# +# Copyright (C) 2009 Kartik Thakore # ------------------------------------------------------------------------------ # # This library is free software; you can redistribute it and/or @@ -24,9 +24,9 @@ # # Please feel free to send questions, suggestions or improvements to: # -# David J. Goehrig -# dgoehrig@cpan.org -# Copyright (C) 2009 Kartik Thakore +# Kartik Thakore +# kthakore@cpan.org +# package SDL; @@ -47,12 +47,18 @@ BEGIN { @EXPORT = qw( in verify &NULL ); }; +# Give our caller SDL::Constant's stuff as well as ours. +sub import { + my $self = shift; -$VERSION = '2.2.1'; + $self->export_to_level(1, @_); + SDL::Constants->export_to_level(1); +} +$VERSION = '2.3'; print "$VERSION" if (defined($ARGV[0]) && ($ARGV[0] eq '--SDLperl')); -$SDL::DEBUG=1; +$SDL::DEBUG=0; sub NULL { return 0; @@ -60,7 +66,11 @@ sub NULL { sub in { my ($k,@t) = @_; - (scalar grep { defined $_ && $_ eq $k } @t) <=> 0; + return 0 unless defined $k; + my $r = ((scalar grep { defined $_ && $_ eq $k } @t) <=> 0); + return 0 if $r eq ''; + return $r; + } sub verify (\%@) { @@ -91,33 +101,83 @@ and Perl. This document describes the low-level functional SDL_perl API. For t object oriented programming interface please see the documentation provided on a per class basis. +=head1 The SDL Perl 2009 Development Team + +=head2 Documentation + + Nick: magnet + +=head2 Perl Development + + Nick: Garu + Name: Breno G. de Oliveira + + Nick: Dngor + Name: Rocco Caputo + + Nick: nferraz + Name: Nelson Ferraz + + Nick: acme + Name: Leon Brocard + + Nick: FROGGS + Name: Tobias Leich + +=head2 Maintainance + + Nick: kthakore + Name: Kartik Thakore + +=head1 MacOSX Experimental Usage + +Please get libsdl packages from Fink + + perl Build.PL + perl Build test + perl Build bundle + perl Build install + +=head2 Running SDL Perl Scripts in MacOSX + +First set the PERL5LIB environment variable to the dependencies of your script + + %export PERL5LIB=$PERL5LIB:./lib + +Use the SDLPerl executable made in the bundle and call your scripts + + %SDLPerl.app/Contents/MacOS/SDLPerl yourScript.pl + +=head1 Functions exported by SDL.pm + =head2 Init(flags) As with the C language API, SDL_perl initializes the SDL environment through the C subroutine. This routine takes a mode flag constructed through -the bitwise OR product of the following functions: +the bitwise OR product of the following constants: =over 4 + =item * -INIT_AUDIO() +INIT_AUDIO =item * -INIT_VIDEO() +INIT_VIDEO =item * -INIT_CDROM() +INIT_CDROM =item * -INIT_EVERYTHING() +INIT_EVERYTHING =item * -INIT_NOPARACHUTE() +INIT_NOPARACHUTE =item * -INIT_JOYSTICK() +INIT_JOYSTICK =item * -INIT_TIMER() +INIT_TIMER =back @@ -252,7 +312,7 @@ C will stop CD playback if playing. =head2 CDEject(cd) -This function will eject the CD +This function will eject the CD. =head2 CDClose(cd) @@ -260,24 +320,80 @@ This function will release an opened CD. =head2 CDNumTracks +This function return the number of tracks on a CD, +it take a SDL_CD as first parameter. + =head2 CDCurTrack +This function return the number of the current track on a CD, +it take a SDL_CD as first parameter. + =head2 CDCurFrame +this function return the frame offset within the current track on a CD. +it take a SDL_CD as first parameter. + =head2 CDTrack +CDtrack stores data on each track on a CD, its fields should be pretty self explainatory. +CDtrack take a SDL::CD as input and return a SDL_CDTrack. + =head2 PumpEvents +Pumps the event loop, gathering events from the input devices. + +PumpEvents gathers all the pending input information from devices and places +it on the event queue. +Without calls to PumpEvents no events would ever be placed on the queue. +Often the need for calls to PumpEvents is hidden from the user +since L and WaitEvent implicitly call PumpEvents. +However, if you are not polling or waiting for events (e.g. you are filtering them), +then you must call PumpEvents to force an event queue update. +PumpEvents doesn't return any value and doesn't take any parameters. + +Note: You can only call this function in the thread that set the video mode. + =head2 NewEvent +Create a new event.It return a SDL::Event. + =head2 FreeEvent +FreeEvent delete the SDL::Event given as first parameter. +it doesn't return anything. + =head2 PollEvent +Polls for currently pending events. +If event is not undef, the next event is removed from the queue and returned as a L< SDL::Event>. +As this function implicitly calls L, you can only call this function in the thread that set the video mode. +it take a SDL::Event as first parameter. + =head2 WaitEvent +Waits indefinitely for the next available event, returning undef if there was an error while waiting for events, +a L< SDL::Event> otherwise. +If event is not NULL, the next event is removed. +As this function implicitly calls L, you can only call this function in the thread that set the video mode. +WaitEvent take a SDL::Event as first parameter. + =head2 EventState +This function allows you to set the state of processing certain event types. + +it take an event type as first argument, and a state as second. + +If state is set to SDL_IGNORE, that event type will be automatically +dropped from the event queue and will not be filtered. +If state is set to SDL_ENABLE, that event type will be processed +normally. +If state is set to SDL_QUERY, SDL_EventState will return the current +processing state of the specified event type. + +A list of event types can be found in the L. + +it returns a state(?). + =head2 IGNORE =head2 ENABLE @@ -302,10 +418,18 @@ This function will release an opened CD. =head2 EventType +EventType return the type of the SDL::Event given as first parameter. + =head2 ActiveEventGain +ActiveEventGain return the active gain from the SDL::Event given as first parameter. +see L for more informations about the active state. + =head2 ActiveEventState +ActiveEventState return the active state from the SDL::Event given as first parameter. +see L for more informations about the active state. + =head2 APPMOUSEFOCUS =head2 APPINPUTFOCUS @@ -314,6 +438,9 @@ This function will release an opened CD. =head2 KeyEventState +KeyEventState return the active key state from the SDL::Event given as first parameter. +see L for me more informations about the active key. + =head2 SDLK_BACKSPACE =head2 SDLK_TAB @@ -606,10 +733,19 @@ This function will release an opened CD. =head2 KeyEventSym +KeyEventSym return the key pressed/released information from the SDL::Event given as first parameter. +see L for more informations about the keyboard events. + =head2 KeyEventMod +KeyEventMod return the mod keys pressed information from the SDL::Event given as first parameter. +see L for more informations about the keyboard events. + =head2 KeyEventUnicode +KeyEventMod return the unicode translated keys pressed/released information from the SDL::Event given as first parameter. +see L for more informations about the keyboard events. + =head2 KeyEventScanCode =head2 MouseMotionState @@ -654,385 +790,4 @@ This function will release an opened CD. =head2 SurfaceBitsPerPixel -=head2 SurfaceBytesPerPixel - -=head2 SurfaceRshift - -=head2 SurfaceGshift - -=head2 SurfaceBshift - -=head2 SurfaceAshift - -=head2 SurfaceRmask - -=head2 SurfaceGmask - -=head2 SurfaceBmask - -=head2 SurfaceAmask - -=head2 SurfaceColorKey - -=head2 SurfaceAlpha - -=head2 SurfaceW - -=head2 SurfaceH - -=head2 SurfacePitch - -=head2 SurfacePixels - -=head2 SurfacePixel - -=head2 MUSTLOCK - -=head2 SurfaceLock - -=head2 SurfaceUnlock - -=head2 GetVideoSurface - -=head2 VideoInfo - -=head2 NewRect - -=head2 FreeRect - -=head2 RectX - -=head2 RectY - -=head2 RectW - -=head2 RectH - -=head2 NewColor - -=head2 ColorR - -=head2 ColorG - -=head2 CologB - -=head2 FreeColor - -=head2 NewPalette - -=head2 PaletteNColors - -=head2 PaletteColors - -=head2 SWSURFACE - -=head2 HWSURFACE - -=head2 ANYFORMAT - -=head2 HWPALETTE - -=head2 DOUBLEBUF - -=head2 FULLSCREEN - -=head2 ASYNCBLIT - -=head2 OPENGL - -=head2 HWACCEL - -=head2 VideoModeOK - -=head2 SetVideoMode - -=head2 UpdateRects - -=head2 Flip - -=head2 SetColors - -=head2 MapRGB (surface,r,g,b) - -C translates the composite red (r), green (g), blue (b) -colors according to the given surface to a interger color value. This -integer can be used in functions like C, and is not -the same as the format independent Color object returned by C. - -=head2 MapRGBA (surface,r,g,b,a) - -C works as C but takes an additional alpha (a) -component for semi-transperant colors. - -=head2 GetRGB - -=head2 GetRGBA - -=head2 SaveBMP - -=head2 SetColorKey - -=head2 SRCCOLORKEY - -=head2 RLEACCEL - -=head2 SRCALPHA - -=head2 SetAlpha - -=head2 DisplayFormat - -=head2 BlitSurface - -=head2 FillRect(surface,rect,color) - -C draws a solid rectangle of color on the given surface. -If the rectangle is NULL, the entire surface will be painted. - -=head2 WMSetCaption - -=head2 WMGetCaption - -=head2 WMSetIcon - -=head2 WarpMouse - -=head2 NewCursor - -=head2 FreeCursor - -=head2 SetCursor - -=head2 GetCursor - -=head2 ShowCursor - -=head2 NewAudioSpec - -=head2 FreeAudioSpec - -=head2 AUDIO_U8 - -=head2 AUDIO_S8 - -=head2 AUDIO_U16 - -=head2 AUDIO_S16 - -=head2 AUDIO_U16MSB - -=head2 AUDIO_S16MSB - -=head2 NewAudioCVT - -=head2 FreeAudioCVT - -=head2 ConvertAudioData - -=head2 OpenAudio - -=head2 PauseAudio - -=head2 UnlockAudio - -=head2 CloseAudio - -=head2 FreeWAV - -=head2 LoadWAV - -=head2 MixAudio - -=head2 MIX_MAX_VOLUME - -=head2 MIX_DEFAULT_FREQUENCY - -=head2 MIX_DEFAULT_FORMAT - -=head2 MIX_DEFAULT_CHANNELS - -=head2 MIX_NO_FADING - -=head2 MIX_FADING_OUT - -=head2 MIX_FADING_IN - -=head2 MixOpenAudio - -=head2 MixAllocateChannels - -=head2 MixQuerySpec - -=head2 MixLoadWAV - -=head2 MixLoadMusic - -=head2 MixQuickLoadWAV - -=head2 MixFreeChunk - -=head2 MixFreeMusic - -=head2 MixSetPostMixCallback - -=head2 MixSetMusicHook - -=head2 MixSetMusicFinishedHook - -=head2 MixGetMusicHookData - -=head2 MixReverseChannels - -=head2 MixGroupChannel - -=head2 MixGroupChannels - -=head2 MixGroupAvailable - -=head2 MixGroupCount - -=head2 MixGroupOldest - -=head2 MixGroupNewer - -=head2 MixPlayChannel - -=head2 MixPlayChannelTimed - -=head2 MixPlayMusic - -=head2 MixFadeInChannel - -=head2 MixFadeInChannelTimed - -=head2 MixFadeInMusic - -=head2 MixVolume - -=head2 MixVolumeChunk - -=head2 MixVolumeMusic - -=head2 MixHaltChannel - -=head2 MixHaltGroup - -=head2 MixHaltMusic - -=head2 MixExpireChannel - -=head2 MixFadeOutChannel - -=head2 MixFadeOutGroup - -=head2 MixFadeOutMusic - -=head2 MixFadingMusic - -=head2 MixFadingChannel - -=head2 MixPause - -=head2 MixResume - -=head2 MixPaused - -=head2 MixPauseMusic - -=head2 MixResumeMusic - -=head2 MixRewindMusic - -=head2 MixPausedMusic - -=head2 MixPlaying - -=head2 MixPlayingMusic - -=head2 MixCloseAudio - -=head2 NewFont - -=head2 UseFont - -=head2 PutString - -=head2 TextWidth - -=head2 GL_RED_SIZE - -=head2 GL_GREEN_SIZE - -=head2 GL_BLUE_SIZE - -=head2 GL_ALPHA_SIZE - -=head2 GL_ACCUM_RED_SIZE - -=head2 GL_ACCUM_GREEN_SIZE - -=head2 GL_ACCUM_BLUE_SIZE - -=head2 GL_ACCUM_ALPHA_SIZE - -=head2 GL_BUFFER_SIZE - -=head2 GL_DEPTH_SIZE - -=head2 GL_STENCIL_SIZE - -=head2 GL_DOUBLEBUFFER - -=head2 GL_SetAttribute - -=head2 GL_GetAttribute - -=head2 GL_SwapBuffers - -=head2 BigEndian - -=head2 NumJoysticks - -=head2 JoystickName - -=head2 JoystickOpen - -=head2 JoystickOpened - -=head2 JoystickIndex - -=head2 JoystickNumAxes - -=head2 JoystickNumBalls - -=head2 JoystickNumHats - -=head2 JoystickNumButtons - -=head2 JoystickUpdate - -=head2 JoystickGetAxis - -=head2 JoystickGetHat - -=head2 JoystickGetButton - -=head2 JoystickGetBall - -=head2 JoystickClose - -=head1 AUTHOR - -David J. Goehrig - -=head1 CONTRIBUTORS - -David J. Goehrig, Wayne Keenan, Guillaume Cottenceau - -=head1 SEE ALSO - - perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3) - SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3) - -=cut - +=head2 SurfaceBy