Courtesy my ex-Professor, Dr.David Ebert

Dr.Ebert kindly gave me permission to use one of his lab assignments as an assignment to my students and use of the sample program and data files given there.

The link to the assignment is given below. However, for faster access, the link information is also made available locally.

2D Scan Conversion

The Assignment - 15 marks (5 for first half and 10 for second half)

Write a program that reads polygon descriptions from a file, scan-converts, and displays them using the GLUT library (first use GLUT for complete display; later, do the actual polygon filling algorithm yourselves). Don't clear the image after each polygon, draw later polygons on top of earlier ones. The last polygon listed in the file will lie on top of all of the others. This is called the Painter's Visibility Algorithm, since it simulates the process a painter would follow to paint a picture.

The input file describes a sequence of polygons. Each polygon description begins with a header line containing the number of vertices of the polygon and the fill color (given as red, green, and blue values). Following the header line are lines giving the coordinates of the vertices, one line for each vertex. Lines which begin with a '#' character are comments and can simply be ignored. A simple polygon description might look like this:

# red triangle 
3       1.0 0.0 0.0
1       1
1       5
5       1

This describes a red triangle.

Here’s a sample input file. Here’s a sample code segment to draw lines without using glVertexx functions.