Game Development Reference
In-Depth Information
2.
And the other pair of shaders is for GLSL ES 1.0:
// vertex shader
#version 100
precision highp float;
uniform mat4 in_ModelViewProjectionMatrix;
attribute vec4 in_Vertex;
attribute vec2 in_TexCoord;
varying vec2 Coords;
void main()
{
Coords = in_TexCoord;
gl_Position = in_ModelViewProjectionMatrix * in_Vertex;
}
// fragment shader
#version 100
precision highp float;
uniform sampler2D Texture0;
varying vec2 Coords;
void main()
{
gl_FragColor = texture2D( Texture0, Coords );
}
The following table is the summary of some differences between three versions of
OpenGL API, which need abstracting:
OpenGL 3
OpenGL ES 2
OpenGL ES 3
Version definition
#version 150 core
#version 100
#version 300 es
Explicit floats
precision
not required
required
not required
Keywords for varyings
and attributes
in and out
varying and attribute
in and out
Fixed-function
fragment data
location
no, customizable
gl_FragColor
no, customizable
2D texture fetching
texture(), overloaded
texture2D()
texture(), overloaded
3.
Let's implement conversion rules in the following code to downgrade GLSL 1.50
shaders to GLSL 1.0:
#if defined( USE_OPENGL_3 )
 
Search WWH ::




Custom Search