Just a quick heads-up

I’m working on a set of Perl bindings for the SDL library. Any thoughts as to
features you’d like to see would be appreciated.

I’m working on a set of Perl bindings for the SDL library. Any thoughts as to
features you’d like to see would be appreciated.

I was thinking of doing some python support (one day 8) - isn’t python a
far better choice for integration with SDL than perl? I don’t want to enter
a languade war, bit perl is optimised for text processing, python by it’s
very nature is extensible and (I believe) quicker.

NeilOn Wed, 17 Nov 1999, Jeff Goff wrote:

Neil McGill mailto:Neil_McGill *8^) . .
Software Developer:ISDN, Cisco Systems Ltd ~~""~""~"~"|~"~
3rd Floor, 96 Commercial Street, Edinburgh, EH6 6LX, UK ||| |||
Tel: 0131 561 3622 Fax: 0131 561 3601 Mob: 07714 226 281 .:|||||:.:|||||:.

shrug

There’s no problem making a Python module too.

While I’m not quite sure what you’d do with an SDL perl module, it’s not going
to hurt anything.On Thu, Nov 18, 1999 at 09:25:53AM +0000, Neil McGill wrote:

On Wed, 17 Nov 1999, Jeff Goff wrote:

I’m working on a set of Perl bindings for the SDL library. Any thoughts as to
features you’d like to see would be appreciated.

I was thinking of doing some python support (one day 8) - isn’t python a
far better choice for integration with SDL than perl? I don’t want to enter
a languade war, bit perl is optimised for text processing, python by it’s
very nature is extensible and (I believe) quicker.

I was thinking of doing some python support (one day 8) - isn’t python a
far better choice for integration with SDL than perl? I don’t want to enter
a languade war, bit perl is optimised for text processing, python by it’s
very nature is extensible and (I believe) quicker.

If I’m not mistaken he was saying he is making some Perl code to be able
to call SDL, not integrating a Perl interpreter into SDL itself. It’s
kind of like the Perl/Tk and Perl/Gtk bindings…just gives the Perl
programmer the ability to add a graphical front end to a scripting
language.

As for which is quicker, unless I am mistaken both languages take the same
approach to running code. They do it like Java.

1)  Compile the script into formalized bytecode.
2)  Run the bytecode through a bytecode interpreter.

Paul Braman
@Paul_BramanOn Thu, 18 Nov 1999, Neil McGill wrote:

While I’m not quite sure what you’d do with an SDL perl module, it’s not going
to hurt anything.

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

NeilOn Thu, 18 Nov 1999, Michael Samuel wrote:

On Wed, 17 Nov 1999, Jeff Goff wrote:

Neil McGill mailto:Neil_McGill *8^) . .
Software Developer:ISDN, Cisco Systems Ltd ~~""~""~"~"|~"~
3rd Floor, 96 Commercial Street, Edinburgh, EH6 6LX, UK ||| |||
Tel: 0131 561 3622 Fax: 0131 561 3601 Mob: 07714 226 281 .:|||||:.:|||||:.

Neil McGill wrote:

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

Well… if you’re considering embedding a script engine into SDL then maybe you should consider using lua
(http://www.tecgraf.puc-rio.br/lua/). There’s a link to projects that have used it (i.e. Baldur’s Gate, Grim Fandango,
MDK2,etc).–
Best regards,

            Jeroen Janssen

+++
It is the fate of all banisters worth sliding down that there is something
nasty waiting at the far end.
– (Terry Pratchett, Maskerade)
+++

Jeff Goff writes:

I’m working on a set of Perl bindings for the SDL library. Any
thoughts as to
features you’d like to see would be appreciated.

I would definitely like to see Perl bindings. It would be very cool
if they were nicely object oriented; I think better that way.
i.e. with a sub new(), and using @ISA, etc.–
Colin Walters <@Colin_Walters>
http://web.verbum.org/levanti
(1024D/C207843A) A580 5AA1 0887 2032 7EFB 19F4 9776 6282 C207 843A

Neil McGill wrote:

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

Well… if you’re considering embedding a script engine into SDL then maybe you should consider using lua
(http://www.tecgraf.puc-rio.br/lua/). There’s a link to projects that have used it (i.e. Baldur’s Gate, Grim Fandango,
MDK2,etc).

Yeah, but the advantage of python/perl is that a lot of folk are already used to
those languages. I also think that for Grim Fandango, they had to modify the
language too.

(I’m not critisizing lua, but if you want to get other people to write
script plug-ins for a game, best to use a well known language. Is lua
mainstream yet?)

NeilOn Thu, 18 Nov 1999, Jeroen Janssen wrote:

