home/ atoms/ glsl-version-syntax-consistency

GLSL syntax must match the `#version` directive — mixing ES 1.00 and 3.00 syntax fails to compile

glslViewer accepts two main GLSL version families: legacy ES1.00/#version 100 (using texture2D, varying, gl_FragColor) and modern ES3.00+/#version 300 es (using texture, in/out, a declared fragColor). Mixing syntax across families — for example calling texture() under #version 100 — is a compile error. Pick one version and use only its corresponding syntax throughout the file.

Examples

// ES1.00 style: void main(){ gl_FragColor = texture2D(u_tex0, uv); } // ES3.00 style: #version 300 es out vec4 fragColor; void main(){ fragColor = texture(u_tex0, uv); }

Assessment

A shader has #version 100 at the top but uses texture(u_tex0, uv) and out vec4 fragColor. Identify the errors and rewrite the lines to be consistent with ES1.00.

“Syntax must match `#version`.** `texture2D`/`varying`/`gl_FragColor` are ES1.00/`110`; `texture`/ `in`/`out`/a declared `fragColor` are `300 es`/`130+`. Mixing them (e.g. `texture()` under `#version 100`) fails to compile.”
context/ · L1-instruments/glsl/gotchas.md · chunk 1