如何在Windows 7中使用OpenGL,Glut和Visual Studio 2008准备一个C ++项目 [英] How to get ready a C++ project with OpenGL, Glut and Visual Studio 2008 in Windows 7

查看:178
本文介绍了如何在Windows 7中使用OpenGL,Glut和Visual Studio 2008准备一个C ++项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我有很多问题设置Visual Studio 2008使用OpenGL我会问这对于一些人可能有用的问题:


为了在Visual Studio 2008中使用OpenGL和C ++,需要遵循哪些步骤?



解决方案

首先,您需要有一个视频卡,并检查它与OpenGL和驱动程序更新的工作。我使用此链接中的测试,



检查Visual Studio 2008是否正确安装并在计算机中创建以下路径也很重要:


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


现在我们可以按照安装步骤:



1.- ://www.opengl.org/resources/libraries/glut/glut_downloads.phprel =nofollow> https://www.opengl.org/resources/libraries/glut/glut_downloads.php ,解压缩并按照以下说明复制文件:




  • glut.h 到文件夹C:\Program Files \\ \\ Microsoft Windows SDK \ Windows \ v6.0A \Include \gl\

  • glut32.lib 添加到文件夹C:\Program Files \\ \\ Microsoft SDKs \Windows\v6.0A\Lib\

  • glut32.dll 添加到文件夹C:\Windows \System32 \



2.-创建一个空的C ++ Win32应用程序:




  • 从文件菜单中选择新建→项目(Ctrl + Shift + N)。

  • 选择Win32项目,输入名称,然后单击确定。

  • 在向导中,单击下一步,然后选中空项目旁边的框,
    并单击完成。



3.-添加一个新的C ++源文件:




    在项目菜单下选择添加新项目Shift + A)。
  • 选择C ++文件(.cpp),输入名称,然后单击确定。



4.- 链接到OpenGL库(重要步骤):





  • 从导航面板中选择配置属性→链接器→输入,然后选择项目属性(Alt + F7)

  • 从对话框顶部的配置下拉框中选择所有配置

  • 在其他依赖关系中键入opengl32.lib glu32.lib glut32.lib,然后点击OK(opengl32.lib和glu32.lib已经在系统中,而glut32.lib将在下载GLUT之后)。



5.-下载此示例代码



6.-还需要在Visual Studio中设置路径:




  • 工具 - >选项 - > VC ++目录 - >包含文件:


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



  • 在配置属性→链接器→附加库
    目录:


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




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?

解决方案

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

这篇关于如何在Windows 7中使用OpenGL,Glut和Visual Studio 2008准备一个C ++项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