Using GLUT with Visual Studio .NET

File Locations for OpenGL with Visual Studio .Net

  1. To compile programs you do not need to download the full GLUT source, only the header and binaries:  (If your system does not already have OpenGL download the self extracting executable Opengl95.exe from Microsoft and put the files in the corresponding locations.)
  2. After downloading the zip file, extract the glut files to the following directories.  (If you have Visual Studio installed in another location, you will have to make the appropriate changes).

    C:\Program Files\Microsoft Visual Studio .NET\Vc7\include\gl

    C:\Program Files\Microsoft Visual Studio .NET\Vc7\lib



Creating a Project in .NET:

  1. New Project (Select Visual C++ Projects, Win32 Project )
  2. In the Application Wizard select "Application Settings" from the menu on the left
  3. Then Choose "Console application "
  4. And check the "Empty project " box.
  5. Once the necessary files are in your project, you should be able to compile and run your GLUT programs.  Do not forget to include the GLUT header in your source:
    	#include <GL/glut.h>


If you receive an error about a redefinition of the exit prototype, there are two possible solutions:

  1. Replace the exit template in glut.h with the one in stdlib.h so that they match. This is probably the best solution, and has been used in this glut.h file.
  2. An easier solution is to #define GLUT_DISABLE_ATEXIT_HACK before you #include <gl/glut.h> in your program.

If you receive an error about missing precompiled headers do the following:

  1. In the Solution Explorer pane right click on the Project and select Properties.
  2. Project Properties:
        Under C/C++, select Precompiled Headers
  3. Next to "Create/Use Precompiled Headers" choose "Not Using Precompiled Headers"


Running a GLUT Program

To run a GLUT program on another PC, you will need the GLUT32 DLL.  You may put it in the same directory as the executable, or in the C:\Windows\System directory.  This assumes that the other PC already has OpenGL libraries, which most Win32 machines come with.