You are not allowed to edit this page.

    GLUT HOWTO

GLUT HOWTO

This document explains how to set up GLUT to work with your development environment. There are 3 sections, one for each of the major platforms. Each set of instructions is split into two sections. The first section need only be performed once to setup GLUT on your computer. The other needs to be performed each time you set up a new OpenGL project.

Note that if you're using the myth lab computers then glut has already been setup and you only need to add the appropriate compiler options.

Windows

Here we assume you are using Visual C++.

One Time Setup

  1. Download the windows GLUT distribution from http://www.xmission.com/~nate/glut.html . Make sure you download the bin zip file. (Alternatively download and compile freeglut from http://freeglut.sf.net . Nate Robins' GLUT has not been updated since 1998 so freeglut may be a better option.)

  2. Unzip glut.h and glut.lib somewhere to keep them permanently (i.e. not in your project directory). Unzip glut32.dll somewhere in your path so it will be accessible by all GLUT programs (C:\Windows\system32 will work, or put it someplace and add that directory to your path by right clicking My Computer, clicking Properties, click the Advanced tab, click the Environment Variables, and either edit or add the PATH variable under the User Variables section to contain the location of the file).
  3. In Visual Studio, go to Tools -> Options...

  4. In the Options window on the left select "Projects and Solutions" -> "VC++ Directories".

  5. From the "Show directories for:" drop-down box, select "Include files".
  6. Add a new directory to the list and point it to the directory holding glut.h.
  7. Do the same for "Library Files", pointing it to the directory holding glut32.lib.

Now glut.h and glut32.lib will always be accessible for your projects.

Per Project Setup

  1. To add the library to the list of libraries to link to, go to Project -> Properties...

  2. Select Linker -> Input in the tree on the left.

  3. Add glut32.lib to "Additional Dependencies".

You should now be able to compile a GLUT program. The GLUT header will just be glut.h (i.e. #include <glut.h>). The GL headers will be GL/gl.h and GL/glu.h.

MacOSX

One Time Setup
You just need the developer tools provided by Apple installed. You can get them installed using the XCode install. If you don't want to use XCode you should be able to deselect it during installation.

Per Project Setup - XCode

  1. Open XCode
  2. Create a new project (File -> New Project)

  3. Under the group "Command Line Utility", choose "Standard Tool" for a C program or "C++ Tool" for a C++ program. Fill in the project name and finish creating the project.
  4. Click on the "Actions" pull down menu and select "Existing Frameworks"
  5. In the dialog you'll be in /System/Library. Select /System/Library/Frameworks/GLUT.framework and add it.

The headers for GL, GLU, and GLUT are OpenGL/gl.h, OpenGL/glu.h, and GLUT/glut.h respectively.

Per Project Setup - Makefile
If you're building your project using a makefile, you'll just need to add the frameworks (OpenGL and GLUT) to the compiler invocation. For example, for a simple project your command line might look like this:

g++ -o gl_app -framework GLUT -framework OpenGL main.cpp

Linux

One Time Setup
Use your package manager to install the GLUT libraries and their development packages. Some distributions may use an updated version / rewrite of GLUT, such as freeglut. Even so, there will probably be a metapackage for glut and glut-dev. Note that you will likely have to install quite a few dependent packages as well.

Once you have done that, the necessary header files should be available in /usr/include and the appropriate libraries in /usr/lib.

Per Project Setup
The header files will be GL/gl.h, GL/glu.h, and GL/glut.h. Generally they will all be installed in /usr/include which should make them available by default to the compiler. If they are not available you'll have to locate them and add the path to the compiler command line using -I/path/to/header/files.

To link to the glut library simply add -lglut to the compiler command line.

So a sample compiler invocation would be

g++ -o gl_app -lglut main.cpp
Recent