You are not allowed to use this action.


Assignment 1 - Generative Art

Goal: To familiarize yourself with the basics of OpenGL and GLUT by creating a simple OpenGL application.

Due Date: January 18, 2007


  1. Download the skeleton code and setup GLUT with your development environment to get the code to compile and run. The GLUT HOWTO explains how to do this if you aren't familiar with setting up and using libraries with your development environment.

  2. Read up on OpenGL and GLUT and answer the following questions. Be sure you can answer all these questions before moving on.
    1. In a GLUT program, how is control passed back to the programmer? How is this set up during initialization?
    2. What does the parameter to glutInitDisplayMode() in main() specify?
    3. 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?
  3. Add to the program to draw something (anything!). Your completed program should at a minimum:
    • Draw using at least two primitives (e.g. lines and triangles)
    • Draw using multiple colors
    • Use some user input to do something in the program. This could be as simple as using the number keys to select one of multiple modes.
  4. Write up and submit your program. Your write up should contain both the answers to the questions and any notes we should know about running your program.

Skeleton Code
The skeleton code contains a very simple GLUT based OpenGL program. All it does is create a window and draw a blank screen. We are providing the code packaged for various platforms/IDEs.

Just the code


Code + Visual Studio Project

Code + XCode Project

Code + Cross Platform Makefile (Linux, MacOS X)



Inspiration for What to Draw
You may draw anything interesting, but here are some ideas to get you started.

Grading Scale Grading for this and all future assignments is based on a four star scale. On this assignment you can receive:

  • 4 stars for a complete assignment
  • 1 star if you give only the answers to the questions
  • 0 stars otherwise

How to submit

  • Create a new wiki page with your answers to the questions and link to it from your personal wiki page.
  • Email a copy of your updated main.cpp to the instructors.


  1. I've ssh'd into or used vnc to connect to a myth computer and compiled the code successfully, but when I try to run it I get an error like this: freeglut (./assignment1): OpenGL GLX extension not supported by display ':1.0'. What's going on?
    • When using an X based system, you need the GLX extension to be present to run OpenGL programs. The vnc server installed on the myth computers doesn't support this. If you have an X server installed locally, you can forward X (including GLX) through your ssh session by adding the -Y option to your ssh command. On Mac you can use their X11 server, you'll just need to install it, run it, and then ssh using the -Y option. Then, any X program you run remotely will display locally. On Windows you need to install an X server. One free one comes from cygwin ( See Installing Cygwin/X for instructions on installing and using it. Note you'll have to install the version of the server with GLX support (labelled experimental, but seems to work well). You may also have to fiddle with the startx script to get it to start the correct X server. Needless to say, this can be a lot of trouble. We encourage you to develop on your personal computer if possible.

  2. I'm using Visual Studio and Nate Robbins' GLUT and the compiler is saying '_exit' is being redefined. How do I fix this?
    • This is due to the fact that GLUT hasn't been updated to work properly with newer versions of Visual Studio. The simplest workaround is to include stdlib.h before including glut.h.