C++ Mac OSX 10.9 中的 Glut 弃用,IDE:QT Creator

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24095931/
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 00:38:08  来源:igfitidea点击:

Glut deprecation in Mac OSX 10.9, IDE: QT Creator

c++openglosx-mavericksglutdeprecation-warning

提问by Clueless Gorilla

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:

我试图在 qt creator 上构建一个 opengl 程序,安装在我的 mac 上,使用 osx 10.9。我收到了几个关于它在 osx10.9 中弃用的 glut 函数的警告,示例错误消息如下:

'glutInit' is deprecated: first deprecated in OS X 10.9 [-Wdeprecated-declarations] glutInit(&argc, &argv); ^

不推荐使用“glutInit”:首先在 OS X 10.9 中不推荐使用 [-Wdeprecated-declarations] glutInit(&argc, &argv); ^

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!

我想知道 GLUT.h 在 osx10.9 中是否不再可用?根据其他一些帖子,据说只要我们将“OS X 部署目标”改回 OSX10.8,它就可以工作。如何在 qtcreator 中这样做?谢谢!

回答by Reto Koradi

You can still use it in 10.9. They're sending you a pretty strong signal that they want you to stop, though...

您仍然可以在 10.9 中使用它。他们向你发出了一个非常强烈的信号,他们希望你停下来,尽管......

You can disable those warnings with the -Wno-deprecated-declarationscompiler option.

您可以使用-Wno-deprecated-declarations编译器选项禁用这些警告。

There's also some difficulties including the right headers if you're trying to use GL3 level features, because you need to include gl3.hfor that, while glut.hincludes gl.h, which causes additional complaints about possible conflicts while building. The somewhat hacky workaround I found for this is to prevent glut.hfrom including gl.hby defining the header guard:

如果您尝试使用 GL3 级别的功能,包括正确的标题也有一些困难,因为您需要为此包含gl3.h,而glut.h包含gl.h,这会导致关于构建时可能发生冲突的额外投诉。我为此找到的有点hacky的解决方法是通过定义标题保护来防止glut.h包含gl.h

#include <OpenGL/gl3.h>
#define __gl_h_
#include <GLUT/glut.h>

Then, for using GL3+ level features, you need to specify that with an additional flag to glutInitDisplayMode():

然后,为了使用 GL3+ 级别的功能,您需要使用一个额外的标志来指定glutInitDisplayMode()

glutInitDisplayMode(... | GLUT_3_2_CORE_PROFILE);

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.

看起来可能是时候开始使用 GLFW 了。我从来没有将 GLUT 用于任何严肃的事情,但它对于小型演示/测试总是非常方便。