BU CAS CS 480

Introduction to Computer Graphics

Spring 1997

Programming Assignment 1

Due before class on Thursday, February 6


This programming assignment will get you started as an OpenGL programmer, while introducing you to basic concepts in interactive graphics programming. You will develop a polygon drawing tool that allows the user to draw, fill, and modify a polygon given mouse input.

Your polygon editing tool must run on the SGI, therefore you will need to use one of the SGI workstations in the CGL cluster (unless you have access to an SGI workstation elsewhere). If you develop your code on a PC, be sure to port and test the code on an SGI before submiting it.

Your program's source files are to be electronically submitted by using the submit program on cgl. The code you submit should conform with the program assignment guidelines.

Part of your grade for this programming assignment will be based on your giving a short demo (2-3 minutes) in the CGL cluster. You will be expected to talk about how your program works, and we will see how well your program performs on some test examples. The demo date for this assignment is Thursday, February 6, 2-5PM. You will be asked to sign up for a slot in class.

Start programming early.

Get Some Files

To help get you started, source files for an example circle drawing program have been provided. A full description of the example program is provided in the program comments. The example program's source files can be found in the directory /usr2/cs480/courseware/p1 on the CGL cluster. Or you can get a copy of the compressed TAR file: example.tar.Z.

You are expected to create a program that allows the user to create and modify a general polygon (rather than a circle). There is an example polygon drawing executable sketch included in the same directory as the source files. This example demonstrates how your final polygon sketch program should work.

The Code You Write

Your program should allow the user to:

Extra Credit

For extra credit, implement cross-hatching of polygons. Be sure to add a menu option that allows the user to toggle cross-hatching on and off.

Test Cases

You are responsible for testing your own code. Try various test cases. For instance, try filling various convex and concave polygons. Try filling polygons that are self-intersecting.

Hint 1: OpenGL Subroutines You May Need

Look on the CS480 class Home Page for links to online OpenGL and GLUT documentation. The following is a partial list of OpenGL routines you will probably need to do the compulsory part of this assignment:

Hint 2: Area Fill of Non-convex Polygons in OpenGL

OpenGL does not support area fill of non-convex polygons. You will need to develop your own code to handle concave and self-intersecting polygons. The recommended approach is to use the stencil buffer as described in the red OpenGL Programming Guide, p. 398. You cannot use the modified scan fill algorithm employed by last year's class.

Hint 3: Example GLUT/OpenGL Programs

Many example programs from GLUT library are available on the CGL cluster in /usr2/cs480/courseware/glut-3.0/progs/.

Page Created: Jan 21, 1997 Last Modified: Jan 21, 1997 Maintained by: Stan Sclaroff