OpenGL Introduction
CS 320
Feb. 5, 2003
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
and/or for obtaining a free C/C++ compiler.
- Login and create a Projects directory. Copy the files
pentagon.c and quadric.c from the class home page into your
Projects directory.
- 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.
- Move pentagon.c from the Projects directory to the
Pentagon directory.
- Open the Project menu and add pentagon.c to the project.
- 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.
- Open pentagon.c and observe the header file declarations:
#include<windows.h>
#include<GL/gl.h>
#include<GL/glu.h>
#include<GL/glut.h>
These should be included in all your projects in the order given.
- 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.)
- Build the program, fixing any unresolved references.
- Run the program. Nice pentagon, right? What happens when you
minimize and restore the window? Can you hypothesize why that happens?
- Repeat for quadric.c .
Look at the functions init() and
display(). Can you see any correlation between the code and the images?
The man pages for all the OpenGL, GLU, and GLUT functions are installed on
phoenix for your perusal. 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
.
- 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
Tue Feb 4 18:25:31 EST 2003
Tom Kelliher