如何在Visual Studio 2012中安装GLUT和OpenGL?

问题描述:

我今天刚刚安装了Visual Studio 2012,我想知道如何在平台上安装GLUT和OpenGL?

I just installed Visual Studio 2012 today, and I was wondering how can you install GLUT and OpenGL on the platform?

OpenGL应该已经存在-可能是缺少的Freeglut/GLUT.

OpenGL should be present already - it will probably be Freeglut / GLUT that is missing.

GLUT现在已经过时,并且没有得到积极的支持-因此,您一定应该使用Freeglut.您完全不必更改代码,并且一些其他功能可用.

GLUT is very dated now and not actively supported - so you should certainly be using Freeglut instead. You won't have to change your code at all, and a few additional features become available.

您将在以下位置找到预先打包的文件集: http://freeglut.sourceforge.net/index.php#download 如果没有看到"lib"文件夹,那是因为您没有下载预打包的集. "Martin Payne的Windows二进制文件"发布在上面的链接上,在撰写本文时已在Windows 8.1和Visual Studio 2013上运行.

You'll find pre-packaged sets of files from here: http://freeglut.sourceforge.net/index.php#download If you don't see the "lib" folder, it's because you didn't download the pre-packaged set. "Martin Payne's Windows binaries" is posted at above link and works on Windows 8.1 with Visual Studio 2013 at the time of this writing.

下载这些文件时,您会发现Freeglut文件夹包含三个子文件夹: -bin文件夹:其中包含运行时的dll文件 -包括:用于编译的头文件 -lib:包含用于编译/链接的库文件

When you download these you'll find that the Freeglut folder has three subfolders: - bin folder: this contains the dll files for runtime - include: the header files for compilation - lib: contains library files for compilation/linking

安装说明通常建议将这些文件移动到Visual Studio文件夹和Windows系统文件夹中:最好避免这样做,因为这会使项目的可移植性降低,并且如果您需要更改哪个版本会更困难.您正在使用的库中的数据(旧项目可能突然停止工作,等等)

Installation instructions usually suggest moving these files into the visual studio folder and the Windows system folder: It is best to avoid doing this as it makes your project less portable, and makes it much more difficult if you ever need to change which version of the library you are using (old projects might suddenly stop working, etc.)

相反(对于任何不一致之处,我深表歉意,我将这些说明基于VS2010)... -将freeglut文件夹放在其他位置,例如C:\开发 -在Visual Studio中打开您的项目 -打开项目属性 -应该有一个 VC ++目录的标签,在这里您应该添加相应的include和lib文件夹,例如:C:\ dev \ freeglut \ include和C:\ dev \ freeglut \ lib -(几乎)最后一步是确保在编译过程中实际上链接了opengl lib文件.仍在项目属性中,展开链接器菜单,然后打开输入选项卡.对于其他依赖项,请添加opengl32.lib(您可以假设仅通过将include GL/gl.h添加到项目中就可以自动链接该链接,但是由于某些原因,这似乎不是情况)

Instead (apologies for any inconsistencies, I'm basing these instructions on VS2010)... - put the freeglut folder somewhere else, e.g. C:\dev - Open your project in Visual Studio - Open project properties - There should be a tab for VC++ Directories, here you should add the appropriate include and lib folders, e.g.: C:\dev\freeglut\include and C:\dev\freeglut\lib - (Almost) Final step is to ensure that the opengl lib file is actually linked during compilation. Still in project properties, expand the linker menu, and open the input tab. For Additional Dependencies add opengl32.lib (you would assume that this would be linked automatically just by adding the include GL/gl.h to your project, but for some reason this doesn't seem to be the case)

在此阶段,您的项目应编译确定.要实际运行它,您还需要将freeglut.dll文件复制到您的项目文件夹中

At this stage your project should compile OK. To actually run it, you also need to copy the freeglut.dll files into your project folder