glutInitContextVersion() is missing from glut library

牧云@^-^@ 提交于 2019-12-05 10:57:21

GLUT development ended many years ago and that is actually a non-standard extension (added in FreeGLUT). OS X ships with its own implementation of standard GLUT (3.x). Though since you mention OS X 10.9 in your question, it is worth pointing out that the compiler is going to generate all sorts of annoying deprecation warnings if you try to use it.

If you want to get a 3.2 core context on OS X using the Frameworks that ship with it, you will have to use CGL (C) or NSOpenGL (Objective C).

If you insist on using GLUT, you will need to find a port of FreeGLUT for OS X instead of the Framework that ships with the platform. This of course means tracking down additional dependencies, but I don't think that will be that big a deal. Just remember to stop including the GLUT headers that ship with Xcode.

Reto Koradi

You can create a 3.2+ core profile context with the GLUT that comes with the Xcode version for OS X 10.9. You just have to use a different interface. Instead of calling glutInitContextVersion(), you need to add the GLUT_3_2_CORE_PROFILE flag to the glutInitDisplayMode() call:

glutInitDisplayMode(... | GLUT_3_2_CORE_PROFILE);

You will also need to include <OpenGL/gl3.h> before <GLUT/glut.h> to use GL3 and later features.

The whole thing will generate a bunch of compiler warnings since GLUT is marked as deprecated in OS X 10.9. My answer to a related questions contains instructions on how to disable those warnings: Glut deprecation in Mac OSX 10.9, IDE: QT Creator.

I had a similar problem, and I didn't #include <GL/freeglut.h>. "glutInitContextVersion()" is a new function added by freeglut, so you need to include freeglut in addition to glut.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!