我想将我使用的 OpenGL 版本从 3.2 更改为 3.3,以便我可以实现实例化渲染。目前我的 OpenGL 初始化代码如下所示。
ContextAttribs attribs = new ContextAttribs(3, 2).withForwardCompatible(true).withProfileCore(true);
所以我把它改成了...
ContextAttribs attribs = new ContextAttribs(3, 3).withForwardCompatible(true).withProfileCore(true);
唯一的区别是我放入 ContextAttribs() 的 OpenGL 版本。
我在 2013 款 MacBook Air 上运行此应用程序,根据 https://support.apple.com/en-us/HT202823,它的 OpenGL 功能最高可达 4.1|
创建显示后,我放置了以下代码
System.out.println("OpenGL version " + GL11.glGetString(GL11.GL_VERSION));
这让我可以检查我使用的是哪个版本的 OpenGL。这是棘手的部分。当我输入 ContextAttribs(3, 2) 时,它会打印出来
OpenGL version 4.1 INTEL-10.12.13
但是,如果我将其更改为 ContextAttribs(3, 3),我的应用程序会崩溃并打印出来
OpenGL version 2.1 INTEL-10.12.13
我不知道如何解决这个问题,如果有人可以,我将不胜感激。感谢您阅读本文。
最佳答案
看看 doc对于 LWJGL ContextAttribs 类。它指出:
However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an instance of this class must be passed to LWJGL. The only valid configuration is ContextAttribs(3, 2, CONTEXT_CORE_PROFILE_BIT_ARB), anything else will be ignored.
关于java - OpenGL 版本在 ContextAttribs() 值更改时更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35590378/