10.9以上的MacOS系統OpenGL有了新的API來替代之前的GLUT庫,之前的GLUT庫里很多函式被標記為了deprecated,即將廢棄的,但是考慮兼容性,當前系統版本還是支持的,
下面介紹如何消除這些警告提示,
報錯如下:
'glTranslatef' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define GL_SILENCE_DEPRECATION to silence these warnings)
根據報錯我們定義GL_SILENCE_DEPRECATION:
#define GL_SILENCE_DEPRECATION
但是警告并沒有消失,原因是我們必須吧該陳述句放在includeOpenGL檔案之前:
#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 is deprecated.Consider migrating to Metal instead
這個就是提示現在GLUT已經棄用,可以轉向使用Metal,相關轉換教程可參考https://www.raywenderlich.com/9211-moving-from-opengl-to-metal,
參考:
https://stackoverflow.com/questions/53562228/silencing-opengl-warnings-on-macos-mojave
https://blog.csdn.net/oktears/article/details/42214519?utm_source=app
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/131856.html
標籤:其他
