From: Ignas Mikalajunas
Subject: Game development
Date: 
Message-ID: <fde4537f.0305102216.61ef2ecb@posting.google.com>
I would like to do some game programming in lisp. What libraries,
tools should I use ? Is it possible to write any decent graphic's
intensive software with lisp ? All lib's i could find were associated
with text editing or AI, but i could not find any graphic's libs like
Allegro, SDL or OpenGl related stuff.
   Ignas Mikalajunas

From: Henrik Motakef
Subject: Re: Game development
Date: 
Message-ID: <87y91eylpe.fsf@interim.henrik-motakef.de>
······@centras.lt (Ignas Mikalajunas) writes:

> I would like to do some game programming in lisp. What libraries,
> tools should I use ? Is it possible to write any decent graphic's
> intensive software with lisp ? All lib's i could find were associated
> with text editing or AI, but i could not find any graphic's libs like
> Allegro, SDL or OpenGl related stuff.

<http://www.cliki.net/CL-SDL>
<http://www.cliki.net/OpenGL%20Bindings>
From: Ignas Mikalajunas
Subject: Re: Game development
Date: 
Message-ID: <fde4537f.0305110821.2814142b@posting.google.com>
> <http://www.cliki.net/CL-SDL>
> <http://www.cliki.net/OpenGL%20Bindings>
 It surely looks promissing, but I was unable to make this thing work
