I was recently helping a friend get set up running OpenGL and I realized that most of the instructions available online for this are fairly outdated. So, here’s a quick run through to set the record straight. This guide is meant for beginners who just want to get a simple OpenGL desktop app going on a Windows machine.
This guide assume you have the following installed:
1. Windows 7 or 8
2. Visual Studio 2008, 2010, or 2012
By convention, we assume the OS is installed to the C drive and VS is installed to a folder such as “C:\Program Files (x86)\Microsoft Visual Studio 10.0″ (for 2010, 2008 maps to 9.0 and 2012 to 11.0).
The first step is to download GLUT (the OpenGl Utility Toolkit). This library provides a slew of helper functions for working with OpenGL, including setting up a window. Grab the latest binaries from here. Unzip this and copy the binaries out into the following directories. Be aware that these are 32-bit binaries. You will need to create the “gl” folder in “\Microsoft Visual Studio 10.0\VC\include\”, as it doesn’t already exist.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\gl\
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib\
C:\Program Files\Microsoft Visual Studio 10.0\VC\include\gl\
C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\
Now boot up Visual Studio. You’ll want to create a simple Win32 console application. In VS 2010, open the New Project dialog and look at the list of templates. Select Visual C++\Win32\Win32 Console Application. Click through the Wizard that appears, leaving the defaults in place.
At this point you should get a solution with a couple of default files and a “_tmain” entry function. Right-click the project you created, go to Properties, then open Configuration Properties\Linker\Advanced
Choose the NO.
Close the settings and modify your main .cpp file to look like this:
// One-time initializtion logic
void init( void )
printf( "OpenGL version: %s\n", (char*)glGetString(GL_VERSION));
printf( "OpenGL renderer: %s\n", (char*)glGetString(GL_RENDERER));
//Configure basic OpenGL settings
glClearColor(0.0, 0.0, 0.0, 1.0);
// Main drawing routine. Called repeatedly by GLUT's main loop
void display( void )
//Clear the screen and set our initial view matrix
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
//TODO: Perform drawing here
//We just drew to the back buffer. Now we need to swap that with the
//front buffer to show it on screen.
// Entry point - GLUT setup and initialization
int main( int argc, char** argv )
glutInit( &argc, argv );
glutInitDisplayMode (GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (800, 600);
glutInitWindowPosition (100, 100);
glutCreateWindow( "OpenGL Test" );
glutDisplayFunc( display );
Hit F5 to build and run. You should get a window with a black screen. Pat yourself on the back. You’re now ready to start coding with OpenGL.