CMSC 435/634: Computer Graphics

Lab 2: 2D Scan Conversion

Due October 6, 2000

The Assignment

Write a program that reads polygon descriptions from a file, scan-converts, and displays them using the Edge library. 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. A sample input file can be found in ~ebert/cs435/paint.pgon.

Use the Edge library to handle the user interface and write pixels to the display. Documentation for Edge is attached, as is a sample program. All the Edge commands that you need for this assignment are used in the sample program. The Edge library can be found in ~ebert/cs435/libedge.a and the Makefile in that same directory shows how to compile a program using Edge. Use the Edge command EdgeWritePPM to save your final image to a PPM (Portable PixMap) file.

Turn in your assignment by using the submit mechanism on gl. Include your c code, your Makefile, and the ppm image produced when your program is run on the sample input. Use the project name 'lab2'.Your comments should include the environment (hardware and software ) that you used to develop your program as well as a description what outside help you got .

Main Page | Syllabus | Class Calendar

Course Assignments & Handouts | Links | Reading List