OpenGL and GLUT HOWTO

Home  |  Topics  |  CPLibrary
Useful references:

OpenGL Online References

Windows Visual C++ Express

  1. Windows has OpenGL libraries included, and Visual C++ has the necessary OpenGL and GLU header files. GLUT libraries and headers are NOT included. You need to download the GLUT distribution from http://www.xmission.com/~nate/glut.html. Download the zip archive glut-3.7.6-bin.zip (117 KB).
  2. The zip archive contains 3 critical files (glut.h, glut.lib, and glut32.dll) in addition to some others which are not needed. These 3 files must be installed in 3 different locations for GLUT programs to compile and run. An easy way to perform this installation is to use Windows Explorer (the file manager). Open Windows Explorer, navigate to the zip archive you downloaded, right-click on it, and then click Extract All.
  3. Install glut.h into the Visual C++ Include directory. Right click on glut.h in the archive you downloaded and select Copy. Navigate to "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl\". You should see the Windows standard GL.h and GLU.h in this directory. Paste glut.h into this directory.
  4. Install glut.lib into the Visual C++ Lib directory. Right click on glut.lib in the archive you downloaded and select Copy. Navigate to "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\". You should see the Windows standard OpenGL32.lib and GLU32.lib in this directory, in addition to a large number of other .lib files. Paste glut.lib into this directory.
  5. Install glut32.dll into the Windows System32 directory. Right click on glut32.dll in the archive you downloaded and select Copy. Navigate to "C:\Windows\System32\". You should see the Windows standard OpenGL32.dll and GLU32.dll in this directory, in addition to a large number of other .dll files. Paste glut32.dll into this directory.

The OpenGL programs should now compile and run in Visual C++.
If Windows does not allow you to install glut32.dll in C:\Windows\System32\ right click on the System32\ folder icon, select Properties, and set permissions appropriately.
If this fails, glut32.dll can be installed in any directory in your Path.

Cygwin on Windows

  1. Start your local Cygwin Install program, or go to http://www.cygwin.com/ and click on the "Install Cygwin now" icon.
  2. Assuming that you have g++ already installed, you need to select and install the following packages:
    1. opengl
    2. freeglut
  3. OpenGL + GLUT programs should now compile with
    $ g++  stdmap-gl.cpp  -lopengl32  -lglu32  -lglut32
    $ ./a.exe
    

Macintosh Xcode

  1. OpenGL and GLUT are included in Macintosh OS X and work well with Xcode. There is nothing else to download and install.
  2. Create a new project and select "Command Line Utility" -> "C++ Tool" for the project type.
  3. Right click on the project target and "Add Existing Frameworks" to add the following 3 frameworks:
    1. Cocoa.framework
    2. OpenGL.framework
    3. GLUT.framework
  4. Replace main.cpp with your OpenGL program, which should now compile and run.

Linux

  1. In Ubuntu, use the package manager to download and install libglut3-dev.