opengl - 获取支持的 GLSL 版本

标签 opengl opengl-es opengl-es-2.0

在使用英特尔显卡的笔记本电脑上开发时,在编译顶点着色器时,我得到了这个:

0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

好的,所以我调整着色器以使用版本 300 ES。
同时,我想检查当前驱动程序/卡支持的 GLSL 版本,所以我使用这个:
glGetString ( GL_SHADING_LANGUAGE_VERSION )

令我沮丧的是,它只返回“1.30”。

我怎样才能得到完整的 list ?或者即使它不是完整列表,我怎样才能获得标准 GL 支持的版本和 GLES 支持的版本?

最佳答案

在桌面 GL 中,GL 版本与 GLSL 版本的对应关系如下:

GL version                     GLSL version
2.0                            1.10
2.1                            1.20
3.0                            1.30
3.1                            1.40
3.2                            1.50
3.3                            3.30
4.0                            4.00
4.1                            4.10
4.2                            4.20
4.3                            4.30
4.4                            4.40
4.5                            4.50
...

因此,从 GL 3.3 开始,版本号被“同步”以使生活更轻松。另请注意,没有明确的 1.00 版本。当着色器被开发为 GL 1.x 的扩展时,这是可用的。然而,这从来都不是 OpenGL 的核心特性,所以这里的版本从 1.10 开始(如果你的着色器中没有 #version 指令,这也是默认的)。如果您要求 #version 100 ,您将获得 GLSL 1.00 ES。

请注意,除了需要支持列出的 GLSL 版本外,还需要 GL 实现来支持旧版本。例如,在 OpenGL 4.5 core profile specification ,陈述如下(强调我的):

OpenGL 4.5 implementations are guaranteed to support version 4.50 of the OpenGL Shading Language. All references to sections of that specification refer to that version. The latest supported version of the shading language may be queried as described in section 22.2. The core profile of OpenGL 4.5 is also guaranteed to support all previous versions of the OpenGL Shading Language back to version 1.40. In some implementations the core profile may also support earlier versions of the Shading Language, and may support compatibility profile versions of the Shading Language for versions 1.40 and earlier. In this case, errors will be generated when using language features such as compatibility profile built-ins not supported by the core profile API.



对于 OpenGL ES,类似的事情适用:
GLES version                  GLSL version
2.0                            1.00 ES
3.0                            3.00 ES
3.1                            3.10 ES

GLES 3.1 spec陈述

OpenGL ES 3.1 implementations are guaranteed to support versions 3.10, 3.00 and 1.00 of the OpenGL ES Shading Language.



现在您可能仍想知道您可以在桌面 GL 中使用哪些 GLSL ES 版本。因此,对于现代 GL,这非常简单。再次引用 GL 4.5 规范:

OpenGL 4.5 implementations are guaranteed to support versions 1.00, 3.00, and 3.10 of the OpenGL ES Shading Language.



对桌面 GL 中特定于 GLES 的功能的支持(如 GLSL 的 ES 变体)通常通过“兼容性”扩展处理:
  • GL_ARB_ES2_compatibility , 自 GL 4.1
  • 起为核心
  • GL_ARB_ES3_compatibility , 自 GL 4.3
  • 起为核心
  • GL_ARB_ES3_1_compatibility , 自 GL 4.5
  • 起为核心

    现在你的实现可能只提供 GL 3.0 并且仍然支持 ES 兼容性扩展。

    从 GL 4.3 开始,您可以通过 glGetStringi(GL_SHADING_LANGUAGE_VERSION,...) 查询所有支持的 GLSL 版本列表。 .对于之前的版本,您必须检查 GL 版本号和扩展字符串以推断保证支持哪些版本(但实现可能仍支持更多)。

    关于opengl - 获取支持的 GLSL 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27407774/

    相关文章:

    iphone - openGL ES 2.0 中 ios 的图像处理过滤器

    go - 最小 Go OpenGL 程序段错误

    c++ - Assimp 面孔指数

    c++ - 位图文件图像数据偏移产生不同图像

    iphone - 如何在 iPhone 上实现 AABB 光线转换命中检查

    android - 顶点属性未传递给着色器

    opengl-es-2.0 - 在 Scenekit 中的透明地板/平面上显示阴影

    python - 从位图字体图像中提取字形数据的工具

    android - 页面 curl 时出现奇怪的闪电

    ios - GPUImage示例不起作用