This guide will show you how to set up a Visual Studio OpenGL/GLUT project that will compile in both Windows and Linux, as long as it is a pure OpenGL program. This guide also assumes Visual Studio .NET 2003 (and/or 2002) is already installed and you are familiar with its use.
Click here for the Quick Version of this guide (if you simply need to refresh your memory).
Windows comes with OpenGL, and Visual Studio comes with the OpenGL libraries, but neither of them comes with GLUT. Get the newest version of GLUT here: GLUT 3.7.6 for Windows.
Put the following files in the following locations:
File | Location | |
---|---|---|
glut32.dll | Windows XP | Server 2003: | C:\WINDOWS\system\ |
Windows 2000: | C:\WINNT\system\ | |
glut32.lib | C:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Lib | |
glut.h | C:\Program Files\Microsoft Visual Studio NET 2003\Vc7\PlatformSDK\Include\gl |
Note:
If you plan on giving your program to friends to run using Windows, you must also include the glut32.dll file. If they don't have this file in the same directory as your application or in their C:\WINDOWS\system folder, the program will not run.
Because GLUT was designed to be window system independent — it makes its own windows — it is better to let GLUT run as a console application than as a native Windows application (which would require #include <windows.h>). To create an empty console project in Visual Studio, do the following:
Adding source files to the project should be familiar to you, so a detailed explanation is not necessary. There are two facts you should know, however.
Before compiling your project, you need to set up Visual Studio's linker so it knows where to find GLUT. To do this, you must open the Property Pages dialog for your project. There are two ways to do this:
Using either option, the Property Pages dialog will open. Once it appears, do the following:
Note:
If you choose to disable the console
window, remember that you won't be able to see any console output from
your program using printf(), cout, cerr,
etc. So, if you plan on having users run your program from a DOS prompt
and console output needs to be seen, do not disable the console window.
Now your program is ready for development in an excellent IDE while still being portable.
Be sure to test your program on a Linux machine before submitting it for grading.
If you're going to share your program with people for fame and glory, build a Release version so the executable isn't gigantic. More importantly, remember to include the glut32.dll file with your application, because most users won't have it in their WINDOWS/system directory.