java - OpenGL 版本在 ContextAttribs() 值更改时更改

标签 java c++ macos opengl

我想将我使用的 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/

相关文章:

java - 使用 Java 8 Streams 将 List<Object> 转换为 Map<String, Integer> 使得 String 不是重复值

java - AssertJ:使用 String.format 生成的消息测试异常

java - 不同测试 JUNIT 的不同参数化参数

c++ - 拖放移动后获取新旧 QStandardItem

c++ - 如何使用 CredUIPromptForWindowsCredentials 验证凭据

c++ - OpenGL 相机俯仰、偏航和滚动旋转

swift - "advanceToNextItem()"不允许循环播放所有视频

macos - 是否有任何适用于 Mac OSX 的 Git 便携版本?

macos - OSX 的 Mach-O 二进制编辑器?

java - 在html中使用spring标签