Neil McGill mailto:Neil_McGill *8^) . .
Software Developer:ISDN, Cisco Systems Ltd ~~""~""~"~"|~"~
3rd Floor, 96 Commercial Street, Edinburgh, EH6 6LX, UK ||| |||
Tel: 0131 561 3622 Fax: 0131 561 3601 Mob: 07714 226 281 .:|||||:.:|||||:.

Neil McGill wrote:

Yeah, but the advantage of python/perl is that a lot of folk are already used to
those languages.

ok, but you should also consider other things then ‘already used to’ something :slight_smile:
(don’t know if python or perl is being used in games?)

I also think that for Grim Fandango, they had to modify the
language too.

yep, they added native lua task(-script)s for their cooperative multitasking system (to create a similar environment
like SCUMM) + they added scrambling + streaming of lua compiled bytecodes I think.

(I’m not critisizing lua, but if you want to get other people to write
script plug-ins for a game, best to use a well known language. Is lua
mainstream yet?)

Well… I can’t judge if it’s “mainstream”, maybe it’s possible to create a python/perl/lua bridge and people that write
plugins can decide what language they want to use (it’s probably best not to “force” something to be used, but leave the
choice to the user).> On Thu, 18 Nov 1999, Jeroen Janssen wrote:


Best regards,

            Jeroen Janssen

+++
It is the fate of all banisters worth sliding down that there is something
nasty waiting at the far end.
– (Terry Pratchett, Maskerade)
+++

This is exactly why more games should use lua, so that eventually it will
become mainstream. Lua is also easily extesible, written in ANSI C
(hmm, I sound like a plug), and compiles to bytecodes. For that matter,
what kind of arguments could be given for any of the languages debated
(perl, python, lua). They all are portable, fast, and embeddable in C …
isn’t it just preference on which one to use? The learning curve (I would
think) wouldn’t be any more difficult for any of the three.

MarcusOn Thu, 18 Nov 1999, Neil McGill wrote:

On Thu, 18 Nov 1999, Jeroen Janssen wrote:

Neil McGill wrote:

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

Well… if you’re considering embedding a script engine into SDL then maybe you should consider using lua
(http://www.tecgraf.puc-rio.br/lua/). There’s a link to projects that have used it (i.e. Baldur’s Gate, Grim Fandango,
MDK2,etc).

Yeah, but the advantage of python/perl is that a lot of folk are already used to
those languages. I also think that for Grim Fandango, they had to modify the
language too.

(I’m not critisizing lua, but if you want to get other people to write
script plug-ins for a game, best to use a well known language. Is lua
mainstream yet?)

Neil

Neil McGill wrote:

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

Well… if you’re considering embedding a script engine into SDL then maybe you should consider using lua
(http://www.tecgraf.puc-rio.br/lua/). There’s a link to projects that have used it (i.e. Baldur’s Gate, Grim Fandango,
MDK2,etc).

I started using SWIG to write bindings (swig will make a perl, tcl, python
and guile as well as your own defined wapper)
If anyone is intrested in helping what I have so far is at:
http://www.cs.umn.edu/~mein/game/SDL_swig
There are three files currently:
Makefile
package.i swig definition file
test.pl Perl testfile
test.tcl Same testfile written in tcl

swig can be found at: http://www.cs.utah.edu/~beazley/SWIG/swig.html

Right now I’m trying to figure out how to use constants like
SDL_INIT_EVERYTHING inside of a script. The docs say it gets converted to
a variable but it doesn’t look like thats quite right when I try it in
the code.

Kent Mein
@Kent_Mein

Jeroen Janssen wrote:

Neil McGill wrote:

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

Well… if you’re considering embedding a script engine into SDL then maybe you should consider using lua
(http://www.tecgraf.puc-rio.br/lua/). There’s a link to projects that have used it (i.e. Baldur’s Gate, Grim Fandango,
MDK2,etc).

Not including a script engine, simply creating a module in the spirit of Perl/Tk which will let you allocate a video
surface and display on that surface. Below is some sample Perl code, with additional commentary.

–cut–#

Initialize the library, and pass in the SDL::INIT_VIDEO constant.

if (SDL::Init(SDL::INIT_VIDEO) < 0) {
print “not ok 2\n”;
print STDERR "Internal Error: " . SDL::GetError() . “\n”;
exit;
}
print “ok 2\n”;

my ($wid,$hgt) = (640,480);

my $surface = SDL::SetVideoMode($wid,$hgt,16,SDL::HWSURFACE);
my $format = Surface::PixelFormat($surface);
my $bytespp = Surface::BytesPerPixel($format);
my $bitspp = Surface::BitsPerPixel($format);

SDL::LockSurface($surface);

JMG Surface::WritePixel is a port of the DisplayPixel() function in the sample source.

