Allegro Perl Module. This is a module to access the Allegro library from Perl.

Dec 19 2003

The source release for 0.02 is available here.

Dec 18 2003

I've uploaded a PPM for ActivePerl 5.6 and 5.8 to CPAN, which should be available whenever the mirrors update (I have no idea how long this will take).

ppm> install http://alperl.mx3.org/Allegro.ppd

If ppm complains that it can't find it, give it a few hours. If it does download and doesn't work, send me an email.

Nov 20 2003

Yes, I am alive. Here's a new snapshot. I will have an "official" release soon, pending some documentation fixes and a little bit more testing. Everything should work except timers.

Allegro-0.01-snapshot.tar.gz (Browse | Docs)

Things are mostly complete now, and I've stopped breaking the API. There's both a procedural interface and an object oriented interface available now. The procedural interface is mostly wrappers around Allegro functions and defines, with the addition of some helper functions to access Allegro structs from Perl. The object interface is a more Perl-friendly (read: won't segfault if you screw up) way to use the library. There's documentation in the included pods.

Synopsis from Allegro.pod:

   use Allegro;

   # Create Allegro object
   $al = Allegro->new() or die "Couldn't initialize Allegro";

   # Create Display object (screen)
   $disp = $al->Display(width => 640, height => 480)
      or die "Couldn't set graphics mode " . $al->error;

   for $file (@ARGV)
   {
      # Load image into bitmap
      $bmp = $disp->Bitmap(file => $file)
         or die "Couldn't load $file";

      # Clear display bitmap
      $disp->clear();

      # Copy image bitmap to display
      $disp->blit($bmp);

      sleep 10;
   }

You can also do it in a more C-like manner:

   use Allegro ':all';

   al_allegro_init();
   al_set_color_depth(24);

   if(al_set_gfx_mode(GFX_AUTODETECT_WINDOWED(), 640, 480, 0, 0) < 0) {
      die al_get_error();
   }

   $screen = al_get_screen();

   for $file (@ARGV)
   {
      # Load image into bitmap
      $bmp = al_load_bitmap($file, AL_NULL_PALETTE());

      # Clear display bitmap
      al_clear_bitmap($screen);

      ($w, $h) = al_get_bitmap_size($bmp);

      # Copy image bitmap to display
      al_blit($bmp, $screen, 0, 0, 0, 0, $w, $h);

      sleep 10;
   }

A Windows distribution (a compiled .ppm for ActiveState and a self-installing Perl distribution including Allegro and PAR) will be ready soon.

-- Colin