Game Development Reference
In-Depth Information
OpenGL ES 3 has backwards-compatible support for OpenGL ES
Shading Language 1.0. For this purpose, we put #version 100 at
the beginning of our shaders. However, if your application targets only
the most recent OpenGL ES 3, you can use the marker #version
300 es and avoid some conversions. Refer to the speciication of
OpenGL ES Shading Language 3.0 for more details at http://
www.khronos.org/registry/gles/specs/3.0/GLSL_ES_
Specification_3.00.4.pdf .
Getting ready
Speciications of different GLSL language versions can be downloaded from the oficial
OpenGL website at http://www.opengl.org . The GLSL 1.50 speciication is found
at http://www.opengl.org/registry/doc/GLSLangSpec.1.50.09.pdf .
Speciications for GLSL ES can be downloaded from the Khronos website at
http://www.khronos.org . The GLSL ES 1.0 speciication is available at
http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_
Specification_1.0.17.pdf .
How to do it…
1.
Let's take a look at two sets of simple vertex and fragment shaders. The one
for GLSL 1.50 is:
// vertex shader
#version 150 core
uniform mat4 in_ModelViewProjectionMatrix;
in vec4 in_Vertex;
in vec2 in_TexCoord;
out vec2 Coords;
void main()
{
Coords = in_TexCoord;
gl_Position = in_ModelViewProjectionMatrix * in_Vertex;
}
// fragment shader
#version 150 core
in vec2 Coords;
uniform sampler2D Texture0;
out vec4 out_FragColor;
void main()
{
out_FragColor = texture( Sampler0, Coords );
}
 
Search WWH ::




Custom Search