OpenGL Introduction

CS 320

Jan. 22, 2001

OpenGL's GLUT files have been added to the system directories on all the lab machines. If you have Visual C++ installed on your personal system, check the class home page for instructions on installing GLUT.

  1. Login and create a Projects directory. Copy the files pentagon.c and quadric.c from the class home page into your Projects directory.

  2. Start Visual C++ and open a new, empty Win32 Console Application Project. The location should be your Projects folder and the project name should be Pentagon. Note that Pentagon will be a folder within Projects.

  3. Move pentagon.c from the Projects directory to the Pentagon directory.

  4. Open the Project menu and add pentagon.c to the project.

  5. Open the Project menu and choose Settings. Go the the Link tab. Under Object/Library modules add Opengl32.lib, glu32.lib, and glut32.lib . This is something you'll have to do for each new project. You generally won't need all three libraries, but it's easiest to get in the habit of adding all three each time.

  6. Open pentagon.c, include <windows.h> (make sure it's the first include), and remove the glx header. Take a look at the code. Pretty simple looking, eh?

  7. Compile pentagon.c and fix any warnings and/or errors. (Hint: There is no random() function, but there is a rand() function defined in stdlib.h.)

  8. Build the program, fixing any unresolved references.

  9. Run the program. Nice pentagon, right? What happens when you minimize and restore the window? Can you hypothesize why that happens?

  10. Repeat for quadric.c . Look at the functions init() and display(). Can you see any correlation between the code and the images? Remember, on the class home page there's a web interface to the man pages on phoenix for all the functions. Lowercase all function names and remove any argument suffixes. For example, if you're interested in gluCylinder() you'd do a search on glucylinder and if you're interested in glColor3f() you'd do a search on glcolor.

  11. Remove the three library files (.lib) files that you added within the link tab. Try to build the program and note the error messages you receive. That what will happen any time you forget to include the library files in the compiler's link phase.



Thomas P. Kelliher
Sat Jan 20 10:50:40 EST 2001
Tom Kelliher