DPA 4010 / 6010

Spring 2016

Connect 4 Board

Homework Assignment 1

Due:  Midnight, Wednesday, January 27


Design a  program to display the game Connect 4, using OpenGL, GLUT and C. The board should be a 6 by 7 grid of slots as shown below. The board can be any color you like, and playing pieces should be contrasting colors.  A sample board with some pieces already played is shown below.  If you don't know how Connect 4 is played, find out by clicking here. The next homework assignment will require a "playable" game board.  Design decisions you make for this assignment can make the next assignment much easier.

Connect 4

 Connect 4 Game

Your program should draw the board and the initial pieces, and should respond to callbacks to automatically redraw the window if the board display is covered and then uncovered.  The program should not quit until either the 'q' or 'esc' key is pressed on the keyboard.


Advanced Extension: Write a reshape callback routine (refer to the GLUT documentation) that will make sure that the board always has a 7x6 aspect ratio, is as large as possible, and is positioned in the center of the window. Then, if the user resizes the window, the board will grow or shrink to exactly fit in the window, and stay centered. The easiest way to do this is to use use an OpenGL viewport that always has the correct aspect ratio and is centered in the window.

The program glsquare.c is a basic OpenGL program using the GLUT interface library.  It draws a red square on a white background. You are welcome to study this code before beginning the assignment.

Please submit your program using the standard handin procedure. You should include your program source code and a Makefile.