Qt4 和 GLew 似乎彼此不兼容

发布于 2025-01-05 15:32:29 字数 727 浏览 5 评论 0原文

我正在尝试从 GLee 迁移到 glew,因为 GLee 不能在 VC2010 下工作,并且已经有一段时间没有更新了。我在使用头文件时遇到了问题,因为两个库都希望首先定义它们的头文件。 glew 不喜欢首先定义 gl.h(它在 QtOpenGL 中定义),并且 QtOpenGL 特别声明 glew 应该在 QtOpenGL 之后定义。

搜索显示很多人同时使用 glew 和 Qt 效果很好。至少,我想要一个关于兼容性的明确答案。我已将 .h 和 .c 文件添加到我的项目中,因为将来我不必再费力安装 .lib 和 .dll 文件。

这是 QtOpenGL 中的代码,如果首先包含 glew,则会调用该代码:

#ifdef __GLEW_H__
#warning qglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
#warning To use GLEW with Qt, do not include <QtOpenGL> or <QGLFunctions> after glew.h
#endif

下面是如果首先包含 QtOpenGL,则调用的代码:

#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)
#error gl.h included before glew.h
#endif

I'm trying to move from GLee to glew, because GLee doesn't work under VC2010 and hasn't been updated in a while. I'm having trouble with the header files, because the both libs want their header file defined first. glew doesn't like gl.h being defined first (which is defined in QtOpenGL), and QtOpenGL specifically states that glew should be defined after QtOpenGL.

Searching shows many people using both glew and Qt together just fine. At the very least, I'd like a definitive answer about the compatibility. I've added the .h and .c files to my project, because in future I won't have to mess around installing .lib and .dll files.

Here's the code in QtOpenGL that gets called if glew is included first:

#ifdef __GLEW_H__
#warning qglfunctions.h is not compatible with GLEW, GLEW defines will be undefined
#warning To use GLEW with Qt, do not include <QtOpenGL> or <QGLFunctions> after glew.h
#endif

And here's the code called if QtOpenGL is included first:

#if defined(__gl_h_) || defined(__GL_H__) || defined(__X_GL_H)
#error gl.h included before glew.h
#endif

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦初启 2025-01-12 15:32:29

GLEW 和 qtfunctions 都定义了相同的东西。您不能同时使用它们,也不应该这样做。您使用 Qt 的全部目的就是初始化 OpenGL 上下文。所以不要包含 qtfunctions。尝试只包含 QGLWidget 和该类需要的东西。

GLEW and qtfunctions all define the same things. You can't use them together, and you shouldn't want to. All you're using Qt for is to initialize the OpenGL context. So don't include qtfunctions. Try to include just QGLWidget and the stuff that class needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文