如何在 Windows 7 中使用 OpenGL、Glut 和 Visual Studio 2008 准备 C++ 项目
因为我在设置 Visual Studio 2008 以使用 OpenGL 时遇到了很多问题,所以我会问这个对某些人有用的问题:
As I had many problems setting Visual Studio 2008 for using OpenGL I will ask this question that can be useful to some people:
在 Visual Studio 2008 中使用 OpenGL 和 C++ 需要遵循哪些步骤?
Which are the steps to follow in order to use OpenGL with C++ in Visual Studio 2008?
推荐答案
首先,您需要有一个视频卡并检查它是否可以与 OpenGL 配合使用,并且驱动程序是否已更新.我在这个链接 检查它.
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.
检查是否正确安装了 Visual Studio 2008 以及是否在您的计算机中创建了以下路径也很重要:
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 FilesMicrosoft SDKsWindowsv6.0A
C:Program FilesMicrosoft SDKsWindowsv6.0A
现在我们可以按照安装步骤进行:
Now we can follow the installation steps:
1.- 下载 GLUT 从 https://www.opengl.org/resources/libraries/glut/glut_downloads.php,按照以下说明解压并复制文件:
1.- Download GLUT from https://www.opengl.org/resources/libraries/glut/glut_downloads.php, unzip and copy the files as instructed below:
- glut.h 到文件夹 C:Program FilesMicrosoft SDKsWindowsv6.0AIncludegl
- glut32.lib 到文件夹 C:Program FilesMicrosoft SDKsWindowsv6.0ALib
- glut32.dll 到文件夹 C:WindowsSystem32
- glut.h to the folder C:Program FilesMicrosoft SDKsWindowsv6.0AIncludegl
- glut32.lib to the folder C:Program FilesMicrosoft SDKsWindowsv6.0ALib
- glut32.dll to the folder C:WindowsSystem32
2.- 创建一个空的 C++ Win32 应用程序:
2.- Create an empty C++ Win32 application:
- 从文件菜单中选择新建 → 项目 (Ctrl+Shift+N).
- 选择 Win32 项目,输入名称,然后单击确定.
- 在向导中单击下一步,然后选中空项目旁边的框,并点击完成.
3.- 添加一个新的 C++ 源文件:
3.- Add a new C++ source file:
- 在项目菜单下选择添加新项目 (Ctrl+Shift+A).
- 选择 C++ 文件 (.cpp),输入名称,然后单击确定.
4.- 链接到 OpenGL 库(重要步骤):
4.- Link to the OpenGL libraries (important step):
- 在项目"菜单下,选择底部的项目属性 (Alt+F7).
- 从左侧的导航面板中选择配置属性 → 链接器 → 输入.
- 从对话框顶部的配置下拉框中选择所有配置.这可确保您更改调试和发布配置的设置.
- 在附加依赖项中输入opengl32.lib glu32.lib glut32.lib"并点击确定(opengl32.lib和glu32.lib已经在系统中,glut32.lib将在之后下载 GLUT).
- 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.- 下载此示例代码.
6.- 还需要在 Visual Studio 中设置路径:
6.- It is also necessary to set the paths in Visual Studio:
在工具 -> 选项 -> VC++ 目录 -> 包含文件:
In Tools -> Options -> VC++ Directories -> Include Files:
C:Program FilesMicrosoft SDKsWindowsv6.0AInclude
C:Program FilesMicrosoft SDKsWindowsv6.0AInclude
在配置属性→链接器→附加库中目录:
In Configuration Properties → Linker → Additional Library Directories:
C:Program FilesMicrosoft SDKsWindowsv6.0ALib
C:Program FilesMicrosoft SDKsWindowsv6.0ALib
相关文章