How to prepare a C ++ project with OpenGL, Glut and Visual Studio 2008 on Windows 7

Since I had a lot of problems installing Visual Studio 2008 to use OpenGL, I will ask this question, which may be useful for some people:

What are the following steps to use OpenGL with C ++ in Visual Studio 2008?

+4
source share
2 answers

First of all, you need to have a video card and verify that it works with OpenGL, and the drivers are updated. I used the test in this link to test it.

It is also important to verify the installation of Visual Studio 2008 and create the following path on your computer:

C: \ Program Files \ Microsoft SDK \ Windows \ v6.0A

Now we can complete the installation steps:

1.- Download GLUT from https://www.opengl.org/resources/libraries/glut/glut_downloads.php , unzip and copy the files according to the instructions below:

  • glut.h to the folder C: \ Program Files \ Microsoft SDK \ Windows \ v6.0A \ Include \ gl \
  • glut32.lib to the folder C: \ Program Files \ Microsoft SDK \ Windows \ v6.0A \ Lib \
  • glut32.dll in the folder C: \ Windows \ System32 \

2.- Create an empty C ++ Win32 application:

  • From the File menu, choose New → Project (Ctrl + Shift + N).
  • Select the Win32 project, enter a name and click OK.
  • In the wizard, click Next, then select the Empty Project check box, and click Finish.

3.- Add a new C ++ source file:

  • From the Project menu, select Add New Item (Ctrl + Shift + A).
  • Select the C ++ file (.cpp), enter a name and click OK.

4.- Link to OpenGL libraries (important step):

  • From the Project menu, select Project Properties (Alt + F7) at the bottom.
  • Select Configuration Properties → Linker → Login from the left navigation bar.
  • Select All Configurations from the Configuration drop-down list at the top of the dialog box. This ensures that you change the settings for the Debug and Release configurations.
  • Type "opengl32.lib glu32.lib glut32.lib" in the additional dependencies and click OK (opengl32.lib and glu32.lib are already on the system, and glut32.lib will be after loading GLUT).

5.- Download this sample code .

6.- You must also set the paths in Visual Studio:

  • In Tools → Options → VC ++ Directories → Include Files:

    C: \ Program Files \ Microsoft SDK \ Windows \ v6.0A \ Include

  • In the configuration properties → linker → additional library Directories:

    C: \ Program Files \ Microsoft SDK \ Windows \ v6.0A \ Lib

+11
source

MSDN has a section in OpenGL that should help, including sample code.

+4
source

All Articles