SimpleDraw 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.

SimpleDraw shows how to draw points, lines, line strips and line loops.   It consists of two source files, SimpleDraw.c and SimpleDraw.h.   There are several options available for downloading this program:

Things to try out:

  1. Compile and run the program.  Use the space bar to toggle between the five images.    Examine the source code and figure out how each of the five figures is drawn in the routine drawScene().
  2. Uncomment out the blocks of code in initRendering() and recompile and re-run.  (First uncomment the first block, then uncomment both blocks.)  How does this effect what the graphics images look like on your computer?
  3. Understand the purposes of the call backs that were set up by calls to glutKeyboardFunc(),   glutReshapeFunc(),  glutDisplayFunc().  Understand what the call to glutMainLoop() does.  Understand how the program responds to the space bar and the escape key.
  4. This program does not use double buffering.   Understand what this means.   What is the purpose of the call to glutPostRedisplay() after the mode is changed?

Version 1.1 of SimpleDraw, Sept. 28, 2003.  
Thanks to Rob Wilkens for a bug report.