CS 5600 - Spring 2009

Homework Assignment 3

2D Polygon Scan Conversion (100 points)

Please note, this assignment is more difficult than the first two, plan accordingly!

Handed out: Feb 3, 2009
Due: Midnight, Feb 10, 2009

You will write a program that scan converts arbitrary 2D polygons.
The polygons may be concave or convex and must include interpolated colors.
You may not use OpenGL polygon drawing commands but must use the drawPoint subroutine from the example program provided for the first assignment.

1. You program should compile and run on the CADE

2. You should read an input file (file name is the first parameter).
For example: lab2.exe polygon_file

The input file has the format (assume any spaces as white space):

POLYGON vertices
VERTEX X0 Y0 r g b
VERTEX X1 Y1 r g b
...
VERTEX Xn Yn r g b

POLYGON vertices
VERTEX X0 Y0 r g b
VERTEX X1 Y1 r g b
...
VERTEX Xn Yn r g b

Where parameters [Xn Yn r g b] are floats, [vertices] is an integer and [POLYGON and VERTEX] are strings.
Here is an example file: testfile1
Here is another test file: new.txt
There may be multiple polygons in the input file

3. You must interpolate the colors internal to the polygons. Hint: first scan convert a solid color polygon and then add color interpolation.

4. You must handle polygons outside of the rendering window. (Clipping)

5. You may either use the AET algorithm provided ( example ) [recommended] or triangularize the input polygon [NOT recommended]

Output

The program should draw its output to an OpenGL window of size 512x512 as in the example program.

Submission

use the handin routine in the CADE Lab. You can with zip or tar your solution. You should comment your code appropriately and hand in a web-page that will serve as complete documentation. Please include a paragraph of difficulties and a paragraph of what you learned in this assignment.

The handin name for this lab is "lab3".

Windows users should use the Zip utility and handin a single zipped file. Unix users should use the tar program to do the same. We will recompile the programs to grade them. Make sure your workspace/program will compile for us. That is, be careful about your user-specific pathname variables! If you do this on a home machine, please allow sufficient time for porting to the CADE machines. We will grade based on compiling and running on the CADE machines.

Due to a bug in the handin program, do not include spaces in the names of the files that you submit, otherwise we will not receive them. For instance, "no spaces.txt" is not a valid filename and would not be received, while "no_spaces.txt" is valid. Please keep this in mind while handing in your assignment.