Perl bindings

From Agar

(Redirected from Perl)
Jump to: navigation, search

Agar provides bindings to the Perl language. Agar's Perl bindings follow the object-oriented approach and are implemented using the XS mechanism.

Installing p5-Agar

The Perl bindings are located under the p5-Agar/ directory in the Agar source tree. The module is compiled in the standard manner:

$ perl Makefile.PL
$ make
$ make test
# make install

Using Agar from Perl

A minimal Agar perl application would look like:

use strict;
use warnings;
use Agar;
 
Agar::InitCore('myapp', { verbose >= 1 });
Agar::InitVideo(320, 240, 32, { resizable => 1 });
 
my $win = Agar::Window->new();
$win->caption("Hello Perl! ($0)");
$win->show();
Agar::EventLoop();

Agar can work with existing applications using the SDL module:

use strict;
use warnings;
use Agar; # use before "use SDL"
use SDL::App;
use SDL::Event;
use SDL::Constants;
 
my $sdlApp = new SDL::App (-w => 800, -h => 600, -d => 32,
                           -title => 'Hello World!');
 
Agar::InitCore('myapp', { verbose => 1 });
Agar::InitVideoSDL($sdlApp);
 
my $win = Agar::Window->new();
$win->caption("Hello Perl! ($0)");
$win->show();
 
Agar::EventLoop();

See 'p5-Agar/agardemo.pl' for a more extensive demo application.

Using the API reference

The Agar Perl bindings are documented in the installed manual pages, which are named after the Agar manual pages. The main manual page is named Agar(3). The Agar::Window(3) manual page corresponds to the Perl bindings for AG_Window(3) and so on.

The p5-Agar manual pages briefly describe the Perl API and should be used along Agar's more detailed C API reference.

This section was marked as being a stub. You are welcome to help expand it.

Personal tools