opengl - 在 macOS Mojave 上静音 OpenGL 警告

标签 opengl freeglut

我的代码充满了警告,比如

'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/

相关文章:

c++ - 你如何检查鼠标是否在 freeglut 的三角形区域内单击?

c - 使用 OpenGL 构建菜单时 GLUT 的替代方案

c++ - Linux 中的 FreeGLUT 链接问题

c++ - 如何使用 gcc/g++ 在 Linux 上为 Windows 编译?

c++ - GLSL - 无法访问多个灯光的 SSBO 数组的第二个索引

java - 片段着色器无法编译

c - OpenGL翻译

c++ - 在 CLion 中使用 freeglut 在 OpenGL 中链接错误

c++ - 切换到 glVertexPointer 后未应用 Cg 着色器

python - 手动投影坐标类似于python中的gluLookAt