Lab 2

Lab 2: Polygons

Due: Thursday, September 2nd, 2010 (before lab session ends)

Create the program, polygons, that reads in a data file containing a list of vertices and draws them using different OpenGL polygon primitives as shown below.

Input

The input file will consist of a set of data points in the following format:

x0 y0
x1 y0
...

An example is the following:

2.0 0.0
4.0 0.0
6.0 2.0
6.0 4.0
4.0 6.0
2.0 6.0
0.0 4.0
0.0 2.0

Polygon Primitives

Your program should draw the input data using the following methods:

  1. GL_POLYGON
  2. GL_TRIANGLES
  3. GL_TRIANGLE_STRIP
  4. GL_TRIANGLE_FAN
  5. GL_QUADS
  6. GL_QUAD_STRIP
lab_02/polygons.png

All of the different primitives should be displayed in one window with each method in its own separate viewport. Likewise, use a different color for each successive vertex (you may rotate through a fixed set) to achieve the gradient effect shown above.

Usage

To specify the input data file, your program should have at least the following command line interface:

usage: polygons [options] <datafile>
Options:
    -h         Show this help message

An example invocation would be:

$ ./polygons input.data

Feel free to add additional flags and options to modify your programs behavior at runtime.

Submission

Demonstrate the polygons executable to the instructor or TA before the lab session is over. Once verified, place the source code and Makefile in your course dropbox:

/afs/nd.edu/coursefa.10/cse/cse40166.01/dropbox/<afsid>/lab2

Solutions

Peter Bui: