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

放肆的年华 提交于 2019-12-18 03:00:48

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/8985548/how-to-get-ready-a-c-project-with-opengl-glut-and-visual-studio-2008-in-windo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!