OpenGL 与 GLSL 版本

来自:https://github.com/mattdesl/lwjgl-basics/wiki/GLSL-Versions

You can use the#versioncommand as the first line of your shader to specify GLSL version:

() {gl_FragColor = vec4(1.0);}

GLSL versions are released alongside GL versions. See the following charts to decide which version you would like to target.

GLSL ES Versions (Android, iOS, WebGL)

OpenGL ES has its own Shading Language, and the versioning starts fresh. It is based on OpenGL Shading Language version 1.10.

OpenGL ES VersionGLSL ES Version

2.0100

3.0300

So, for example, if a feature is available in GLSL 120, it probably won’t be available in GLSL ES 100 unless the ES compiler specifically allows it.

Version 100

Vertex shader:

uniform mat4 projTrans;attribute vec2 Position;attribute vec2 TexCoord;varying vec2 vTexCoord;void main() {vTexCoord = TexCoord;gl_Position = u_projView * vec4(Position, 0.0, 1.0);}

Fragment shader:

uniform sampler2D tex0;varying vec2 vTexCoord;void main() {vec4 color = texture2D(tex0, vTexCoord);gl_FragColor = color;}

Version 330

texture2DprojTrans;layout(location = 0) in vec2 Position;layout(location = 1) in vec2 TexCoord;out vec2 vTexCoord;void main() {vTexCoord = TexCoord;gl_Position = u_projView * vec4(Position, 0, 1);}

,享受每一刻的感觉,欣赏每一处的风景,这就是人生。

OpenGL 与 GLSL 版本

相关文章:

你感兴趣的文章:

标签云: