Aug 26, 2009

Getting OpenGL to Work With Visual C++ 2008

Follow each step, unless you have already done one of these steps.
1. Install Visual C++ 2008 Express Edition

This is a free C++ IDE from Microsoft that is an excellent tool to start with, if you are interested in programming on a Windows environment.

You can find Visual C++ 2008 on the Visual Studio Express download page on Microsoft's site. It only works on Windows XP and up. If you have an older version of windows you might want to find Visual C++ 2005 and then use this Visual C++ 2005 and OpenGL tutorial.
2. Install Windows SDK for Windows Server 2008 and .NET Framework 3.5

This is the equivalent to the Windows� Server 2003 SP1 Platform SDK that Visual C++ 2005 users installed. It contains the main OpenGL libraries. You can download the Windows SDK for Windows Server 2008 and .NET Framework from the Microsoft website.

The installation will take a little while.
3. Install the GLUT Libraries

These are additional libraries that come in handy down the road. Some code samples you find may use them, so I find it best to just have them around right off the bat.

GLUT itself is a bit old, but there is another one called freeglut that is a little more actively maintained. I install both of them. Download freeglut from the freeglut SourceForge page. I download the original GLUT from Nate Robins' site.

For both downloads, unzip them and do the following:

1. Copy all the .h files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\GL folder. This should be glut.h, freeglut.h, freeglut_ext.h, and freeglut_std.h.
2. Copy all the .lib files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib folder. This should be freeglut.lib and glut32.lib.
3. Copy all the .dll files into the C:\Windows\system32 folder. This should be freeglut.dll and glut32.dll.

4. Create Your First Project

Create a project in Visual C++ with whatever name you like and set the template as Win32 Project. Click OK.

Click Next on the following screen and you will be taken to Application Settings. Check on Empty Project and then click OK. Your new project has been created.

Declare the dependencies for your project.

1. Click on Project -> [project name] Properties.
2. Expand Configuration Properties.
3. In the Configuration dropdown, select All Configurations.
4. Select Linker -> Input.
5. In the Additional Dependencies field, enter in GlU32.Lib OpenGL32.Lib freeglut.lib glut32.lib. Then click OK.

5. Create Your First Source File

I recommend a .cpp file. I recommned downloading the source code from NeHe's Lesson 2 and copying into the file you just created.

Press F7 to compile it and F5 to run it.

It should be working at this point. If not, post a comment and I will try and help out.

Reference: http://thoughtsfrommylife.com/article-748-OpenGL_and_Visual_Studio_Express_2008

No comments:

Post a Comment

Followers