next up previous


Computer graphics Assignment 2


Scan Conversion
Due date: Wednesday, October 6, 12:00 pm

What your program should do

Write a program that performs two tasks: line drawing and scan conversion for polygons with texture mapping. The program should be interactive, that is, the endpoints of the lines and the vertices of the polygon should be defined interactively by the user. Switching between the two modes can be done using the GLUT pull-down menus or the space bar.

In this assignment only, you should not use OpenGL functions for drawing lines and polygons. Create an internal array of RGB values, and do all drawing there; display the image using OpenGL raster functions glRasterPos, glDrawPixels, as it was explained at the lecture.

Your program should do the following:

For the purposes of calculating the transformation, assume that the coordinates in the image extend from -1 to 1 in x and y directions.

Assume that vertices of the quadrangle are picked in order, i.e. the point of the image with coordinates (-1,-1) should map to the first point, (1,-1) to the second picked point, (1,1) to the third and (-1,1) to the last. Check the input for validity, i.e. detect and refuse to accept concave and self-intersecting quadrangles, and quadrangles with three vertices on one line.

What to turn in

A working version of your program; please follow the instructions on the Web page when submitting your homework!

PPM format description

This description is from the SGI's IFL man page. The portable pixmap format is a lowest common denominator color image file format. The definition is as follows:

Here is an example of a small pixmap in this format:

     P3
     # feep.ppm
     4 4
     15
     0  0  0    0  0  0    0  0  0   15  0 15
     0  0  0    0 15  7    0  0  0    0  0  0
     0  0  0    0  0  0    0 15  7    0  0  0
     15  0 15    0  0  0    0  0  0    0  0  0

Programs that read this format should be as lenient as possible, accepting anything that looks remotely like a pixmap.


next up previous
Denis Zorin