Surface::WritePixel($surface, 255,0,0, 1,1);

JMG Surface::ReadPixel is the inverse of WritePixel

print Surface::ReadPixel($surface,1,1); print “\n”;
SDL::UpdateRect($surface,0,0,$wid,$hgt);

my $image = SDL::LoadBMP(’/dosc/windows/Circles.bmp’) or
die "Couldn’t load $file: " . SDL::GetError() . “\n”;
my $image2 = SDL::LoadBMP(’/dosc/windows/Clouds.bmp’) or
die "Couldn’t load $file: " . SDL::GetError() . “\n”;
my $cp = SDL::LoadBMP(‘terran.bmp’) or
die "Couldn’t load terran.bmp: " . SDL::GetError() . “\n”;

for(0…20) {
Surface::BlitSurfaces($image,$surface,0,0);
SDL::UpdateRect($surface,0,0,$wid,$hgt);
Surface::BlitSurfaces($image2,$surface,0,0);
SDL::UpdateRect($surface,0,0,$wid,$hgt);
}

Surface::BlitSurfaces($cp,$surface,0,300);
SDL::UpdateRect($surface,0,0,$wid,$hgt);

SDL::UnlockSurface($surface);

sleep 2;

SDL::Quit();
–cut–

This code works, and displays pixels and bitmaps on the screen.
I chose Perl simply because of my familiarity with the language, and the fact that bindings already exist for graphics
toolkits such as ImageMagick, Tk, Gtk, and Qt.

I have no illusions about making this library into a competitor for Quake 3, but I think it will be fast enough for
simple 2-D games, given the fact that once the code is compiled it should run close to the same speed as compiled C. I’m
not trying to get into a language war here, though.

This is a primitive example, with many refinements yet to come, as my comments indicate. Below is a sample of the code
I hope we can eventually use.

–cut–
use SDL;

Initialize the library, and pass in the SDL::INIT_VIDEO constant.

if (Init(INIT_VIDEO) < 0) {
print “not ok 2\n”;
print STDERR "Internal Error: " . GetError() . “\n”;
exit;
}
print “ok 2\n”;

my ($wid,$hgt) = (640,480);

my $surface = new SDL::Surface($wid,$hgt,16,HWSURFACE); # Retaining the SDL root to allow for SDL::Audio, et al.
my $format = $surface->PixelFormat();
my $bytespp = $format->BytesPerPixel();
my $bitspp = $format->BitsPerPixel();

$surface->Lock();

JMG Surface::WritePixel is a port of the DisplayPixel() function in the sample source.

$surface->WritePixel(255,0,0,1,1);

JMG Surface::ReadPixel is the inverse of WritePixel

print $surface->ReadPixel(1,1); print “\n”;
$surface->UpdateRect(0,0,$wid,$hgt);

my $image = LoadBMP(’/dosc/windows/Circles.bmp’) or
die "Couldn’t load $file: " . GetError() . “\n”;
my $image2 = LoadBMP(’/dosc/windows/Clouds.bmp’) or
die "Couldn’t load $file: " . GetError() . “\n”;
my $cp = LoadBMP(‘terran.bmp’) or
die "Couldn’t load terran.bmp: " . GetError() . “\n”;

for(0…20) {
$surface->Blit($image,0,0);
$surface->UpdateRect(0,0,$wid,$hgt);
$surface->Blit($image2,0,0);
$surface->UpdateRect(0,0,$wid,$hgt);
}

$surface->Blit($cp,0,300);
$surface->UpdateRect(0,0,$wid,$hgt);

$surface->Unlock();

sleep 2;

Quit();
–cut–

Jeff Goff <@Jeff_Goff>

Paul Braman wrote:

As for which is quicker, unless I am mistaken both languages take the same
approach to running code. They do it like Java.

    1)  Compile the script into formalized bytecode.
    2)  Run the bytecode through a bytecode interpreter.

Mmm… I’d say there are radical differences between Java’s and Perl’s
bytecodes.

Java Virtual Machine is just that, a virtual machine, with its bytecode
expressed as a stream of opcodes, much like actual binary code for Intel
or other “non-virtual” processors.

The perl executor on the other hand stores the program as a tree of
operator nodes, which knows a lot about itself and about how it is going
to be used. The operator nodes are also of a much higher level than the
JVM opcodes, as they were never meant to be “opcodes” for a real
machine.

For example, the whole of the ‘grep’ function (quite complex) in Perl is
a single operator node in the executor, which is implemented in fast
native C code. A similar function would have to be implemented with a
large number of opcodes on the JVM, with a proportional performance
loss. Thanks to this architecture, the perl interpreter is faster than
even most JIT JVMs, without any JIT done (actually, you could consider
it cheating, since a lot of stuff is already natively compiled from C
code, like the ‘grep’ function)…

