Computer Graphics- Homework 1
Due : Tuesday October 11, 2005
Using OpenGL, GLU and GLUT write a program to play the "game" of life.
The game of life is described on this page together with further references.
You may write your own program to play life on a 2000 x 2000 board, or you may adapt the code
on the site which plays it on an infinite board.
Note if you use the program, you will have to rewrite it to be a subroutine, so that the GLUT program
is the main program.
You should
- create a program which draws a square segment of the board - initially 50x50 in the center of the board
- using squares for the live cells,
- which also provides a menu panel on the side similar to the one on the top in the newpaint2.c program
- on the main part of the board
- a left mouse click should change the state of the cell (e.g. make dead ones live)
- a right mouse click should bring up a menu
- which has a sub-menu that allows the insertion of one of a number of fixed
configurations with their upper left cell at the mouse position. These should include at least
the r pentomino, glider, glider gun, and repro configuration from
site
- has a third last entry which is a submenu allowing the insertion of delays of 1, 1.5, 2, 2.5 and 3 seconds in
the event loop
- has a second last entry (clear) which clears the board (sets it to all dead cells) and display
- has a last entry which allows one to exit the program.
- on the menu part of the board, you should provide square "buttons" providing the following functionality
- Left, Right, Up, and Down - which if clicked with left button move 1/2 of the screen in the indicated
direction, and if clicked with the center button or SHIFTed left button (that is left button with shift depressed)
move a whole screen.
- Zoom in / zoom out - zoom in or out by factor of 2, if clicked with left button.
Note: zoom out will display a larger segment of the board, zoom in a smaller segment.
- Step - which steps one generation (day) or 10 days, if clicked with left or middle button or SHIFTed left button respectively
- Run/Pause - run continuously and Pause (Stop), if clicked with left button (Note that you need to keep the
current state - running or paused - so you can toggle it. A more sophisticated implementation would
change the label on th "button"
Pay attention to ensuring that the window behaves correctly (preserves shapes) on resizing, and that it
updates the generations only when it is not getting mouse input.
Additional Non-required Option
For those interested, write a mouse routine to allow one to select an arbitrary square on the display and
zoom in on it. You can use functionality similar to that in newpaint2.c for drawing squares.
Note that this is not required.
Submission
The source files and a makefile to make the program on neptune or poseidon should be mailed as a tar file as
decribed on the homework submission page.
Warning
This homework is intended as an individual project. You are not permitted
to work jointly on it with others
Paul Farrell