glLife - Conway's Game of Life using OpenGL
*******************************************
Simon Green 3/2000

Introduction
============

glLife implements John Conway's famous cellular automaton
"Life" using OpenGL to accelerate computation and display.

Although with current graphics hardware this is not always the
fastest way of computing Life, OpenGL does allow for some interesting
display possibilities, including fractional zooming and rotation
and even perspective views of the cell universe (which is
pointless but fun).

If you don't know what "Life" is I recommend this web page:
http://www.cs.jhu.edu/~callahan/lifepage.html

Performance
===========

This is intended more as a demo or video art than a serious CA tool.
If you are looking for a good high performance software Life program
for Windows I recommend Johan Bontes' Life32:
http://psoup.math.wisc.edu/Life32.html

On an SGI 320, glLife gets around 12 frames per second with a
1024 x 1024 universe, which is 12 million cell updates a second.
With the ever increasing fill rates and parallelism of graphics
hardware it may one day become faster doing it this way than
using the CPU.

Since calculations are always performed for every cell in the universe
(it doesn't make use any traditional Life optimizations that take
advatage of the sparsity and regulatity of the universe), performance
is independent of the number of active cells.


Requirements
============

You will need an OpenGL implementation that supports the stencil
buffer and destination alpha (this may require switching to a true color
display on some systems). There appears to be a bug in the standard Microsoft
software OpenGL that causes this program not to work, although it would be
very slow anyway. The code has been tested on NVidia TNT, GeForce and the
SGI 320 (very fast).

The program computes the patterns in the back buffer, with one pixel
representing one cell, and then displays the results using texture
mapping to the front buffer. Since this isn't synched to the vertical
refresh, you might notice some flickering.


Usage
=====

Most of the user interface is self-explanatory. There is a menu activated
by the right mouse button that provides most of the available options,
with keyboard shortcuts shown in braces.

Mouse Buttons:
Left 				- translate
Middle (or left+shift)		- zoom
Middle+Left (or left+ctrl)	- rotate

Keys:
'g'	- toggle animation
space	- step animation
'm'	- move
'd'	- draw cells
'e'	- erase cells
'r'	- reset view
'n'	- toggle info

'+' '-'	- zoom
'*' '/' - rotate 45 degrees
numeric keypad - move


Command Line Options
====================

The default size of the Life grid is 256 x 256 cells. You can also set
the size at start time using a command line option:
-size <w> <h> 
This size is limited by the maximum texture size (typically 2048x2048
with current hardware) and the window size since calculation is done in
the back buffer.

The program also loads Life patterns in the ".lif" format. There is no
file requester, so you must specify a file to load at start time on
the command line:
gllife patterns\breeder.lif -size 1024 1024

A few interesting examples from Alan Hensel's excellent collection are
included in the "patterns" directory, for the rest see:
http://www.mindspring.com/~alanh/life/


Algorithm
=========

The algorithm used is basically that described in the OpenGL
Programming Guide (p.589 in the 3rd edition). It uses the
texture mapping and the stencil buffer to count neighbours,
followed by the stencil test to determine which cells should
live or die.

This requires 10 passes to calculate each generation (8 to count
the neighbours, 2 to determine cells for the next generation).

The biggest performance bottleneck on most platforms appears to be
the glCopyTexImage call, which copies data from the frame buffer to
texture memory.


Distribution
============

Freely distributable, no warranties implied.


Comments/bugs to: simes@hotbot.com