:( There are no comprehensive readme files. I am really new to lisp
and i have no idea how to use CL-SDL. Yet only info i could find was
that it need's something called ASDF. I have couple of lisp
imlementations Clisp and Cmucl, but my linux distro has no default
place for lisp extensions - libraries and I just have no idea where
should I put it all the files so any of them could find it.
  Ignas Mikalajunas
From: Kenny Tilton
Subject: Re: Game development
Date: 
Message-ID: <3EBE7B31.1050208@nyc.rr.com>
Ignas Mikalajunas wrote:
>><http://www.cliki.net/CL-SDL>
>><http://www.cliki.net/OpenGL%20Bindings>
> 
>  It surely looks promissing, but I was unable to make this thing work
> :( There are no comprehensive readme files. I am really new to lisp
> and i have no idea how to use CL-SDL. Yet only info i could find was
> that it need's something called ASDF.

This one is easy: http://www.cliki.net/asdf

> I have couple of lisp
> imlementations Clisp and Cmucl, but my linux distro has no default
> place for lisp extensions - libraries and I just have no idea where
> should I put it all the files so any of them could find it.

That part I am ignorant of, but take heart, "some assembly required" is 
definitely the case. Thems that know better here will be able to help.


-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Henrik Motakef
Subject: Re: Game development
Date: 
Message-ID: <877k8xzaos.fsf@interim.henrik-motakef.de>
······@centras.lt (Ignas Mikalajunas) writes:

>> <http://www.cliki.net/CL-SDL>
>> <http://www.cliki.net/OpenGL%20Bindings>
>  It surely looks promissing, but I was unable to make this thing work
> :( There are no comprehensive readme files. I am really new to lisp
> and i have no idea how to use CL-SDL. Yet only info i could find was
> that it need's something called ASDF. I have couple of lisp
> imlementations Clisp and Cmucl, but my linux distro has no default
> place for lisp extensions - libraries and I just have no idea where
> should I put it all the files so any of them could find it.

So your Distro obviously isn't Debian :)

In fact it doesn't matter much where you put things. Just choose some
directory, say ~/lisp-libraries. For kicks, also create a directory
~/lisp-libraries/system-registry. Then get ASDF (Kenny told you how to
find it), and put it in this directory.

In your Lisp startup file (e.g. ~/cmucl-init.lisp for CMUCL), put
something like this:

(load "/home/you/lisp-libraries/asdf")
(pushnew "/home/you/lisp-libraries/system-registry/" 
         asdf:*central-registry*)

Then get all the ASDF-managed packages you want and un-tgz them, so
that you'll get ~/lisp-libraries/cl-sdl or some such, for
example. You'll likely find a *.asd file in this directory, this
should be symlinked in the system-registry, i.e.

$ cd ~/lisp-libraries/system-registry
$ ln -s ../cl-sdl/cl-sdl.asd cl-sdl.asd

Then start your Lisp, and type

(asdf:operate 'asdf:load-op :cl-sdl)

That should compile and load everything you need.

[Note that I don't use cl-sdl myself, but that's basically how you
handle ASDF packages]

hth
Henrik
From: Kenny Tilton
Subject: Re: Game development
Date: 
Message-ID: <3EBE98AC.4040201@nyc.rr.com>
Henrik Motakef wrote:
> [Note that I don't use cl-sdl myself, but that's basically how you
> handle ASDF packages]

Thx for the fill-in. To the OP, I /did/ manage to get cl-sdl up and 
running under win32, worked fine. But I needed multiple windows, so I 
moved on to FreeGlut. I gather games only use one window, so you should 
be OK.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Nikodemus Siivola
Subject: Re: Game development
Date: 
Message-ID: <b9m754$5atgr$1@midnight.cs.hut.fi>
Ignas Mikalajunas <······@centras.lt> wrote:

> imlementations Clisp and Cmucl, but my linux distro has no default
> place for lisp extensions - libraries and I just have no idea where

Everyone has their reaons for choosing a certain distro, but I would point out that
Debian is quite lisp-friendly.

Cheers,

  -- Nikodemus
From: Franz Kafka
Subject: Re: Game development
Date: 
Message-ID: <wAuva.5935$nu5.3973@news02.roc.ny.frontiernet.net>
"Henrik Motakef" <··············@web.de> wrote in message
···················@interim.henrik-motakef.de...
> ······@centras.lt (Ignas Mikalajunas) writes:
>
> > I would like to do some game programming in lisp. What libraries,
> > tools should I use ? Is it possible to write any decent graphic's
> > intensive software with lisp ? All lib's i could find were associated
> > with text editing or AI, but i could not find any graphic's libs like
> > Allegro, SDL or OpenGl related stuff.
>
> <http://www.cliki.net/CL-SDL>
> <http://www.cliki.net/OpenGL%20Bindings>

There is a Jpeg graphics Library for Common Lisp on sourceforge.net.

Abuse uses Lisp as a scripting Language but it is a rather old game. The
souce for the game is on line--it used mostly C++ source and has a Lisp
Compiler built in, don't know how good it is.

GOAL, The Game Object Assembly Lisp, is a Scheme based scripting language
used by Naughty Dog software for game development--I don't know about
availibilty.
From: Kenny Tilton
Subject: Re: Game development
Date: 
Message-ID: <3EBE76C6.3050100@nyc.rr.com>
Watch this space or the URL in my sig for news on Cello, an OpenGL-based 
GUI for (working now) ACL, LW, and (RSN) MCL and CMUCL.

Ignas Mikalajunas wrote:
> I would like to do some game programming in lisp. What libraries,
> tools should I use ? Is it possible to write any decent graphic's
> intensive software with lisp ? All lib's i could find were associated
> with text editing or AI, but i could not find any graphic's libs like
> Allegro, SDL or OpenGl related stuff.
>    Ignas Mikalajunas


-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Franz Kafka
Subject: Re: Game development
Date: 
Message-ID: <iICva.6144$B32.3752@news01.roc.ny.frontiernet.net>
Is there anyway to hook Lisp into a popular game's API:
such as Unreal, Quake, Half Life.

Or, to create a Lisp-type Gaming Language that would
compile into an other Game's scripting Language.

Thank you.
From: Christopher Browne
Subject: Re: Game development
Date: 
Message-ID: <b9n8p0$kqg5e$3@ID-125932.news.dfncis.de>
The world rejoiced as "Franz Kafka" <Symbolics _ XL1201 _ Sebek _ Budo _ Kafka @ hotmail . com> wrote:
> Is there anyway to hook Lisp into a popular game's API:
> such as Unreal, Quake, Half Life.

Only if those games provide ready way to have "hooks."  I'm not sure
those all offer any such capability, for _any_ language.

The tendancy has been for apps like this to offer, as their "hook," a
C-like API.

Most Scheme implementations put high value on having a FFI system that
allows linking the Scheme environment into a C application, which
commonly makes this not _too_ difficult.  This was one of the express
purposes of the design of Guile Scheme, for instance.

Common Lisp implementations often offer something similar, too.

A common factor is that FFI systems are almost always pretty
implementation-specific.  That is, the FFI scheme for Guile is not
compatible with the one for MzScheme or RScheme.  Nor is it likely the
same as the FFI scheme for CLISP, which is not the same as the FFI
scheme for CMU-CL, which differs from what is used with LW or ACL.

There are attempts at "common FFI schemes," such as GWrap (which works
with several Schemes) and "UFFI" (for several Common Lisp
implementations).  They are less universal than you'd probably hope
for...
-- 
output = ("cbbrowne" ·@cbbrowne.com")
http://www3.sympatico.ca/cbbrowne/lisp.html
Space   is   big.  Really    big.   You   won't   believe  how  vastly
mind-bogglingly big it is.  I mean, you may think it's a long way down
the road to the chemist, but that's just peanuts to space. Listen....
From: Luke J Crook
Subject: Re: Game development
Date: 
Message-ID: <2W_wa.20267$6P6.534822@twister.socal.rr.com>
"Franz Kafka" <Symbolics _ XL1201 _ Sebek _ Budo _ Kafka @ hotmail . com>
wrote in message ························@news01.roc.ny.frontiernet.net...

>
> Or, to create a Lisp-type Gaming Language that would
> compile into an other Game's scripting Language.

You would probably want to write a Lisp to game scripting language
translator, which would operate in much the same way as a Fortran to C
translator, or a Lisp to C translator. The Lisp source would be translated
into the syntax of the scripting language, which would then be run through
the script compiler.

-Luke
From: Vladimir S.
Subject: Re: Game development
Date: 
Message-ID: <87u1c0b7ut.fsf@shawnews.cg.shawcable.net>
Well, you're really asking two different questions. Do you want to use
Lisp for the game logic, or do you want to do graphics programming in
Lisp? In case of the latter, others have pointed to the OpenGL and SDL
bindings available. If you want to do the former, you might save some
time by hooking some CL implementation (CLISP and ECL are probably
good candidates) into an existing graphics engine like Crystal Space
or the first two Quakes (there is some very impressive graphics work
being done with them - see for example Tenebrae). 

You might want to look at LAngband*, which is a Nethack-alike written
in CL. It has some rudimentary graphics (based on SDL), but it's very
portable and the game logic is supposed to be very modular.

* - http://www.langband.org/
From: Gene Michael Stover
Subject: Re: Game development
Date: 
Message-ID: <5S-dnXuwztbQdEWjXTWc-g@speakeasy.net>
Hi Ignas,

I'm writing a game in Lisp.  I chose to do the graphics in C (w/
OpenGL, Mesa) in a separate program.  The logic & the physics
are in Lisp, which sends object positions & velocities to the C
program.  I did it that way to avoid FFI hassles.  I get about
5+ fps with 1,000 objects on the screen (I'm guessing about
10,000 triangles, but that guess could be way off).  I'm happy
with how it's turning out, though the bottleneck is the
communication between Lisp & the C program; wouldn't work well
if you had lots of on-screen objects & Lisp needed to tell C
about each one for each frame.

gene


Ignas Mikalajunas wrote:
> I would like to do some game programming in lisp. What libraries,
> tools should I use ? Is it possible to write any decent graphic's
> intensive software with lisp ? All lib's i could find were associated
> with text editing or AI, but i could not find any graphic's libs like
> Allegro, SDL or OpenGl related stuff.
>    Ignas Mikalajunas
From: Luke J Crook
Subject: Re: Game development
Date: 
Message-ID: <nHgCa.5382$49.329959@twister.socal.rr.com>
"Gene Michael Stover" <·······@speakeasy.net> wrote in message
···························@speakeasy.net...
> Hi Ignas,
>
> I get about
> 5+ fps with 1,000 objects on the screen (I'm guessing about
> 10,000 triangles, but that guess could be way off).  I'm happy
> with how it's turning out, though the bottleneck is the
> communication between Lisp & the C program

What graphics card are you using and how many light sources are active? Are
you processing any texture maps or other effects ?
I ported the OpenGL gears example by Brian Paul to Corman Lisp (a lot less
objects than you have), and get:

- around 72fps on an Athlon 1900 with an nVidia Riva TNT
- around 1,800fps on a dual Xeon 2.8Ghz with a Radeon 9700 Pro

-Luke
From: Gene Michael Stover
Subject: Re: Game development
Date: 
Message-ID: <v6WcnYhf6KK9NEejXTWc-w@speakeasy.net>
Luke J Crook wrote:
> 
> What graphics card are you using and how many light sources are active? Are
> you processing any texture maps or other effects ?

It's a work in progress, not using light sources or texture maps
yet.  (The point of the project is mostly "Gene learns how to
write a game".)

The 5 fps was using an HDS X-term in the kitchen as my X server &
running the game on a 400 MHz Gnu/Linux machine at the other end
of my apartment.

Now I'm running it on a Sony PCG-XG500 laptop with a 700 MHz
CPU & god knows what video hardware.  It gets over 33 fps at 33%
CPU usage & wihout busy-waiting.  By cranking down the timer
interval on 'glutTimerFunc' to 1, it looks like it peaks at
93 fps which surprises me because most of the books I've been
reading say that you need to do OpenGL in hardware to reach 30
fps without pulling busy-wait tricks.

(Oh, & this is with some hard-coded objects, with the viewer
program temporarily disconnected from the simulator.  It looks
like the bottleneck is the communication between the two
programs, so for a production-quality frame rate, it may be
necessary to link the graphics parts with the logic parts.  I'm
going to see how far I can go while keeping them as separate
programs.)

> I ported the OpenGL gears example by Brian Paul to Corman Lisp (a lot less
> objects than you have), and get:
> 
> - around 72fps on an Athlon 1900 with an nVidia Riva TNT
> - around 1,800fps on a dual Xeon 2.8Ghz with a Radeon 9700 Pro

1,800 fps?  Would my eyes be impressed, or is that kind of a
frame rate just a nifty statistic?

> 
> -Luke
> 
> 

gene
Reply to me at CyberTiggyr.COM, where me is "gmb".
From: Joe Marshall
Subject: Re: Game development
Date: 
Message-ID: <H_xCa.34009$M01.10352@sccrnsc02>
> Luke J Crook wrote:
> > I ported the OpenGL gears example by Brian Paul to Corman Lisp (a lot less
> > objects than you have), and get:
> >
> > - around 72fps on an Athlon 1900 with an nVidia Riva TNT
> > - around 1,800fps on a dual Xeon 2.8Ghz with a Radeon 9700 Pro


"Gene Michael Stover" <·······@speakeasy.net> wrote in message ···························@speakeasy.net...
>
> 1,800 fps?  Would my eyes be impressed, or is that kind of a
> frame rate just a nifty statistic?

Your eyes would be very much impressed....
until they were destroyed by the X-rays from the monitor.

I don't think there are any monitors that can handle
an 18 Khz refresh rate.
From: Luke J Crook
Subject: Re: Game development
Date: 
Message-ID: <PfBCa.5514$49.426594@twister.socal.rr.com>
"Joe Marshall" <·············@attbi.com> wrote in message
··························@sccrnsc02...
>
> "Gene Michael Stover" <·······@speakeasy.net> wrote in message
···························@speakeasy.net...
> >
> > 1,800 fps?  Would my eyes be impressed, or is that kind of a
> > frame rate just a nifty statistic?
>
> Your eyes would be very much impressed....
> until they were destroyed by the X-rays from the monitor.
>
> I don't think there are any monitors that can handle
> an 18 Khz refresh rate.
>

18 Khz, wouldn't that be something :)

I am unsure of X, but in Windows - depending on the display driver - it is
possible to lock/unlock OpenGL to the vertical sync of the monitor. When not
locked to the vertical sync, the frames per second do not relate to the
vertical refresh rate of the monitor (the application runs free), thus
allowing for the 1,800 frames per second when the actual monitor refresh
rate is 75hz.

In the case of the Dual Xeon, if I had locked OpenGL to the vertical sync
then the fps would match the monitor refresh of 72Hz.

In the case of the Athlon 1900 with the old TNT card, OpenGL is locked to
the vertical sync resulting in a fps of 72. When not locked I get around
110fps.

-Luke
From: Joe Marshall
Subject: Re: Game development
Date: 
Message-ID: <65nobk1n.fsf@ccs.neu.edu>
"Luke J Crook" <····@NO-SPAM.balooga.com> writes:

> "Joe Marshall" <·············@attbi.com> wrote in message
> ··························@sccrnsc02...
> >
> > "Gene Michael Stover" <·······@speakeasy.net> wrote in message
> ···························@speakeasy.net...
> > >
> > > 1,800 fps?  Would my eyes be impressed, or is that kind of a
> > > frame rate just a nifty statistic?
> >
> > Your eyes would be very much impressed....
> > until they were destroyed by the X-rays from the monitor.
> >
> > I don't think there are any monitors that can handle
> > an 18 Khz refresh rate.
> >
> 
> 18 Khz, wouldn't that be something :)

Sure would.  The horizontal flyback would have to be something like
300 Mhz and the dot clock at about 300 GHz.  You wouldn't need a
monitor because the stray emissions should be in the visible light
band.
From: Luke J Crook
Subject: Re: Game development
Date: 
Message-ID: <QtBCa.5516$49.429937@twister.socal.rr.com>
"Gene Michael Stover" <·······@speakeasy.net> wrote in message
···························@speakeasy.net...
> Luke J Crook wrote:
> >
> > - around 72fps on an Athlon 1900 with an nVidia Riva TNT
> > - around 1,800fps on a dual Xeon 2.8Ghz with a Radeon 9700 Pro
>
> 1,800 fps?  Would my eyes be impressed, or is that kind of a
> frame rate just a nifty statistic?

Just a nifty statistic. Your eye sees only the monitor refresh rate. There
is no perceivable difference between application A with a fps of 200 and
application B with a fps of 60 being displayed on a monitor with a vertical
refresh rate of 60hz. In some cases the higher fps could even look worse,
for example, if the monitor retraces the screen when the application is
halfway though a screen refresh. This can cause 'tearing', i.e.. the bottom
portion of the display seems to lag behind the top portion.

In Windows it is possible to have an OpenGL application not sync with the
vertical refresh of the monitor, thus allowing for the crazy frames per
second.

Why then even mention the 1,800 frames per second ? Well, it shows that (1)
the bottleneck is not in the Lisp application, and (2) that the graphics
card is able to process a lot more geometry, transforms, lighting, textures
etc. before it chokes.

-Luke
From: Luke J Crook
Subject: Re: Game development
Date: 
Message-ID: <5mCCa.5519$49.438967@twister.socal.rr.com>
"Gene Michael Stover" <·······@speakeasy.net> wrote in message
···························@speakeasy.net...
> Luke J Crook wrote:
> >
>
> Now I'm running it on a Sony PCG-XG500 laptop with a 700 MHz
> CPU & god knows what video hardware.  It gets over 33 fps at 33%
> CPU usage & wihout busy-waiting.  By cranking down the timer
> interval on 'glutTimerFunc' to 1, it looks like it peaks at
> 93 fps which surprises me because most of the books I've been


If I might make a couple of suggestions:

Try and generate a compiled display list for each object. If you are simply
duplicating a cube with 6 faces (2 triangles per face) 1000 times, then a
single display list is all you require. All you need to do for each oject
is:

    pushmatrix
        rotate
        transform
        displaylist
    popmatrix

Thats a single call to the display list, instead of 12 calls for each
triangle face.

Don't use a timer (I think this might mean leaving GLUT behind). Why do I
say this ? Well, when using your own hardware you can experiment with the
timer value until all your objects look good moving at a smooth 60 fps. On
faster hardware the frame rate will still be 60fps. But what if someone runs
your game on a machine with half the processing power? Now not only is the
machine too slow (say it could only push 20fps at the best of times), but
you are introducing an additional wait because of the timer, so the game
will run even slower on lower end hardware. By slow, I mean that if it took
1 second to move an object 60 pixels across the screen, on slow hardware it
might take 5 seconds to move that same object 60 pixels. The game now
becomes unplayable because everything runs in Matrix time.

Worse than this, you may experience uneven movement even on your target
hardware. Say for instance you adjust your timer value to give you smooth
movement at 60fps with 1000 objects on the screen. What happens if, in the
very next frame, you have 5x that number of objects on the screen. Now
suddenly you have to crunch through 5x the amount of data (which could take
5x as long) AND there is a timer slowing everything down on the other end.
Objects will move fast, then slow, then fast, then slow etc.

To fix this, have the application crank as fast as it can and scale the
movement/rotations of your objects depending on your frame rate. So no
matter what speed hardware you use, it will always take e.g. exactly 1
second to move an object 60 pixels. Slow hardware might only manage 20fps
while fast hardware might manage 200fps so movement be a lot smoother using
fast hardware, but at least the game will play at the same speed. This is
how most games work, e.g. Quake etc. In fact, this is pretty much the only
way to go if you plan on having a multiplayer mode over a WAN or the
Internet.

Here is a link describing one such scaling algorithm:
http://www.libsdl.org/pipermail/sdl/2001-September/038327.html
And here is the link to the book "Programming Linux Games" that is available
for free download: http://www.overcode.net/~overcode/writing/plg/

> reading say that you need to do OpenGL in hardware to reach 30
> fps without pulling busy-wait tricks.

I'm not entirely sure what you mean here.

> (The point of the project is mostly "Gene learns how to
> write a game".)

Well, we're both in the same boat then :)

Hope this helps.

-Luke