Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ready a C++ project with OpenGL, Glut and Visual Studio 2008 in Windows 7

As I had many problems setting Visual Studio 2008 for using OpenGL I will ask this question that can be useful to some people:

Which are the steps to follow in order to use OpenGL with C++ in Visual Studio 2008?

like image 384
Jav_Rock Avatar asked Dec 06 '22 16:12

Jav_Rock


1 Answers

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

It is also important to check that Visual Studio 2008 is correctly installed and that the following path is created in your computer:

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

Now we can follow the installation steps:

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

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

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

  • From File menu select New → Project (Ctrl+Shift+N).
  • Select Win32 Project, enter a Name, and click OK.
  • In the Wizard click Next, then check the box next to Empty Project, and click Finish.

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

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

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

  • Under the Project menu select Project Properties (Alt+F7) at the bottom.
  • Select Configuration Properties → Linker → Input from the navigation panel on the left.
  • Select All Configurations from the Configuration drop-down box at the top of the dialog. This ensures you are changing the settings for both the Debug and Release configurations.
  • Type “opengl32.lib glu32.lib glut32.lib” in Additional Dependencies and click OK (the opengl32.lib and glu32.lib are already in the system, and glut32.lib will be after downloading GLUT).

5.- Download this sample code.

6.- It is also necessary to set the paths in Visual Studio:

  • In Tools -> Options -> VC++ Directories -> Include Files:

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

  • In Configuration Properties → Linker → Additional Library Directories:

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

like image 163
Jav_Rock Avatar answered May 15 '23 18:05

Jav_Rock