GLSL ES requires a precision mediump float block at the top of every shader
OpenGL ES (the GPU API used by glslViewer in browser/mobile contexts) requires an explicit precision qualifier for float variables. Without it, the compiler produces ‘No precision specified for (float)’. The canonical fix is a guarded block at the top of the shader: #ifdef GL_ES\nprecision mediump float;\n#endif. The #ifdef guard makes the block harmless on desktop GL where precision is implicit. This block appears in the rig’s hello.frag template.
Examples
#ifdef GL_ES
precision mediump float;
#endif
Assessment
Write the guarded precision block required for GL ES and explain why the #ifdef guard is used rather than adding the declaration unconditionally.