我的代码充满了警告,比如
'glTranslatef' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings)
我做了
#define GL_SILENCE_DEPRECATION
但这并没有解决问题。我用
freeglut
使用 brew install freeglut
安装的我可以以某种方式让它静音吗?
最佳答案
你应该把 #define GL_SILENCE_DEPRECATION
在 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
在编译阶段传递给编译器。
关于opengl - 在 macOS Mojave 上静音 OpenGL 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53562228/