Perl 5.005 is the first version to have a file-based format for its
bytecode, before that it was a memory-only thing, because of it being a
complex structure instead of a simple stream of data as Java bytecode.

I do not know what architecture the Python interpreter has.–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
“First they ignore you. Then they laugh at you.
Then they fight you. Then you win.” – Gandhi

Neil McGill wrote:

I’m working on a set of Perl bindings for the SDL library. Any thoughts as > > to features you’d like to see would be appreciated.

I was thinking of doing some python support (one day 8) - isn’t python a
far better choice for integration with SDL than perl? I don’t want to enter
a languade war, bit perl is optimised for text processing, python by it’s
very nature is extensible and (I believe) quicker.

I think Python is a very nice language (except for its indented-blocks
thing which makes me go crazy!), and making Python bindings should be
easy once other bindings (like Perl) are made.

But Perl has one big advantage as I see it, and it isn’t one of
language: Perl hackers are literally RAINING! Python I know a bit and I
know some Python hackers, lua I only barely heard of a few times, don’t
even know how it looks like, but if I scream “WHO KNOWS PERL
PROGRAMMING?” on a crowded downtown street, I’m pretty sure I’d get some
people… :wink:

And BTW, about the text processing thing: it is true that perl is
optimized for that, but it is optimized for a lot of things beside that.
It isn’t a “language optimized for text processing” anymore, it is more
of an “optimized language”. :-)–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
“First they ignore you. Then they laugh at you.
Then they fight you. Then you win.” – Gandhi

Kent B Mein wrote:

I started using SWIG to write bindings (swig will make a perl, tcl, python
and guile as well as your own defined wapper)
If anyone is intrested in helping what I have so far is at:
http://www.cs.umn.edu/~mein/game/SDL_swig

Well, there we go! SWIG is very cool by the way! If the interface file
is properly done, there’s going to be a whole lotta bindings for SDL
when it works!–
Pierre Phaneuf
Ludus Design, http://ludusdesign.com/
“First they ignore you. Then they laugh at you.
Then they fight you. Then you win.” – Gandhi

Paul Braman wrote:

As for which is quicker, unless I am mistaken both languages take the same
approach to running code. They do it like Java.

Mmm… I’d say there are radical differences between Java’s and Perl’s
bytecodes.

I was providing a very simplistic overview of how it was done. :slight_smile:

Still, thanks for the detailed heads up.

Paul Braman
@Paul_BramanOn Thu, 18 Nov 1999, Pierre Phaneuf wrote:

swig can be found at: http://www.cs.utah.edu/~beazley/SWIG/swig.html

and http://www.swig.org too,ummm…i think i have a question here,would it
be possible to use swig inside autoconf,automake (does sdl use it,it’s been
some time i downloaded it and i got a new 10.X gig drive this week) and
./configure ??

it would be nice to add a —with-swig=yes to configure and redo the
makefile according to that !!!

Alain “happy man” Toussaint

Jeroen Janssen wrote:

Neil McGill wrote:

That was my thought. It would be interesting, but probably be of more use as
Python. Python is fairly commonly embedded into games. I’ve not heard of
any Perl enabled games yet - though I could be wrong 8)

Well… if you’re considering embedding a script engine into SDL then maybe you should consider using lua
(http://www.tecgraf.puc-rio.br/lua/). There’s a link to projects that have used it (i.e. Baldur’s Gate, Grim Fandango,
MDK2,etc).

Tried this. Unfortunately, it’s too Pascal-ish for my taste. I’m in
the process of writing an embedded script language right now, and have
gotten a small byte compiler out the door and am in the process of
writing a virtual machine. It’s sort of like Lisp/Scheme with a more
C-like syntax. Current progress is at
http://www.dilnet.upd.edu.ph/~mobotlab/starlang.html. Watch out; this
site may be slow loading because it’s behind a low-bandwidth line used
by one of the largest universities in Southeast Asia! Can’t even access
it quick from my local ISP.–

| Rafael R. Sevilla @Rafael_R_Sevilla |
| Instrumentation, Robotics, and Control Laboratory |

College of Engineering, University of the Philippines, Diliman

swig can be found at: http://www.cs.utah.edu/~beazley/SWIG/swig.html

and http://www.swig.org too,ummm…i think i have a question here,would it
be possible to use swig inside autoconf,automake (does sdl use it,it’s been
some time i downloaded it and i got a new 10.X gig drive this week) and
./configure ??

it would be nice to add a —with-swig=yes to configure and redo the
makefile according to that !!!

Yes. That would be the easyest way, the only problem is we need to get it
working before we integrate it into autoconfig.

Kent