【问题标题】:Silencing OpenGL warnings on macOS Mojave在 macOS Mojave 上消除 OpenGL 警告
【发布时间】:2018-11-30 17:28:30
【问题描述】:

我的代码充满了像

这样的警告

'glTranslatef' 已弃用:首先在 macOS 10.14 - OpenGL 中弃用 API 已弃用。 (定义 GL_SILENCE_DEPRECATION 以使这些静音 警告)

我做了#define GL_SILENCE_DEPRECATION 但这并没有解决问题。 我使用通过brew install freeglut 安装的freeglut

我可以让它静音吗?

【问题讨论】:

  • 你把#define放在哪里了?你必须在包含头文件之前把它放好。
  • @DietrichEpp 它就在标题之后。现在已经修好了。谢谢!

标签: opengl freeglut


【解决方案1】:

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

【讨论】:

  • 按预期工作。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-03-27
  • 2020-07-16
  • 2019-06-22
  • 2019-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多