[require] GLSL >= 1.10 [vertex shader] uniform int index; varying vec4 m[2]; void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; m[0].xy = vec2(1.0, 1.1); m[1].xy = vec2(2.0, 2.1); m[0].zw = vec2(5.0, 5.1); m[1].zw = vec2(6.0, 6.1); if (index >= 2) m[index-2].zw = vec2(0.0, 0.1); else m[index].xy = vec2(0.0, 0.1); } [fragment shader] uniform int index; varying vec4 m[2]; void main() { bool pass = true; for (int i = 0; i < 2; i++) pass = pass && m[i].xy == (index == i ? vec2(0.0, 0.1) : vec2(1.0, 1.1) + vec2(i)); for (int i = 0; i < 2; i++) pass = pass && m[i].zw == (index == 2+i ? vec2(0.0, 0.1) : vec2(5.0, 5.1) + vec2(i)); gl_FragColor = pass ? vec4(0.0, 1.0, 0.0, 1.0) : vec4(1.0, 0.0, 0.0, 1.0); } [test] clear color 0.5 0.5 0.5 0.5 clear ortho uniform int index 0 draw rect 5 5 10 10 probe rgb 10 10 0.0 1.0 0.0 uniform int index 1 draw rect 30 5 10 10 probe rgb 35 10 0.0 1.0 0.0 uniform int index 2 draw rect 55 5 10 10 probe rgb 60 10 0.0 1.0 0.0 uniform int index 3 draw rect 80 5 10 10 probe rgb 85 10 0.0 1.0 0.0