GustavRydstedt/Assignment 1

Gustav Rydstedt

CS 148 - Winter 2007

"Generative Art"

In a GLUT program, how is control passed back to the programmer? How is this set up during initialization?

Control is given to the user via call-back functions. Function-pointers are sent via functions such as glutDisplayFunc (for the display function).Other callback functions are glutReshapeFunc(), which is called when the window is resized, glutKeyboardFunc(), which is called in keyboard interaction, and glutMouseFunc(), called on mouse input, and glutMotionFunc(), called on mouse-motion.

What does the parameter to glutInitDisplayMode() in main() specify?

Parameters to gluInitDisplayMode sets up the initial display mode. In our example GLUT_RGBA sets up a Red, Green and Blue color schema with and alpha channel (for transparency). Another color schema is index-mode which indexes certain colors in a color map. GLUT_DOUBLE sets the display mode to use double buffering (alternating two display buffers) instead of GLUT_SINGLE; which is single buffering. Double buffering helps in smoothing animation. Other parameters can setup the window to use accumulation, depth, or stencil buffers.

What do the calls to glOrtho() and glViewport() in the reshape() function accomplish? If the window is to be resized, why might we want to change this?

glViewport sets up the "viewing box"; that is, sets up the painting canvas for the program. Together with glOrtho (which can redefine and move the coordinate system) these two functions set up the relative coordinate system. In the reshape function these are useful in either keeping the scene relative to the size of the window; or make primitives have constant (or absolute) size whatever the window-size.

Program Instructions

The program writes a koch-triangle (and anti-koch) using GL_LINES and GL_POINTS.

The following files are needed: main.cpp, koch.h and walk.h.


  • (+) Increases Koch-Level

  • (-) Decreases Koch-Level

  • (a) Toggles Animation

  • (t) Toggle Normal/Anti Snowflake

  • (c) Toggle Color

  • (p) Toggle Lines/Points

  • (esc) Exit