LWJGL 3.1.6 OpenGL 4.1 crash on macOS High Sierra

送分小仙女□ 提交于 2020-12-13 04:49:49

问题


I have a slightly modified version of the sample code found on the main LWJGL page. It works but it uses legacy OpenGL version 2.1. If I attempt to use the forward-compatible context described in GLFW doc, the version used is 4.1 (no matter what major/minor I hint), the window is created, but it crashes on the first call to glPushMatrix().

Forward compatibility enabled like so:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

Some info I print in the console:

LWJGL 3.1.6 build 14
OS name Mac OS X
OS version 10.13.4
OpenGL version 4.1 ATI-1.66.31

Logging:

[LWJGL] A function that is not available in the current context was called.
Problematic frame:
C  [liblwjgl.dylib+0x1c494]

From here I don't know what to look for. Should this code be working? Or am I missing some ceremony? Many resources are outdated, making it harder to figure things out.


回答1:


glPushMatrix is a function for not Core Profile context, but for OpenGL < 3.2.

If you want to use it (and other pre-core features) you need a Compatibility context, not a Forward compatible one, not a Core profile either.

The GLFW hints should be like these, without asking for a Core Profile.

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);

Likely the driver will give the highest available version, but with all of old features too.



来源:https://stackoverflow.com/questions/49802367/lwjgl-3-1-6-opengl-4-1-crash-on-macos-high-sierra

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