【问题标题】:OpenGL version changes when ContextAttribs() value is changed更改 ContextAttribs() 值时 OpenGL 版本更改
【发布时间】:2016-02-23 23:30:30
【问题描述】:

我想将我使用的 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 版本。

根据https://support.apple.com/en-us/HT202823,我在 2013 年 MacBook Air 上运行此应用程序,它的 OpenGL 功能高达 4.1

创建显示后,我放置了以下代码

System.out.println("OpenGL version " + GL11.glGetString(GL11.GL_VERSION));

这让我可以检查我使用的是哪个版本的 OpenGL。这是棘手的部分。当我把 ContextAttribs(3, 2) 打印出来

OpenGL 4.1 版 INTEL-10.12.13

但是,如果我将其更改为 ContextAttribs(3, 3),我的应用程序会崩溃并打印出来

OpenGL 2.1 版 INTEL-10.12.13

我不知道如何解决这个问题,如果有人可以的话,将不胜感激。感谢您阅读本文。

【问题讨论】:

    标签: java c++ macos opengl


    【解决方案1】:

    查看 LWJGL ContextAttribs 类的 doc。它指出:

    但是,为了在 MacOS X 10.7 或更高版本上启用 GL 3.2 上下文,必须将此类的实例传递给 LWJGL。唯一有效的配置是 ContextAttribs(3, 2, CONTEXT_CORE_PROFILE_BIT_ARB),其他的都将被忽略。

    【讨论】:

    • 如果我将其更改为 OpenGL 3.3,即使它设置为 3.2,我也可以使用它吗?感谢您的回复!@nasser
    猜你喜欢
    • 2023-03-11
    • 2018-01-17
    • 2014-02-04
    • 2010-09-20
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-07
    相关资源
    最近更新 更多