GLFW 打开 OpenGL 3.2 上下文,但 Freeglut 不能 - 为什么?

2024-01-01

我正在 Mac 上工作,我已经编译并安装了 FreeGlut,但我似乎无法使用它获取 OpenGL 3.2 上下文。不过,我在使用 GLFW 时可以毫无问题地获取它。 所以在 GLFW 中,这段代码工作得很好:

    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
    glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);
    glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
    glfwOpenWindow(500, 500, 8, 8, 8, 8, 24, 8, GLFW_WINDOW)

但是对于 FreeGlut,这段代码失败了(在glutCreateWindow):

glutInitContextVersion (3, 2);
glutInitContextProfile(GLUT_CORE_PROFILE);  
glutInitWindowSize (width, height); 
glutInitWindowPosition (300, 200);
int window = glutCreateWindow (argv[0]);

它失败的错误是:

X Error of failed request:  BadRequest (invalid request code or no such operation)
  Major opcode of failed request:  34 (X_UngrabKey)
  Serial number of failed request:  29
  Current serial number in output stream:  29

我正在 MacOS X 10.8 Mountain Lion 上运行,配有 Intel HD4000 显卡,安装了 XQuartz 作为我的 X11 服务器,并从源代码编译并安装了 FreeGlut 2.8。

有谁知道可能是什么问题?


在 10.8 和 10.7 中,如果您在设置 GL 上下文时明确调用 GL 3.2,则可以使用它。 Apple 将此称为“Core Profile”,以区别于“Legacy Profile”(即 GL 2.1)。

我在 OSX 上使用 Wine 时遇到了这个问题,它不支持 OpenGL 3.2。我的理解是,X11服务器(Apple X11或XQuartz)目前没有实现3.2支持,也没有开关可以翻转某处来启用它。这可能是出于兼容性问题,因为 3.2 配置文件会破坏一些现有总帐应用程序 https://developer.apple.com/library/mac/#documentation/graphicsimaging/conceptual/OpenGL-MacProgGuide/UpdatinganApplicationtoSupportOpenGL3/UpdatinganApplicationtoSupportOpenGL3.html#//apple_ref/doc/uid/TP40001987-CH3-SW1

这篇文章建议 https://stackoverflow.com/questions/11259328/glut-on-os-x-with-opengl-3-2-core-profile使用GLFW(或者Apple的GLUT.framework,如果仍然有这样的东西)

这一页 http://www.geeks3d.com/20121109/overview-of-opengl-support-on-os-x/解释了 OSX 上的 GL 堆栈并确认了 GLX 的 2.1 问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GLFW 打开 OpenGL 3.2 上下文,但 Freeglut 不能 - 为什么? 的相关文章

随机推荐