BU
CAS
CS 480
Introduction to Computer Graphics
Spring 1998
Programming Assignment 1
Due before class on Thursday, February 5
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 5, times to be arranged. You will be asked to sign up
for a demo slot in class.
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:
- Add new polygon points by pressing the left mouse button
- Select/move polygon points by pressing the middle mouse button
- Press the right mouse button to get the pulldown menu
- Toggle area fill on/off (option on pulldown menu)
- Toggle antialiasing of lines on/off (option on pulldown menu)
- Change the polygon color (option on pulldown menu)
- Change the line width (option on pulldown menu)
- Clear the polygon (option on pulldown menu)
- Exit (option on pulldown menu)
Test Cases
You are responsible for testing your own code. Try various test cases. For
instance, try filling various convex and concave polygons. Your program
should also work for 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:
- glBegin
- glBlendFunc
- glClear
- glClearColor
- glColor
- glDisable
- glEnable
- glLineWidth
- glLoadIdentity
- glMatrixMode
- gluOrtho2D
- glPolygonMode
- glViewport
Hint 2: Area Fill of Concave or Self-Intersecting Polygons
OpenGL does not support area fill of concave polygons.
You will need to develop your own code that subdivides such polygons into
collections of convex polygons. Important note: you
cannot use the stencil buffer approach employed by last year's class
(described in the red OpenGL Programming Guide, p. 398).
Your program need not handle self-intersecting polygons.
Hint 3: Example GLUT/OpenGL Programs
Many example programs from GLUT library are available on
the CGL cluster in /usr/local/glut/progs/.
Extra Credit
For extra credit, allow the user to apply a texture map
to the polygon. Be sure to add a menu option that allows the user to
to toggle this option on and off.
Page Created: Jan 14, 1998
Last Modified: Jan 14, 1998
Maintained by: Stan Sclaroff