背景
Opengl ES code 移植到QT平台, QT 版本是5.13.1, GLSL代码直接移植,但是必须说明版本,否则编译shader不过。
shader中添加GLSL版本信息:
const char *sVertexShader =
"#version 100\n"
"precision mediump float;\n"
...
添加:
“#version 100\n”
或者
“#version 330 core\n”
都可以,原因待查。
调研资料
OpenGL ES对应的GLSL版本
GLSL versions have evolved alongside specific versions of the OpenGL API. It is only with OpenGL versions 3.3 and above that the GLSL and OpenGL major and minor version numbers match. These versions for GLSL and OpenGL are related in the following table:
GLSL Version | OpenGL Version | Date | Shader Preprocessor |
---|---|---|---|
1.10.59 | 2.0 | 30 April 2004 | #version 110 |
1.20.8 | 2.1 | 07 September 2006 | #version 120 |
1.30.10 | 3.0 | 22 November 2009 | #version 130 |
1.40.08 | 3.1 | 22 November 2009 | #version 140 |
1.50.11 | 3.2 | 04 December 2009 | #version 150 |
3.30.6 | 3.3 | 11 March 2010 | #version 330 |
4.00.9 | 4.0 | 24 July 2010 | #version 400 |
4.10.6 | 4.1 | 24 July 2010 | #version 410 |
4.20.11 | 4.2 | 12 December 2011 | #version 420 |
4.30.8 | 4.3 | 7 February 2013 | #version 430 |
4.40.9 | 4.4 | 16 June 2014 | #version 440 |
4.50.7 | 4.5 | 09 May 2017 #version 450 | |
4.60.5 | 4.6 | 14 June 2018 | #version 460 |
OpenGL ES and WebGL use OpenGL ES Shading Language (abbreviated: GLSL ES).
GLSL ES version | OpenGL ES version | WebGL version | Based on GLSL version | Date | Shader Preprocessor |
---|---|---|---|---|---|
1.00.17 | 2.0 | 1.0 | 1.20 | 12 May 2009 | #version 100 |
3.00.6 | 3.0 | 2.0 | 3.30 | 29 January 2016 | #version 300 es |
This list is incomplete; you can help by expanding it.
OpenGL and GLSL versions
Every OpenGL version since 2.0 has been released with a corresponding GLSL version. However, the GLSL version numbers were not always in sync with the GL version. Here is a table:
OpenGL Version | GLSL Version |
---|---|
2.0 | 1.10 |
2.1 | 1.20 |
3.0 | 1.30 |
3.1 | 1.40 |
3.2 | 1.50 |
For all versions of OpenGL 3.3 and above, the corresponding GLSL version matches the OpenGL version. So GL 4.1 uses GLSL 4.10.
What are the differences between #version 330 and #version 330 core ?
Those two version declarations are equivalent. core is the default. From the GLSL 3.30 spec:
If no profile argument is provided, the default is core.
Which means that:
#version 330
is the same as:
#version 330 core
If you want to use the compatibility profile, you need to specify that explicitly with:
#version 330 compatibility
查询GLSL版本方法
Shading language version
The primary version of GLSL supported by the implementation can be queried:
glGetString(GL_SHADING_LANGUAGE_VERSION);
This Wiki page will note the differences between GLSL and C.
https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)