When writing code for a fragment shader, it starts as follows:
#ifdef GL_ES
precision mediump float;
#endif
Why does the precision mediump float; line have to depend on whether GL_ES was defined or not?
When writing code for a fragment shader, it starts as follows:
#ifdef GL_ES
precision mediump float;
#endif
Why does the precision mediump float; line have to depend on whether GL_ES was defined or not?
It doesn't "have to"; it simply does.
Desktop GL will ignore any
precisiondeclarations. So there's no need toifdefaround it.That being said, if one wants to share GLSL code with very old versions of desktop GLSL (1.20 or before), then the
#ifdefis useful, as such versions did not allow theprecisiondeclaration.