OpenGL and Visual Studio
The following explains how to get started with Visual Studio 2010 and OpenGL. This is written from memory and may contain errors. If you find any errors, please report them to a TA, and we'll correct it.
- Create an empty C++ project in Visual Studio
- File->New->Project...->Visual C++->General->Empty Project
- Usually located under My Documents\Visual Studio 2010\Projects\<project name>\<project name>\
- If the files don't show up in Visual Studio, then you may need to add them. This is done by right clicking on the project and selecting Add->Existing items. Select the GL folder and all .h and .cpp files in the project directory, and click add.
- If you get compile errors, this is likely because it can't find <GL/glut.h>
- A quick way to remedy this is to use relative paths ("") instead of include paths (<>). Relative paths are relative to the place where the project files go, so if you copied the files verbatim to the project directory, you can simply replace <GL/glut.h> with "GL/glut.h" in all .h and .cpp files.
- Another possible issue is the "#ifdef WIN32". This is used to include windows.h if you compile the code on a Windows system. If the "#include <windows.h>" has faded colours, then it is not included. To include this file, either change "WIN32" to "_WIN32", or remove the "#ifdef" and "#endif" lines around the include statement.