How to Compile and Run an OpenGL Program on the CSS Windows System Using Microsoft Visual C++

 

Geb Thomas

10/22/2004

 

The Visual C++ System on the CSS systems has OpenGL installed by default, but does not have GLUT, the utility toolkit installed.

 

Just to make sure that you have the OpenGL libraries and header files there already you can check for a few key files.  On my machine these appear in:

 

C:\Program Files\Microsoft Visual Studio\VC98\Include\GL:

 

Gl.h

Glaux.h

Glu.h

 

C:\Program Files\Microsoft Visual Studio\VC98\Lib:

 

Glaux.lib

Glu32.lib

OpenGL32.lib

 

C:\WINDOWS\system32:

 

Glu32.dll

Opengl32.dll

 

Together, these files will allow you to compile and run OpenGl programs that do not require the GLUT toolkit.  You can find an example of such a program in WinGLTest.  This example uses the windows system calls to open a window and write graphics in it.  Note that to create this type of application you need to select new->create wi32 application.

 

If you want to write OpenGL programs that are portable between Microsoft, you need to use the GL Utility Toolkit (GLUT) which is not installed on CSS.  You need to get the toolkit from the web, unzip it to a convenient directory and tell the compiler and operating system where to look for it.

 

I copied the toolkit from the OpenGL.Org download page.  Here is version GLUT version 3.7 that I copied.  I made a subdirectory called GLUT and extracted the files from the zip archive to there.

 

In order for the compiler to find the header and library, you need to tell it what directory these are in.  To do that, open Microsoft Visual C++, Tools->Options->Directories (a tab)

Go to the pulldown menu for “show directories for:” and select include files.  Add the directory where you just put the glut.h file extracted from the archive.  Similarly, add the directory (probably the same one) to the list for the library files.

 

Now you have to tell the operating system where to find the .dll file.  Windows searches for these on its path defined as a environment variable.  To set this, open “My Computer.”  Right-click on the white space on the right half of the explorer window.  Select properties, then the “Advanced” tab.  At the bottom of this page is an “Environment Variables” button.  Click on that.  Under the user variables section, select path, then choose edit.  Add the directory where you’ve stored the .dll here.  If there is already a directory defined in this area, add a semicolon, then add the path to your file.

 

You are done.