SDL_perl - Simple DirectMedia Layer for Perl
First to clarify:
THIS IS THE LAST RELEASE OF THIS API.
That said we are actively redesigning the SDL Bindings on the redesign branch here:
The newrelease will break backwards compatibility. We recommend you try the redesign branch to get a head start on any new code you are developing.
SDL_perl is a package of perl modules that provides both functional and object orient interfaces to the Simple DirectMedia Layer for Perl 5. This package does take some liberties with the SDL API, and attempts to adhere to the spirit of both the SDL and Perl. This document describes the low-level functional SDL_perl API. For the object oriented programming interface please see the documentation provided on a per class basis.
Nick: Garu Name: Breno G. de Oliveira Nick: Dngor Name: Rocco Caputo Nick: nferraz Name: Nelson Ferraz
Nick: kthakore Name: Kartik Thakore
Please get libsdl packages from Fink
perl Build.PL perl Build test perl Build bundle perl Build install
First set the PERL5LIB environment variable to the dependencies of your script
Use the SDLPerl executable made in the bundle and call your scripts
As with the C language API, SDL_perl initializes the SDL environment through the
SDL::Init subroutine. This routine takes a mode flag constructed through the bitwise OR product of the following functions:
SDL::Init returns 0 on success, or -1 on error.
The last error message set by the SDL library can be retrieved using the subroutine
SDL::GetError, which returns a scalar containing the text of the message if any.
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.
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.
AddTimer will register a SDL_NewTimerCallback function to be executed after
interval milliseconds, with parameter
param. SDL_NewTimerCallback objects can be constructed with the
SDL::PerlTimerCallback 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.
NewTimer 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
NewTimer returns the SDL_TimerID for the new timer or NULL on error.
This subroutine taks a SDL_TimerID and removes it from the list of active callbacks. RemoveTimer returns false on failure.
This subroutine is depreciated, please use
SDL::CDNumDrives returns the number of available CD-ROM drives in the system.
SDL::CDName returns the system specific human readable device name for the given CD-ROM 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.
SDL::CDTrackListing returns a human readable description of a CD-ROM. For each track one line will be produced with the following format:
Track index: %d, id %d, %2d.%2d
This is provided to ease the creation of human readable descriptions and debugging.
CDTrackId returns the id field of the given SDL_CDtrack structure.
CDTrackType returns the type field of the given SDL_CDtrack structure.
CDTrackLength returns the length field of the given SDL_CDtrack structure.
CDTrackOffset returns the offset field of the given SDL_CDtrack structure.
CDStatus returns the current status of the given SDL_CDrom.
CDStatus's return values are:
To start playing from an arbitrary portion of a CD, one can provide
SDL::CDPlayTracks with a CD, a starting track, the number of tracks, a starting frame, and the number of frames to be played.
SDL::CDPlay plays the next
length tracks starting from
This function will pause CD playback until resume is called.
This function will resume CD playback if paused.
SDL::CDStop will stop CD playback if playing.
This function will eject the CD.
This function will release an opened CD.
This function return the number of tracks on a CD, it take a SDL_CD as first parameter.
This function return the number of the current track on a CD, it take a SDL_CD as first parameter.
this function return the frame offset within the current track on a CD. it take a SDL_CD as first parameter.
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.
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 " PollEvent" 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.
Create a new event.It return a SDL::Event.
FreeEvent delete the SDL::Event given as first parameter. it doesn't return anything.
Polls for currently pending events. If event is not undef, the next event is removed from the queue and returned as a " SDL::Event". As this function implicitly calls " PumpEvents", you can only call this function in the thread that set the video mode. it take a SDL::Event as first parameter.
Waits indefinitely for the next available event, returning undef if there was an error while waiting for events, a " SDL::Event" otherwise. If event is not NULL, the next event is removed. As this function implicitly calls " PumpEvents", you can only call this function in the thread that set the video mode. WaitEvent take a SDL::Event as first parameter.
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 " SDL_Event section".
it returns a state(?).
EventType return the type of the SDL::Event given as first parameter.
ActiveEventGain return the active gain from the SDL::Event given as first parameter. see " SDL::Event" for more informations about the active state.
ActiveEventState return the active state from the SDL::Event given as first parameter. see " SDL::Event" for more informations about the active state.
KeyEventState return the active key state from the SDL::Event given as first parameter. see " SDL::Event" for me more informations about the active key.
KeyEventSym return the key pressed/released information from the SDL::Event given as first parameter. see " SDL::Event" for more informations about the keyboard events.
KeyEventMod return the mod keys pressed information from the SDL::Event given as first parameter. see " SDL::Event" for more informations about the keyboard events.
KeyEventMod return the unicode translated keys pressed/released information from the SDL::Event given as first parameter. see " SDL::Event" for more informations about the keyboard events.