Visual Studio C++ 2010 express 和 OpenGL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5055288/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 17:16:21  来源:igfitidea点击:

Visual Studio C++ 2010 express and OpenGL

c++visual-studio-2010visual-c++opengl

提问by Ron

I want to be able to compile OpenGL4.1 (C/C++) applications from VisualC++ 2010.

我希望能够从 VisualC++ 2010 编译 OpenGL4.1 (C/C++) 应用程序。

After doing a search I only found: http://www.opengl.org/sdk/and the documentation: (which is fine) http://www.opengl.org/sdk/docs/man4/

进行搜索后,我只找到了:http: //www.opengl.org/sdk/和文档:(很好) http://www.opengl.org/sdk/docs/man4/

Which is a bit confusing, and I really don't know what to install to get started. I can't even find a download link, or what OpenGL projects I should use.

这有点令人困惑,我真的不知道要安装什么才能开始。我什至找不到下载链接,或者我应该使用什么 OpenGL 项目。

回答by Alexander Rafferty

You don't need to download anything to use OpenGL. Just add

您无需下载任何内容即可使用 OpenGL。只需添加

#include <gl/GL.h>
#include <gl/GLU.h>

to the top of your source file. And you also need to link the libraries, which in MSVC can be done like this:

到源文件的顶部。并且您还需要链接库,在 MSVC 中可以这样做:

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

With the header files provided with microsoft, you are stuck with version 1.1 of ogl. I suggest getting the latest extension headers from the OpenGL website, as well as something like GLEW. This will give you access to the latest available functions and constants in OpenGL.

使用 microsoft 提供的头文件,您只能使用 ogl 1.1 版。我建议从 OpenGL 网站获取最新的扩展头文件,以及 GLEW 之类的东西。这将使您能够访问 OpenGL 中最新的可用函数和常量。

回答by Xzhsh

I believe the windows sdk includes opengl. Just include windows.h before including GL/gl.h

我相信 windows sdk 包括 opengl。在包含 GL/gl.h 之前只包含 windows.h

http://www.opengl.org/resources/faq/technical/gettingstarted.htm

http://www.opengl.org/resources/faq/technical/gettingstarted.htm

Search 2.070

搜索 2.070

回答by Divakar

For Windows you have to use the SDK form the manufacturer of your graphics card. For Nvidia SDK is available for free download, for registered users. The OpenGL SDK link that you have shown IMO is only the specification, just like how OpenGL is only the API specification.

对于 Windows,您必须使用来自显卡制造商的 SDK。对于 Nvidia SDK,注册用户可以免费下载。您向 IMO 展示的 OpenGL SDK 链接只是规范,就像 OpenGL 只是 API 规范一样。