_gl-board.ss_

The gl-board.ss library uses OpenGL, via the sgl library, to provide generic
functionality for 3-dimensional views of board games.  It provides support for
viewing and positioning the board as well as for moving pieces on the board.
It does not handle rendering of the board and pieces themselves.  The arrow
keys rotate the board, the = and - keys move the board closer and further, and
the _ and + keys control the field of vision.  Games are played by left
clicking the mouse on a piece and dragging it to a space.

The checkers and goblet games both use the gl-board.ss library.

The gl-board.ss module provides _gl-board%_, a subclass of canvas%, with the
following public methods:

> (add-space draw info): (->) X ->
  Adds a space to the board.  The draw argument function should draw the space
  using GL drawing commands.  The info argument is associated with the space.
  Spaces should be drawn on the z = 0 plane.

> (add-piece x y z draw info): real real real (bool ->) X ->
  Adds a piece to the board.  The draw argument function should draw the piece
  using GL drawing commands; the argument is #t if the piece is being drawn
  only for its shadow, #f otherwise.  The info argument is associated with the
  piece.  The x, y, and z arguments are the position at which the piece resides.

> (add-heads-up w h draw info): real real (->) X ->
  Adds an item to a "heads-up" display at the bottom of the board area. The
  heads-up area is not affected by rotation or scaling of the board, though 
  it does scale as the window is enlarged. The w and h arguments inidicate
  the width and height of the object that is shown by `draw'; the heads-up
  area is intended to show objects up to size 1 x 1. The `draw' function
  should draw at the origin.

> (get-spaces): -> (listof X)
  Returns a list of the infos associated with the current spaces.

> (get-pieces): -> (listof X)
  Returns a list of the infos associated with the current pieces.

> (get-heads-ups) -> (listof X)
  Returns a list of the infos associated with the current heads-up items.

> (set-space-draw info draw): X (->) ->
  Sets to draw the drawing method of all spaces whose info is equal? to the
  given info.

> (set-piece-draw info draw): X (boolean ->) ->
  Sets to draw the drawing method of all pieces whose info is equal? to the
  given info.  The drawing method takes a boolean.  If the value it true, 
  then the piece should be drawn for creating its shadow.  Otherwise is should
  be drawn normally.

> (set-heads-up-draw info draw): X (->) ->
  Sets to draw the drawing method of all heads-up objects whose info
  is equal? to the given info.

> (enable-piece info on?): X boolean ->
  Enables or disables a piece whose info is equal? to the given info.
  Disabled pieces are not selectable.

> (enabled? info): X -> boolean
  If a piece whose info is equal? to the given info is enabled or not.

> (remove-piece info): X ->
  Removes all pieces whose info is equal? to the given info.

> (remove-heads-up info): X ->
  Removes all heads-up objects whose info is equal? to the given info.


A gl-board object is constructed as follows:
(new gl-board% (min-x real) (max-x real)
               (min-y real) (max-y real)
               (lift real)
               (move (X gl-double-vector ->))
	       ;; Optional:
	       (theta real) (phi real))

The min-x, max-x, min-y, and max-y parameters all specify the dimensions of
the board.  They are used to setup viewing parameters.  The board is viewed
centered around the center of the coordinates, and the view attempts to fill
the window to them. The optional theta and phi arguments determine the initial
rotation of the board, with respective defaults 45 and 0; theta corresponds to
the up and down keys, and phi corresponds to the left and right keys. (Holding
down Command/Meta/Alt while pressing an arrow key pans the display, instead
of rotating.)

The lift parameter specifies how high off the board mouse-dragged pieces are.

The gl-board% class invokes the move callback when a piece is selected
(left-click) and then unselected.  It is given the info associated with the
selected piece, and the coordinates the user has dragged it to.  If the piece
should be moved permanently, the move function must update the board state
with remove-piece and add-piece.
