CS 381, Fall 2007
HW #1

General Information

Questions

  1. Do you intend to do the programming assignments for this class on your own computer or in a lab? Identify OS, processor, graphics card and compiler if using your own system. (4 pts)
  2. Running a 2-D Open GL/GLUT Program (8 pts)
    1. Compile and run the program sample2d.cpp from the course web page (requires C++ with Open GL and GLUT; you may need to install the latter yourself). What does the program do? Give details: colors, shapes, etc. Hint: “It doesn’t do anything, because I couldn’t compile it” is not an acceptable answer.
    2. Find the command “glBegin(GL_LINE_STRIP);”, and replace it with “glBegin(GL_LINE);”. When you run the program, what is different? (Check both graphics and text output!)
    3. Modify the source code in some other (interesting?) way. The program should still compile and run, but may (or may not) produce errors. What modification did you make, and how did the program’s behavior change as a result?
    4. This program is put together differently from most C++ programs you have seen before. In particular, while the function “display” does much of the real work, there is no call to “display” anywhere in the program (really!). After examining the code, made an educated guess as to how “display” gets called.
  3. Running a 3-D Open GL/GLUT Program (8 pts)
    1. Compile and run the program sample3d.cpp from the course web page (requires C++ with Open GL and GLUT). What does the program do? Give details: colors, shapes, etc.
    2. Find and comment out the call to setmaterial_main. When you run the program, what is different? In your own words, what is the purpose of the function setmaterial_main? (In this and the following questions, restore the program to its original form before proceeding with the next question.)
    3. Find the command “glEnable(GL_LIGHTING);”, and replace it with “glDisable(GL_LIGHTING);”. When you run the program, what is different? Based on your observation, why is lighting very important in 3-D CG?
    4. Find the command “glEnable(GL_DEPTH_TEST);”, and replace it with “glDisable(GL_DEPTH_TEST);”. When you run the program, what is different? In your own words, what purpose does this command serve? (Hint: Documentation is available. Use it!)