我试图在 qt creator 上构建一个 opengl 程序,安装在我的 mac 上,使用 osx 10.9.我收到了几个关于它在 osx10.9 中弃用的 glut 函数的警告,示例错误消息如下:
I was trying to build an opengl program on qt creator, installed on my mac, with osx 10.9. I got several warnings on glut functions about its deprecation in osx10.9, a sample error message is like:
'glutInit' 已弃用:首先在 OS X 10.9 中弃用 [-Wdeprecated-declarations]glutInit(&argc, &argv);^
'glutInit' is deprecated: first deprecated in OS X 10.9 [-Wdeprecated-declarations] glutInit(&argc, &argv); ^
我想知道 GLUT.h 在 osx10.9 中是否不再可用?根据其他一些帖子,据说只要我们将OS X 部署目标"更改回 OSX10.8,它就可以工作.如何在 qtcreator 中这样做?谢谢!
I wonder if GLUT.h is not usable anymore in osx10.9? According to some other posts, it is said that as long as we change "OS X Deployment Target" back to OSX10.8, then it works. How to do so in qtcreator? Thank you!
您仍然可以在 10.9 中使用它.他们向你发出了一个非常强烈的信号,他们希望你停下来……
You can still use it in 10.9. They're sending you a pretty strong signal that they want you to stop, though...
您可以使用 -Wno-deprecated-declarations
编译器选项禁用这些警告.
You can disable those warnings with the -Wno-deprecated-declarations
compiler option.
如果您尝试使用 GL3 级别的功能,包括正确的标题也有一些困难,因为您需要为此包含 gl3.h
,而 glut.h
> 包括 gl.h
,这会导致关于构建时可能发生冲突的额外投诉.我为此找到的有点hacky的解决方法是通过定义标题保护来防止glut.h
包含gl.h
:
There's also some difficulties including the right headers if you're trying to use GL3 level features, because you need to include gl3.h
for that, while glut.h
includes gl.h
, which causes additional complaints about possible conflicts while building. The somewhat hacky workaround I found for this is to prevent glut.h
from including gl.h
by defining the header guard:
#include <OpenGL/gl3.h>
#define __gl_h_
#include <GLUT/glut.h>
然后,为了使用 GL3+ 级别的功能,您需要在 glutInitDisplayMode()
中指定一个附加标志:
Then, for using GL3+ level features, you need to specify that with an additional flag to glutInitDisplayMode()
:
glutInitDisplayMode(... | GLUT_3_2_CORE_PROFILE);
看来是时候开始使用 GLFW 了.我从来没有将 GLUT 用于任何严肃的事情,但它对于小型演示/测试总是非常方便.
It looks like it's probably time to start using GLFW. I never used GLUT for anything serious, but it was always very convenient for small demos/tests.
这篇关于Mac OSX 10.9 中的 Glut 弃用,IDE:QT Creator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!