3 #extension GL_3DL_array_objects : enable
\r
5 int a = 0xffffffff; // 32 bits, a gets the value -1
\r
6 int b = 0xffffffffU; // ERROR: can't convert uint to int
\r
7 uint c = 0xffffffff; // 32 bits, c gets the value 0xFFFFFFFF
\r
8 uint d = 0xffffffffU; // 32 bits, d gets the value 0xFFFFFFFF
\r
9 int e = -1; // the literal is "1", then negation is performed,
\r
10 // and the resulting non-literal 32-bit signed
\r
11 // bit pattern of 0xFFFFFFFF is assigned, giving e
\r
13 uint f = -1u; // the literal is "1u", then negation is performed,
\r
14 // and the resulting non-literal 32-bit unsigned
\r
15 // bit pattern of 0xFFFFFFFF is assigned, giving f
\r
16 // the value of 0xFFFFFFFF.
\r
17 int g = 3000000000; // a signed decimal literal taking 32 bits,
\r
18 // setting the sign bit, g gets -1294967296
\r
19 int h = 0xA0000000; // okay, 32-bit signed hexadecimal
\r
20 int i = 5000000000; // ERROR: needs more than 32 bits
\r
21 int j = 0xFFFFFFFFF; // ERROR: needs more that 32 bits
\r
22 int k = 0x80000000; // k gets -2147483648 == 0x80000000
\r
23 int l = 2147483648; // l gets -2147483648 (the literal set the sign bit)
\r
25 float fa, fb = 1.5; // single-precision floating-point
\r
26 double fc, fd = 2.0LF; // double-precision floating-point
\r
28 vec2 texcoord1, texcoord2;
\r
31 ivec2 textureLookup;
\r
36 mat4 view, projection;
\r
37 mat4x4 view; // an alternate way of declaring a mat4
\r
38 mat3x2 m; // a matrix with 3 columns and 2 rows
\r
39 dmat4 highPrecisionMVP;
\r
47 struct S { float f; };
\r
50 //S; // Error: anonymous structures disallowed
\r
51 //struct { ... }; // Error: embedded structures disallowed
\r
52 S s; // Okay: nested structures with name are allowed
\r
55 float frequencies[3];
\r
56 uniform vec4 lightPosition[4];
\r
58 const int numLights = 2;
\r
59 light lights[numLights];
\r
62 centroid in vec2 TexCoord;
\r
63 invariant centroid in vec4 Color;
\r
64 noperspective in float temperature;
\r
65 flat in vec3 myColor;
\r
66 noperspective centroid in vec2 myTexCoord;
\r
68 uniform vec4 lightPosition;
\r
69 uniform vec3 color = vec3(0.7, 0.7, 0.2); // value assigned at link time
\r
72 smooth in vec4 Color1; // legal, input inside in block
\r
73 smooth vec4 Color2; // legal, 'in' inherited from 'in Material'
\r
74 vec2 TexCoordA; // legal, TexCoord is an input
\r
75 uniform float Atten; // illegal, mismatched storage qualifier
\r
86 } Materiala; // instance name
\r
87 vec3 Color; // different Color than Material.Color
\r
89 in vec4 gl_FragCoord; // redeclaration that changes nothing is allowed
\r
91 // All the following are allowed redeclaration that change behavior
\r
92 layout(origin_upper_left) in vec4 gl_FragCoord;
\r
93 layout(pixel_center_integer) in vec4 gl_FragCoord;
\r
94 layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;
\r
96 layout(early_fragment_tests) in;
\r
99 layout (local_size_x = 32, local_size_y = 32) in;
\r
100 layout (local_size_x = 8) in;
\r
102 layout(location = 3) out vec4 color;
\r
103 layout(location = 3, index = 1) out vec4 factor;
\r
104 layout(location = 2) out vec4 colors[3];
\r
106 layout (depth_greater) out float gl_FragDepth;
\r
108 // redeclaration that changes nothing is allowed
\r
109 out float gl_FragDepth;
\r
111 // assume it may be modified in any way
\r
112 layout (depth_any) out float gl_FragDepth;
\r
114 // assume it may be modified such that its value will only increase
\r
115 layout (depth_greater) out float gl_FragDepth;
\r
117 // assume it may be modified such that its value will only decrease
\r
118 layout (depth_less) out float gl_FragDepth;
\r
120 // assume it will not be modified
\r
121 layout (depth_unchanged) out float gl_FragDepth;
\r
123 in vec4 gl_Color; // predeclared by the fragment language
\r
124 flat in vec4 gl_Color; // redeclared by user to be flat
\r
127 float[5] foo(float[5])
\r
129 return float[5](3.4, 4.2, 5.0, 5.2, 1.1);
\r
132 precision highp float;
\r
133 precision highp int;
\r
134 precision mediump int;
\r
135 precision highp float;
\r
140 float a[5] = float[5](3.4, 4.2, 5.0, 5.2, 1.1);
\r
143 float a[5] = float[](3.4, 4.2, 5.0, 5.2, 1.1); // same thing
\r
146 vec4 a[3][2]; // size-3 array of size-2 array of vec4
\r
147 vec4[2] a1[3]; // size-3 array of size-2 array of vec4
\r
148 vec4[3][2] a2; // size-3 array of size-2 array of vec4
\r
149 vec4 b[2] = vec4[2](vec4(0.0), vec4(0.1));
\r
150 vec4[3][2] a3 = vec4[3][2](b, b, b); // constructor
\r
151 void foo(vec4[3][2]); // prototype with unnamed parameter
\r
152 vec4 a4[3][2] = {vec4[2](vec4(0.0), vec4(1.0)),
\r
153 vec4[2](vec4(0.0), vec4(1.0)),
\r
154 vec4[2](vec4(0.0), vec4(1.0)) };
\r
159 float b[] = a; // b is explicitly size 5
\r
162 float b[5] = a; // means the same thing
\r
165 float b[] = float[](1,2,3,4,5); // also explicitly sizes to 5
\r
167 a.length(); // returns 5
\r
171 a.length(); // this is 3
\r
172 a[x].length(); // this is 2
\r
174 // for an array b containing a member array a:
\r
175 b[++x].a.length(); // b is never dereferenced, but
\93++x
\94 is evaluated
\r
177 // for an array s of a shader storage object containing a member array a:
\r
178 s[x].a.length(); // s is dereferenced; x needs to be a valid index
\r
180 //All of the following declarations result in a compile-time error.
\r
181 //float a[2] = { 3.4, 4.2, 5.0 }; // illegal
\r
182 //vec2 b = { 1.0, 2.0, 3.0 }; // illegal
\r
183 //mat3x3 c = { vec3(0.0), vec3(1.0), vec3(2.0), vec3(3.0) }; // illegal
\r
184 //mat2x2 d = { 1.0, 0.0, 0.0, 1.0 }; // illegal, can't flatten nesting
\r
188 //} e = { 1.2, 2, 3 }; // illegal
\r
193 } e = { 1.2, 2 }; // legal, all types match
\r
198 } e = { 1, 3 }; // legal, first initializer is converted
\r
200 //All of the following declarations result in a compile-time error.
\r
201 //int a = true; // illegal
\r
202 //vec4 b[2] = { vec4(0.0), 1.0 }; // illegal
\r
203 //mat4x2 c = { vec3(0.0), vec3(1.0) }; // illegal
\r
213 //} d[] = { S1(vec4(0.0), vec4(1.1)) }; // illegal
\r
216 float a[] = float[](3.4, 4.2, 5.0, 5.2, 1.1);
\r
217 float b[] = { 3.4, 4.2, 5.0, 5.2, 1.1 };
\r
218 float c[] = a; // c is explicitly size 5
\r
219 float d[5] = b; // means the same thing
\r
222 const vec3 zAxis = vec3 (0.0, 0.0, 1.0);
\r
223 const float ceiling = a + b; // a and b not necessarily constants
\r
228 in vec2 texCoord[4];
\r
232 out mediump vec2 P;
\r
233 lowp ivec2 foo(lowp mat3);
\r