获取受支持的GLSL版本 [英] Get supported GLSL versions

查看:444
本文介绍了获取受支持的GLSL版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用具有英特尔图形卡的笔记本电脑上进行开发时,同时编译了顶点着色器,我得到了:

While developing on a laptop with an intel graphics card, while compiling a vertex shader, i got this:

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版本,所以我使用以下方法:

ok, so i adapt the shader to use version 300 ES. Meanwhile, i want to check what GLSL versions the current driver/card supports, so i use this:

glGetString ( GL_SHADING_LANGUAGE_VERSION )

令我沮丧的是,它仅返回"1.30".

Which, to my dismay, returns only "1.30".

如何获取完整列表?或者,即使它不是完整列表,我如何获得标准的GL支持版本和GLES支持的版本?

How can i get the full list? Or even if it's not the full list, how can i get standard GL supported versions, and GLES supported versions ?

推荐答案

在桌面GL中,GL版本和GLSL版本之间的映射如下:

In desktop GL, the mapping between the GL version and the GLSL version is as follows:

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 .

So, beginning with GL 3.3, the version numbers are "synced" to make life easier. Also note that there is no explicit version 1.00. That was available when shaders were developed as an extension to GL 1.x. However, that was never a core feature of OpenGL, so the version starts at 1.10 here (which is also the default if you don't have a #version directive in your shader). If you request #version 100, you'll get GLSL 1.00 ES.

请注意,除了要求支持列出的GLSL版本外,还要求GL实现支持较早的版本.例如,在 OpenGL 4.5核心配置文件规范中,以下内容是说(强调我的):

Note that besides being required to support the listed GLSL versions, GL implementations are also required to support older versions. For example, in the OpenGL 4.5 core profile specification, the following is stated (emphasis mine):

OpenGL 4.5实现保证支持版本4.50 OpenGL着色语言.对该部分的所有引用 规格参考该版本.最新的受支持版本 如第22.2节所述,可以查询阴影语言. OpenGL 4.5的核心配置文件也保证支持所有以前的版本 版本的OpenGL阴影语言可以回到1.40.在某些情况下 核心配置文件的实现可能还支持更早版本的 着色语言,并且可能支持兼容性配置文件版本 版本的着色语言 1.40及更早版本.在这种情况下,如果使用语言功能(例如不兼容的兼容性配置文件)会产生错误. 核心配置文件API支持.

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,类似的情况适用:

For OpenGL ES, similiar things apply:

GLES version                  GLSL version
2.0                            1.00 ES
3.0                            3.00 ES
3.1                            3.10 ES

GLES 3.1规范指出

OpenGL ES 3.1实现保证支持版本3.10, OpenGL ES着色语言的3.00和1.00.

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规范:

Now you might still want to know which GLSL ES versions you can use in desktop GL. So, for modern GL, this is quite simple. To quote the GL 4.5 spec again:

OpenGL 4.5实现保证支持1.00版本, OpenGL ES着色语言3.00和3.10.

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变体)通常通过兼容性"扩展来处理:

Support for features which are specific to GLES in desktop GL (like the ES variants of GLSL) are generally handled via "compatibility" extensions:

现在,您的实现可能仅提供GL 3.0,并且仍支持ES兼容性扩展.

Now your implementation might only provide GL 3.0 and still support the ES compatibility extensions.

从GL 4.3开始,您可以通过

Since GL 4.3, you can simply query the list of all of the supported GLSL versions via glGetStringi(GL_SHADING_LANGUAGE_VERSION,...). For versions prior to that, you have to check the GL version number and the extension string(s) to deduce which versions are guaranteed to be supported (but the implementation might still support more).

这篇关于获取受支持的GLSL版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