570/761 Programming Assignment 1

Due: Tuesday, September 21, 2004


The purpose of this programming assignment is to get introduce you to graphics programming with OpenGL and to increase your understanding of the Bresenham line (Hearn, p. 95) and polygon filling (Hearn, p. 196) algorithms discussed in class.


You are to modify the routines in drawLine.c and drawPolygon.c which are used in paint.c, lineTest.c and polygonTest.c so that they use only the OpenGL routine to draw a point, rather than those for drawing lines or polygons. You are required to implement these using the Bresenham line algorithm and the polygon fill algorithm discussed in class and in your textbook.

Output Format:

The paint program is already set up to take user input and use it to draw points, lines, line loops, and filled polygons. So, you do not need to create any new output, you just need to make sure that drawLine and drawPolygon function properly.


  1. I should be able to compile and execute your final product on a Sun workstation!
  2. See http://www.cs.rit.edu/usr/local/pub/ncs/graphics/OpenGL/Lab1/ (/usr/local/pub/ncs/graphics/OpenGL/Lab1/) for source code for paint.c, drawLine.c, drawPolygon.c, and Makefile. The directory also includes two other testing programs: lineTest.c and polygonTest.c as well as pseudo code for drawLine and drawPolygon.

What to submit

You are to submit a directory called lab1dir using the following command:

submit -v ncs-grd cg1lab1 lab1dir

where lab1dir contains your funcions drawLine.c and drawPolygon.c and a Readme file, if pertinent. If you are using C++ and have changed file names for the test files, please also include the testfiles, a Readme AND your makefile.


  1. You are expected expected to use the names Readme, lab1dir, drawLine.c and drawPolygon.c as specified above. As I am using scripts to help with the grading process, failure to do so is annoying and you will be suitably awarded! :-)
  2. Your directory should only include the source files and a Readme file, i.e., please remove any backup files, executables, etc. before submitting. If you are using C++, please include ALL source files, a Readme file AND your makefile in the directory.


Your overall programming assignment grade will be based on the following: Does your drawLine routine handle all kinds of lines (shallow or steep/positive or negative slopes, vertical, diagonal, or horizontal lines), starting from either endpoint? Does your drawPolygon routine fill rectangles and triangles properly, regardless of order of entry of vertices? The gradesheet I will use can be viewed here.

When I begin grading your submittal, if there are any problems, I will send you e-mail and you must then resubmit within 24 hours. Incorrect submittals are subject to penalties!

Nan C. Schaller
Rochester Institute of Technology
Computer Science Department
102 Lomb Memorial Dr.
Rochester, NY 14623-5608
telephone: +1.585.475.2139
fax: +1.585.475.7100
e-mail: ncs@cs.rit.edu
September 8, 2004