在macOS莫哈韦上关闭OpenGL警告

xlpyo6sf  于 2023-08-04  发布在  Mac
关注(0)|答案(1)|浏览(216)

我的代码充满了警告,比如
“glTranslatef”已弃用:在macOS 10.14中首次弃用- OpenGL API弃用。(定义GL_SILENCE_DEPRECATION以使这些警告静音)
我做了#define GL_SILENCE_DEPRECATION,但这并没有解决这个问题。我使用的freeglut是使用brew install freeglut安装的
我能让它安静下来吗?

ar5n3qh5

ar5n3qh51#

#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传递给编译器。

相关问题