我的代码中有很多警告,如下所示:
'glTranslatef'已经被弃用:在macOS 10.14中首次弃用 - OpenGL API已弃用。(定义GL_SILENCE_DEPRECATION可消除这些警告)
我已经使用了#define GL_SILENCE_DEPRECATION
,但这并没有解决问题。我使用的是通过brew install freeglut
安装的freeglut
我能以某种方式将其消除吗?
在OpenGL的头文件之前,应该加入#define GL_SILENCE_DEPRECATION
,这样您就可以像这样做:
#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
。
#define
放在哪里了?你必须在包含头文件之前放置它。 - Dietrich Epp