1# Test accessing glTexCoordIn without redeclaration but with constant indices. 2# 3# From the ARB_geometry_shader4 spec (section ): 4# "Indices used to subscript gl_TexCoord must either be an integral constant 5# expressions, or this array must be re-declared by the shader with a size." 6[require] 7GL >= 2.0 8GLSL >= 1.10 9GL_ARB_geometry_shader4 10 11[vertex shader] 12#version 110 13 14attribute vec4 vertex; 15attribute float offset; 16 17varying float gs_offset; 18 19void main() 20{ 21 gl_TexCoord[0] = vec4(offset + float(0)); 22 gl_TexCoord[1] = vec4(offset + float(1)); 23 gl_TexCoord[2] = vec4(offset + float(2)); 24 gs_offset = offset; 25 gl_Position = vertex; 26} 27 28[geometry shader] 29#version 110 30#extension GL_ARB_geometry_shader4: enable 31 32varying in float gs_offset[]; 33 34varying out float fs_ok; 35 36void main() 37{ 38 bool ok = true; 39 40 if (gl_TexCoordIn[0][0] != vec4(gs_offset[0] + float(0))) 41 ok = false; 42 if (gl_TexCoordIn[0][1] != vec4(gs_offset[0] + float(1))) 43 ok = false; 44 if (gl_TexCoordIn[1][0] != vec4(gs_offset[1] + float(0))) 45 ok = false; 46 if (gl_TexCoordIn[1][1] != vec4(gs_offset[1] + float(1))) 47 ok = false; 48 if (gl_TexCoordIn[2][0] != vec4(gs_offset[2] + float(0))) 49 ok = false; 50 if (gl_TexCoordIn[2][1] != vec4(gs_offset[2] + float(1))) 51 ok = false; 52 53 for (int i = 0; i < 3; ++i) { 54 fs_ok = float(ok); 55 gl_Position = gl_PositionIn[i]; 56 EmitVertex(); 57 } 58} 59 60[geometry layout] 61input type GL_TRIANGLES 62output type GL_TRIANGLE_STRIP 63vertices out 3 64 65[fragment shader] 66#version 110 67 68varying float fs_ok; 69 70void main() 71{ 72 if (distance(fs_ok, 1.0) < 1e-6) 73 gl_FragColor = vec4(0, 1, 0, 1); 74 else 75 gl_FragColor = vec4(1, 0, 0, 1); 76} 77 78[vertex data] 79vertex/float/2 offset/float/1 80-1.0 -1.0 1.0 81 1.0 -1.0 2.0 82 1.0 1.0 3.0 83-1.0 1.0 4.0 84 85[test] 86draw arrays GL_TRIANGLE_FAN 0 4 87probe all rgb 0 1 0 88