X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSDL.pm;h=7953486cb3b25739da669d15d40389e9b32ddc0d;hb=15a6855a1873836b12bf4f67f0cb600bd4209b6f;hp=4dff767da9706890dfeb82f4d2061814106c6522;hpb=5c44eb34dedf77aa7c4f679ef5d5bbab24dea8d9;p=sdlgit%2FSDL_perl.git diff --git a/lib/SDL.pm b/lib/SDL.pm index 4dff767..7953486 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,8 +24,8 @@ # # Please feel free to send questions, suggestions or improvements to: # -# David J. Goehrig -# dgoehrig@cpan.org +# Kartik Thakore +# kthakore@cpan.org # package SDL; @@ -54,12 +54,11 @@ sub import { $self->export_to_level(1, @_); SDL::Constants->export_to_level(1); } - -$VERSION = '2.2.1'; +$VERSION = '2.3'; print "$VERSION" if (defined($ARGV[0]) && ($ARGV[0] eq '--SDLperl')); -$SDL::DEBUG=1; +$SDL::DEBUG=0; sub NULL { return 0; @@ -102,948 +101,192 @@ 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. -=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: - -=over 4 -=item * -INIT_AUDIO() - -=item * -INIT_VIDEO() - -=item * -INIT_CDROM() - -=item * -INIT_EVERYTHING() - -=item * -INIT_NOPARACHUTE() - -=item * -INIT_JOYSTICK() - -=item * -INIT_TIMER() - -=back - -C returns 0 on success, or -1 on error. - -=head2 GetError() - -The last error message set by the SDL library can be retrieved using the subroutine -C, which returns a scalar containing the text of the message if any. - -=head2 Delay(ms) - -This subroutine allows an application to delay further operations for atleast a -number of milliseconds provided as the argument. The actual delay may be longer -than the specified depending on the underlying OS. - -=head2 GetTicks() - -An application may retrieve the number of milliseconds expired since the initilization -of the application through this subroutine. This value resets rougly ever 49 days. - -=head2 AddTimer(interval,callback,param) - -C will register a SDL_NewTimerCallback function to be executed after -C milliseconds, with parameter C. SDL_NewTimerCallback objects -can be constructed with the C subroutine. C -will return a valid callback for executing a perl subroutine or closure. -This subroutine returns a SDL_TimerID for the newly registered callback, or NULL -on error. - -=head2 NewTimer(interval,subroutine) - -The C takes an interval in milliseconds and a reference to a subroutine -to call at that interval. The subroutine will be invoked in a void context -and accepts no parameters. The callback used is that returned by C. -C returns the SDL_TimerID for the new timer or NULL on error. - -=head2 RemoveTimer(id) - -This subroutine taks a SDL_TimerID and removes it from the list of active callbacks. -RemoveTimer returns false on failure. +=head1 The SDL Perl 2009 Development Team -=head2 SetTimer +=head2 Documentation -This subroutine is depreciated, please use C or C instead. + Nick: magnet -=head2 CDNumDrives() +=head2 Perl Development -C returns the number of available CD-ROM drives in the system. - -=head2 CDName(drive) - -The subroutine C returns the system specific human readable device name -for the given CD-ROM drive. - -=head2 CDOpen(drive) - -This subroutine opens a CD-ROM drive for access, returning NULL if the drive is busy -or otherwise unavailable. On success this subroutine returns a handle to the CD-ROM -drive. - -=head2 CDTrackListing(cd) - -C returns a human readable description of a CD-ROM. For each -track one line will be produced with the following format: + Nick: Garu + Name: Breno G. de Oliveira + + Nick: Dngor + Name: Rocco Caputo - Track index: %d, id %d, %2d.%2d + Nick: nferraz + Name: Nelson Ferraz -This is provided to ease the creation of human readable descriptions and debugging. + Nick: acme + Name: Leon Brocard + + Nick: FROGGS + Name: Tobias Leich -=head2 CDTrackId(track) +=head2 Maintainance + + Nick: kthakore + Name: Kartik Thakore -C returns the id field of the given SDL_CDtrack structure. +=head1 MacOSX Experimental Usage -=head2 CDTrackType(track) +Please get libsdl packages from Fink + + perl Build.PL + perl Build test + perl Build bundle + perl Build install -C returns the type field of the given SDL_CDtrack structure. +=head2 Running SDL Perl Scripts in MacOSX -=head2 CDTrackLength(track) +First set the PERL5LIB environment variable to the dependencies of your script + + %export PERL5LIB=$PERL5LIB:./lib -C returns the length field of the given SDL_CDtrack structure. +Use the SDLPerl executable made in the bundle and call your scripts -=head2 CDTrackOffset(track) + %SDLPerl.app/Contents/MacOS/SDLPerl yourScript.pl -C returns the offset field of the given SDL_CDtrack structure. +=head1 Functions exported by SDL.pm -=head2 CDStatus(cd) +=head2 init(flags) -The function C returns the current status of the given SDL_CDrom. -C's return values are: +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 constants: =over 4 =item * -CD_TRAYEMPTY +INIT_AUDIO =item * -CD_PLAYING +INIT_VIDEO =item * -CD_STOPPED +INIT_CDROM =item * -CD_PAUSED +INIT_EVERYTHING =item * -CD_ERROR - -=back - -=head2 CDPlayTracks(cd,track,tracks,frame,frames) - -To start playing from an arbitrary portion of a CD, one can provide -C with a CD, a starting track, the number of tracks, -a starting frame, and the number of frames to be played. - -=head2 CDPlay(cd,track,length) - -C plays the next C tracks starting from C - -=head2 CDPause(cd) - -This function will pause CD playback until resume is called. - -=head2 CDResume(cd) - -This function will resume CD playback if paused. - -=head2 CDStop(cd) - -C will stop CD playback if playing. - -=head2 CDEject(cd) - -This function will eject the CD - -=head2 CDClose(cd) - -This function will release an opened CD. - -=head2 CDNumTracks - -=head2 CDCurTrack - -=head2 CDCurFrame - -=head2 CDTrack - -=head2 PumpEvents - -=head2 NewEvent - -=head2 FreeEvent - -=head2 PollEvent - -=head2 WaitEvent - -=head2 EventState - -=head2 IGNORE - -=head2 ENABLE - -=head2 QUERY - -=head2 ACTIVEEVENT - -=head2 KEYDOWN - -=head2 KEYUP - -=head2 MOUSEMOTION - -=head2 MOUSEBUTTONDOWN - -=head2 MOUSEBUTTONUP - -=head2 QUIT - -=head2 SYSWMEVENT - -=head2 EventType - -=head2 ActiveEventGain - -=head2 ActiveEventState - -=head2 APPMOUSEFOCUS - -=head2 APPINPUTFOCUS - -=head2 APPACTIVE - -=head2 KeyEventState - -=head2 SDLK_BACKSPACE - -=head2 SDLK_TAB - -=head2 SDLK_CLEAR - -=head2 SDLK_RETURN - -=head2 SDLK_PAUSE - -=head2 SDLK_ESCAPE - -=head2 SDLK_SPACE - -=head2 SDLK_EXCLAIM - -=head2 SDLK_QUOTEDBL - -=head2 SDLK_HASH - -=head2 SDLK_DOLLAR - -=head2 SDLK_AMPERSAND - -=head2 SDLK_QUOTE - -=head2 SDLK_LEFTPAREN - -=head2 SDLK_RIGHTPAREN - -=head2 SDLK_ASTERISK - -=head2 SDLK_PLUS - -=head2 SDLK_COMMA - -=head2 SDLK_MINUS - -=head2 SDLK_PERIOD - -=head2 SDLK_SLASH - -=head2 SDLK_0 - -=head2 SDLK_1 - -=head2 SDLK_2 - -=head2 SDLK_3 - -=head2 SDLK_4 - -=head2 SDLK_5 - -=head2 SDLK_6 - -=head2 SDLK_7 - -=head2 SDLK_8 - -=head2 SDLK_9 - -=head2 SDLK_COLON - -=head2 SDLK_SEMICOLON - -=head2 SDLK_LESS - -=head2 SDLK_EQUALS - -=head2 SDLK_GREATER - -=head2 SDLK_QUESTION - -=head2 SDLK_AT - -=head2 SDLK_LEFTBRACKET - -=head2 SDLK_BACKSLASH - -=head2 SDLK_RIGHTBRACKET - -=head2 SDLK_CARET - -=head2 SDLK_UNDERSCORE - -=head2 SDLK_BACKQUOTE - -=head2 SDLK_a - -=head2 SDLK_b - -=head2 SDLK_c - -=head2 SDLK_d - -=head2 SDLK_e - -=head2 SDLK_f - -=head2 SDLK_g - -=head2 SDLK_h - -=head2 SDLK_i - -=head2 SDLK_j - -=head2 SDLK_k - -=head2 SDLK_l - -=head2 SDLK_m - -=head2 SDLK_n - -=head2 SDLK_o - -=head2 SDLK_p - -=head2 SDLK_q - -=head2 SDLK_r - -=head2 SDLK_s - -=head2 SDLK_t - -=head2 SDLK_u - -=head2 SDLK_v - -=head2 SDLK_w - -=head2 SDLK_x - -=head2 SDLK_y - -=head2 SDLK_z - -=head2 SDLK_DELETE - -=head2 SDLK_KP0 - -=head2 SDLK_KP1 - -=head2 SDLK_KP2 - -=head2 SDLK_KP3 - -=head2 SDLK_KP4 - -=head2 SDLK_KP5 - -=head2 SDLK_KP6 - -=head2 SDLK_KP7 - -=head2 SDLK_KP8 - -=head2 SDLK_KP9 - -=head2 SDLK_KP_PERIOD - -=head2 SDLK_KP_DIVIDE - -=head2 SDLK_KP_MULTIPLY - -=head2 SDLK_KP_MINUS - -=head2 SDLK_KP_PLUS - -=head2 SDLK_KP_ENTER - -=head2 SDLK_KP_EQUALS - -=head2 SDLK_UP - -=head2 SDLK_DOWN - -=head2 SDLK_RIGHT - -=head2 SDLK_LEFT - -=head2 SDLK_INSERT - -=head2 SDLK_HOME - -=head2 SDLK_END - -=head2 SDLK_PAGEUP - -=head2 SDLK_PAGEDOWN - -=head2 SDLK_F1 - -=head2 SDLK_F2 - -=head2 SDLK_F3 - -=head2 SDLK_F4 - -=head2 SDLK_F5 - -=head2 SDLK_F6 - -=head2 SDLK_F7 - -=head2 SDLK_F8 - -=head2 SDLK_F9 - -=head2 SDLK_F10 - -=head2 SDLK_F11 - -=head2 SDLK_F12 - -=head2 SDLK_F13 - -=head2 SDLK_F14 - -=head2 SDLK_F15 +INIT_NOPARACHUTE -=head2 SDLK_NUMLOCK - -=head2 SDLK_CAPSLOCK - -=head2 SDLK_SCROLLOCK - -=head2 SDLK_RSHIFT - -=head2 SDLK_LSHIFT - -=head2 SDLK_RCTRL - -=head2 SDLK_LCTRL - -=head2 SDLK_RALT - -=head2 SDLK_LALT - -=head2 SDLK_RMETA - -=head2 SDLK_LMETA - -=head2 SDLK_LSUPER - -=head2 SDLK_RSUPER - -=head2 SDLK_MODE - -=head2 SDLK_HELP - -=head2 SDLK_PRINT - -=head2 SDLK_SYSREQ - -=head2 SDLK_BREAK - -=head2 SDLK_MENU - -=head2 SDLK_POWER - -=head2 SDLK_EURO - -=head2 KMOD_NONE - -=head2 KMOD_NUM - -=head2 KMOD_CAPS - -=head2 KMOD_LCTRL - -=head2 KMOD_RCTRL - -=head2 KMOD_RSHIFT - -=head2 KMOD_LSHIFT - -=head2 KMOD_RALT - -=head2 KMOD_LALT - -=head2 KMOD_CTRL - -=head2 KMOD_SHIFT - -=head2 KMOD_ALT - -=head2 KeyEventSym - -=head2 KeyEventMod - -=head2 KeyEventUnicode - -=head2 KeyEventScanCode - -=head2 MouseMotionState - -=head2 MouseMotionX - -=head2 MouseMotionY - -=head2 MouseMotionXrel - -=head2 MouseMotionYrel - -=head2 MouseButtonState - -=head2 MouseButton - -=head2 MouseButtonX - -=head2 MouseButtonY - -=head2 SysWMEventMsg - -=head2 EnableUnicode - -=head2 EnableKeyRepeat - -=head2 GetKeyName - -=head2 PRESSED - -=head2 RELEASED - -=head2 CreateRGBSurface - -=head2 CreateRGBSurfaceFrom - -=head2 IMG_Load - -=head2 FreeSurface - -=head2 SurfacePalette - -=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 +=item * +INIT_JOYSTICK -=head2 MixPaused +=item * +INIT_TIMER -=head2 MixPauseMusic +=back -=head2 MixResumeMusic +C returns 0 on success, or -1 on error. -=head2 MixRewindMusic +=head2 init_subsystem(flags) -=head2 MixPausedMusic +After SDL has been initialized with SDL::init you may initialize uninitialized subsystems with SDL::init_subsystem. +The flags parameter is the same as that used in SDL::init. -=head2 MixPlaying +SDL::init_subsystem returns 0 on success, or -1 on error. -=head2 MixPlayingMusic +=head2 quit_subsystem(flags) -=head2 MixCloseAudio +SDL::quit_subsystem allows you to shut down a subsystem that has been previously initialized by SDL::init or SDL::init_subsystem. +The flags tells SDL::quit_subSystem which subsystems to shut down, it uses the same values that are passed to SDL::init. -=head2 NewFont +SDL::quit_subsystem doesn't returns any value. -=head2 UseFont +=head2 quit -=head2 PutString +Shuts down all SDL subsystems, unloads the dynamically linked library and frees the allocated resources. This should always be called before you exit. -=head2 TextWidth +SDL::quit doesn't returns any value. -=head2 GL_RED_SIZE +=head2 was_init(flags) -=head2 GL_GREEN_SIZE +SDL::was_init allows you to see which SDL subsytems have been initialized. +flags is a bitwise OR'd combination of the subsystems you wish to check (see SDL::init for a list of subsystem flags). +If 'flags' is 0 or SDL_INIT_EVERYTHING, it returns a mask of all initialized subsystems (this does not include SDL_INIT_EVENTTHREAD or SDL_INIT_NOPARACHUTE). -=head2 GL_BLUE_SIZE -=head2 GL_ALPHA_SIZE +=head2 get_error() -=head2 GL_ACCUM_RED_SIZE +The last error message set by the SDL library can be retrieved using the subroutine +C, which returns a scalar containing the text of the message if any. -=head2 GL_ACCUM_GREEN_SIZE +=head2 set_error(error) *need to be coded -=head2 GL_ACCUM_BLUE_SIZE +SDL::get_error sets the SDL error to a printf style formatted string. +it doesn't returns any values. -=head2 GL_ACCUM_ALPHA_SIZE +=head2 error(code) * need to be coded -=head2 GL_BUFFER_SIZE +Sets the SDL error message to one of several predefined strings specified by code. -=head2 GL_DEPTH_SIZE +code can be : -=head2 GL_STENCIL_SIZE +=over 4 -=head2 GL_DOUBLEBUFFER + SDL_errorcode The corresponding error string -=head2 GL_SetAttribute + SDL_ENOMEM Out of memory + SDL_EFREAD Error reading from datastream + SDL_EFWRITE Error writing to datastream + SDL_EFSEEK Error seeking in datastream + SDL_UNSUPPORTED Unknown SDL error + SDL_LASTERROR Unknown SDL error + any other value Unknown SDL error -=head2 GL_GetAttribute -=head2 GL_SwapBuffers + Note 1: SDL_LASTERROR marks the highest numbered predefined error. + Note 2: SDL also defines SDL_OutOfMemory() and SDL_Unsupported() for internal use + which are equivalent to SDL_Error(SDL_ENOMEM) and SDL_Error(SDL_UNSUPPORTED) respectively. -=head2 BigEndian +=back -=head2 NumJoysticks +SDL::Error doesn't returns any value. -=head2 JoystickName -=head2 JoystickOpen +=head2 clear_error() * need to be coded -=head2 JoystickOpened +SDL::clear_error deletes all information about the last internal SDL error. Useful if the error has been handled by the program. +it doesn't returns any value. -=head2 JoystickIndex +=head2 load_object() -=head2 JoystickNumAxes +Need to be coded. -=head2 JoystickNumBalls +=head2 load_function() -=head2 JoystickNumHats +Need to be coded. -=head2 JoystickNumButtons +=head2 unload_object() -=head2 JoystickUpdate +Need to be coded. -=head2 JoystickGetAxis +=head2 VERSION() -=head2 JoystickGetHat +Need to be coded. -=head2 JoystickGetButton +=head2 version() -=head2 JoystickGetBall +Need to be coded. -=head2 JoystickClose +=head2 linked_version -=head1 AUTHOR +Need to be coded. -David J. Goehrig +=head2 get_error() -=head1 CONTRIBUTORS +The last error message set by the SDL library can be retrieved using the subroutine +C, which returns a scalar containing the text of the message if any. -David J. Goehrig, Wayne Keenan, Guillaume Cottenceau +=head2 delay(ms) -=head1 SEE ALSO +This subroutine allows an application to delay further operations for atleast a +number of milliseconds provided as the argument. The actual delay may be longer +than the specified depending on the underlying OS. - perl(1) SDL::App(3) SDL::Surface(3) SDL::Event(3) SDL::Rect(3) - SDL::Palette(3) SDL::Mixer(3) SDL::Cdrom(3) -=cut