OpenGL文件glew.h和gl.h/glu.h之间的区别 [英] Difference between OpenGL files glew.h and gl.h/glu.h

查看:1033
本文介绍了OpenGL文件glew.h和gl.h/glu.h之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Windows 7专业版中默认包含的glu和gl头文件构建了一个OpenGL程序.现在,我已经买了一本描述OpenGL游戏开发的书.本书的作者说,我必须在项目中包含glew标头.完成此操作后,我遇到了一些未解决的外部符号错误.

I've built an OpenGL program with my glu and gl header files default included in windows 7 professional edition. Now, I've bought a book that describes OpenGL game development. The author of this book said, I have to include the glew header into my project. After I've done this I got some unresolved external symbol errors.

所以,现在我真的很困惑. 我之前在程序中使用过glBegin和glEnd语句.现在,我必须使用glBindBuffers和glGenBuffer等,但是会出现无法解决的外部符号错误,如下所示:

So, now I'm really confused. I've worked earlier with glBegin and glEnd statements in my program. Now I've to work with glBindBuffers and glGenBuffer etcetera, but I get the unresolved external symbol errors, like that:

1>cWindows.obj : error LNK2001: unresolved external symbol __imp___glewBindBuffer
1>cMdlLoader.obj : error LNK2001: unresolved external symbol __imp___glewBindBuffer
1>cMdlLoader.obj : error LNK2001: unresolved external symbol __imp___glewBufferData
1>cMdlLoader.obj : error LNK2001: unresolved external symbol __imp___glewGenBuffers

这里有人可以解释这些头文件与我之间的区别吗?

Is there anyone here who can explain the difference between these header files and what I have to do with them?

我打了很多遍,但是在不同的站点上有更多令人困惑的单词,例如"glee"或"glut".

I goggled many times, but on different sites there are much more confusing words like "glee" or "glut".

推荐答案

您在这里混合了3种不同的东西:

You're mixing up 3 different things here:

  1. OpenGL
  2. 不属于OpenGL的GL实用程序(GLU)
  3. 和GL扩展牧马人(GLEW)

GLEW和GLU是完全不同的事物,您不能用另一种替代.

GLEW and GLU are completely different things and you can not replace one with another.

GL/gl.h是基本的OpenGL标头,可为您提供OpenGL-1.1函数和令牌声明,甚至更多.对于超过1.1版的任何内容,您都必须使用OpenGL扩展机制.由于这是一项枯燥而乏味的任务,因此GLEW项目已将其自动化,该项目将所有肮脏的细节打包在一个易于使用的库中.该库的声明位于头文件GL/glew.h中.由于没有基本的OpenGL,Op​​enGL扩展就没有意义,因此GLEW标头隐含了常规的OpenGL标头,因此在包含GL/glew.h时,您不再需要包含GL/gl.h.

GL/gl.h are the base OpenGL headers, which give you OpenGL-1.1 function and token declarations, any maybe more. For anything going beyond version 1.1 you must use the OpenGL extension mechanism. Since this is a boring and tedious task, that has been automatized by the GLEW project, which offer all the dirty details packed up in a easy to use library. The declarations of this library are found in the header file GL/glew.h. Since OpenGL extensions don't make sense without basic OpenGL, the GLEW header implicitly includes the regular OpenGL header, so as of including GL/glew.h you no longer need to include GL/gl.h.

然后是GLU,这是一组便捷方法,但BTW严重过时了,不应在任何现代OpenGL程序中使用.没有现代的GLU,所以就算了吧.无论如何,它的声明可以通过标头GL/glu.h(您要询问的标头)获得.

Then there's GLU, a set of convenience methods, which BTW are seriously outdated and should not be used in any modern OpenGL program. There's no modern GLU, so just forget about it. Anyway, it's declarations are made available by the header GL/glu.h (the one you were asking about).

您得到的错误与包含文件无关.这些是链接器错误.仅包括声明只是工作的一半.另一半是链接实际的 definitions ,而这些不在库文件的头文件中.在* nix操作系统上为libglew.solibglew.a,在Windows上为glew.libglew32.libglews.libglew32s.lib.如果不使用静态版本(不带"s"的版本),则还必须安装正确的DLL.

The errors you get have nothing to do with include files though. Those are linker errors. Just including the declarations is only half of the job. The other half is linking the actual definitions and those are not in the header by the library file; libglew.so or libglew.a on a *nix OS, glew.lib or glew32.lib or glews.lib or glew32s.lib on Windows. If not using the static versions (those without the 's') you also must have installed the right DLL.

因此,要使用GLEW,您需要包括标题并将添加到链接器选项中的库列表中.此外,一旦在程序中获得了OpenGL上下文,就必须调用glewInit();.

So to use GLEW you need to include the header and add it to the list of libraries in the linker options. Also you must call glewInit(); once you've obtained a OpenGL context in your program.

这篇关于OpenGL文件glew.h和gl.h/glu.h之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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