10.9以上的MacOS系统OpenGL有了新的API来替代以前的GLUT库,以前的GLUT库里不少函数被标记为了deprecated,即将废弃的,可是考虑兼容性,当前系统版本仍是支持的。macos
下面介绍如何消除这些警告提示。bash
报错以下:app
'glTranslatef' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings)
根据报错咱们定义GL_SILENCE_DEPRECATION
:ide
#define GL_SILENCE_DEPRECATION
可是警告并无消失,缘由是咱们必须吧该语句放在include
OpenGL文件以前:函数
#ifdef __APPLE__ /* Defined before OpenGL and GLUT includes to avoid deprecation messages */ #define GL_SILENCE_DEPRECATION #include <OpenGL/gl.h> #include <GLUT/glut.h> #else #include <GL/gl.h> #include <GL/glut.h> #endif
另一个方法是在编译阶段传递-Wno-deprecated-declarations
选项给编译器。spa
此外还有一个警告是没法删除的:.net
OpenGl is deprecated.Consider migrating to Metal instead
这个就是提示如今GLUT已经弃用,能够转向使用Metal,相关转换教程可参考https://www.raywenderlich.com/9211-moving-from-opengl-to-metal。code
参考:
https://stackoverflow.com/questions/53562228/silencing-opengl-warnings-on-macos-mojave
blog
https://blog.csdn.net/oktears/article/details/42214519?utm_source=app教程