ConnectDots

ConnectDots is sample C code illustrating the use of OpenGL.   It is intended to accompany the book 3D Computer Graphics: A mathematical approach with OpenGL, by S. Buss, Cambridge University Press, 2003.   However, it can be used independently as well.

ConnectDots allows the user to specify points with mouse clicks.   The points are drawn connected with straight lines.   This illustrates how the OpenGL GLUT routines can be used to capture mouse clicks.  The C code consists of two source files, ConnectDots.c and ConnectDots.h.   There are several options available for downloading this program:

Things to try out:

  1. Compile and run the program.  Test out the keyboard controls.  The left mouse button adds a point.  The commands "f" and "l"  remove the first and last point from the list of points (respectively).  If you go over 64 points, the first point(s) are removed.
  2. Observe how the program uses an OpenGL GLUT callback to capture mouse clicks and determine their  x and y  locations.
  3. Experiment with turning off and on (a) the thick lines and points, (b) the anti-aliasing.  What difference does this make to the appearance and the speed of the graphics?  Your results may vary widely depending on your implementation of OpenGL.
  4. MAJOR PROJECT: write a program that generates Catmull-Rom splines or Overhauser splines that interpolate the dots.  Do something appropriate at the endpoints to make the first and last points be interpolated.