I try to compile this shader:
varying vec2 TexCoords;
varying vec4 color;
uniform sampler2D text;
uniform vec3 textColor;
void main()
{
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
color = vec4(textColor, 1.0) * sampled;
}
This is for OpenGL es. The errors which I get:
ERROR: 0:2: 'vec2' : No precision defined for this type
ERROR: 0:3: 'vec4' : No precision defined for this type
ERROR: 0:6: 'vec3' : No precision defined for this type
ERROR: 0:10: 'texture' : undeclared identifier
ERROR: 0:10: invalid function call
Note that it compiles on OpenGL 3.3, but fails on es.
See OpenGL ES Shading Language 1.00 Specification - 4.5.3 Default Precision Qualifiers:
The fragment language has no default precision qualifier for floating point types. Hence for float, floating point vector and matrix variable declarations, either the declaration must include a precision qualifier or the default float precision must have been previously declared.
Therefore you must add a precision qualifiere. e.g:
precision mediump float;
The overloaded functional texture
was introduced in GLSL ES 3.00, but it is not supported in GLSL ES 1.00. You have to use the function texture2D
:
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
vec4 sampled = vec4(1.0, 1.0, 1.0, texture2D(text, TexCoords).r);