OpenGL Lab: Menus, Selection, Display Lists, and ``Animation''

CS 320

Feb. 21, 2005

  1. Create a new OpenGL project, grab paint.c from the class home page, and add it to the project.

  2. Compile and run the program. Play with it. Show us your creative side.

  3. Fix the text drawing tool so that text is drawn in the current color.

  4. Add a set of display lists for ASCII text, as discussed in class and add an elapsed time clock in the upper right hand corner of the canvas. The elapsed time string should be displayed in black characters.

    Hints:

    1. The time() function returns the number of seconds since the beginning of the ``Epoch:''
         #include <time.h>
         #include <stdlib.h>
      
         int startTime = time(NULL);
      

    2. Using a start time and a current time, you can easily compute the number of elapsed seconds. Using modulo arithmetic, you can convert elapsed seconds to elapsed hours, minutes, and seconds for your display.

    3. The sprintf() function can be used to create the time string:
         #include <stdio.h>
      
         char timeString[80];
      
         sprintf(timeString, "%2d:%02d:%02d", elapsedHours, elapsedMinutes,
                 elapsedSeconds);
      

  5. Explain why the elapsed time string has so much ``jitter.''

  6. Add a menu choice to allow resetting the elapsed time to 0.

  7. Add a line strip drawing tool.



Thomas P. Kelliher
Thu Feb 17 09:37:39 EST 2005
Tom Kelliher