changed: gcc8 base update
[opensg.git] / Examples / Simple / shaderstoragebufferobject_test_1.cpp
blob0072fa45cce321c301073c5209adb6d68171672e
1 // OpenSG Test Example: ShaderStorageBufferObject_Test_1
2 //
3 // This example allows to research the capabilities of the shader
4 // storage buffer object extension on your graphics platform.
5 //
6 // This example is similar to the ShaderStorageBufferObject_Test
7 // example which uses a non array block layout, whereas this
8 // example uses an even more complex setup with an array
9 // block layout.
11 // The example does use the ShaderStorageObjChunk which allows the
12 // host application to provide the shader storage block member values
13 // directly to the chunk. The layout of the shader storage block is determined
14 // by the shader code. Any of the layout values of the specification (shared,
15 // packed, std140, std430) are allowed.
17 // Outcome on running this example:
18 // 1. animated green cylinder and torus
19 // => your platform provides all GLSL capabilities used in this
20 // example. Congratulations :-)
22 // 2. animated red cylinder and torus
23 // => the shader is actively working but some detail is not
24 // working properly. E.g.:
25 // - On ATI/AMD the usage of bvec2 fails at the time of writing
26 // the example on the authors Radeon 5700 series
27 // platform, iff the 'std140' layout is used.
28 // - On ATI/AMD the usage of double and dvec2 fails at the time
29 // writing the example on the authors Radeon 5700 series
30 // platform.
32 // 3. animated gold looking cylinder and torus
33 // => the shader is not working at all. Something is miserabely
34 // wrong on your platform.
36 // The example uses the following shader storage block named 'ExampleBlock'
37 // which is declared in the shader code below.
39 // struct TestA
40 // {
41 // float a;
42 // ivec3 b[3];
43 // int c;
44 // };
46 // struct TestB
47 // {
48 // bvec2 a;
49 // TestA b[2];
50 // float c;
51 // };
53 // struct TestC
54 // {
55 // float a;
56 // bvec2 b;
57 // TestB c[2];
58 // };
60 // struct TestD
61 // {
62 // uvec3 a;
63 // vec2 b;
64 // float c[2];
65 // vec2 d;
66 // mat3 e[2];
67 // };
69 // struct TestE
70 // {
71 // dvec2 a;
72 // int b;
73 // TestA c[4];
74 // };
76 // struct Example
77 // {
78 // float a;
79 // vec2 b;
80 // vec3 c;
81 // TestC d;
82 // float e;
83 // float f[2];
84 // mat2x3 g;
85 // TestD h[2];
86 // double i;
87 // bool j;
88 // TestE k;
89 // } example;
91 // layout(shared) buffer Examples
92 // {
93 // Example example[3];
94 // } examples;
96 // For this example the values must be provided for the following data slots (second column):
98 // Example[0].a float Examples.example[0].a
99 // Example[0].b vec2 Examples.example[0].b
100 // Example[0].c vec3 Examples.example[0].c
101 // Example[0].TestC.a float Examples.example[0].d.a
102 // Example[0].TestC.b bvec2 Examples.example[0].d.b
103 // Example[0].TestC.TestB[0].a bvec2 Examples.example[0].d.c[0].a
104 // Example[0].TestC.TestB[0].TestA[0].a float Examples.example[0].d.c[0].b[0].a
105 // Example[0].TestC.TestB[0].TestA[0].b[0] ivec3[3] Examples.example[0].d.c[0].b[0].b[0]
106 // Example[0].TestC.TestB[0].TestA[0].b[1] Examples.example[0].d.c[0].b[0].b[1]
107 // Example[0].TestC.TestB[0].TestA[0].b[2] Examples.example[0].d.c[0].b[0].b[2]
108 // Example[0].TestC.TestB[0].TestA[0].c int Examples.example[0].d.c[0].b[0].c
109 // Example[0].TestC.TestB[0].TestA[1].a float Examples.example[0].d.c[0].b[1].a
110 // Example[0].TestC.TestB[0].TestA[1].b[0] ivec3[3] Examples.example[0].d.c[0].b[1].b[0]
111 // Example[0].TestC.TestB[0].TestA[1].b[1] Examples.example[0].d.c[0].b[1].b[1]
112 // Example[0].TestC.TestB[0].TestA[1].b[2] Examples.example[0].d.c[0].b[1].b[2]
113 // Example[0].TestC.TestB[0].TestA[1].c int Examples.example[0].d.c[0].b[1].c
114 // Example[0].TestC.TestB[0].c float Examples.example[0].d.c[0].c
115 // Example[0].TestC.TestB[1].a bvec2 Examples.example[0].d.c[1].a
116 // Example[0].TestC.TestB[1].TestA[0].a float Examples.example[0].d.c[1].b[0].a
117 // Example[0].TestC.TestB[1].TestA[0].b[0] ivec3[3] Examples.example[0].d.c[1].b[0].b[0]
118 // Example[0].TestC.TestB[1].TestA[0].b[1] Examples.example[0].d.c[1].b[0].b[1]
119 // Example[0].TestC.TestB[1].TestA[0].b[2] Examples.example[0].d.c[1].b[0].b[2]
120 // Example[0].TestC.TestB[1].TestA[0].c int Examples.example[0].d.c[1].b[0].c
121 // Example[0].TestC.TestB[1].TestA[1].a float Examples.example[0].d.c[1].b[1].a
122 // Example[0].TestC.TestB[1].TestA[1].b[0] ivec3[3] Examples.example[0].d.c[1].b[1].b[0]
123 // Example[0].TestC.TestB[1].TestA[1].b[1] Examples.example[0].d.c[1].b[1].b[1]
124 // Example[0].TestC.TestB[1].TestA[1].b[2] Examples.example[0].d.c[1].b[1].b[2]
125 // Example[0].TestC.TestB[1].TestA[1].c int Examples.example[0].d.c[1].b[1].c
126 // Example[0].TestC.TestB[1].c float Examples.example[0].d.c[1].c
127 // Example[0].e float Examples.example[0].e
128 // Example[0].f[0] float[2] Examples.example[0].f[0]
129 // Example[0].f[1] Examples.example[0].f[1]
130 // Example[0].g mat2x3 Examples.example[0].g
131 // Example[0].TestD[0].a uvec3 Examples.example[0].h[0].a
132 // Example[0].TestD[0].b vec2 Examples.example[0].h[0].b
133 // Example[0].TestD[0].c[0] float[2] Examples.example[0].h[0].c[0]
134 // Example[0].TestD[0].c[1] Examples.example[0].h[0].c[1]
135 // Example[0].TestD[0].d vec2 Examples.example[0].h[0].d
136 // Example[0].TestD[0].e[0] mat3[2] Examples.example[0].h[0].e[0]
137 // Example[0].TestD[0].e[1] Examples.example[0].h[0].e[1]
138 // Example[0].TestD[1].a uvec3 Examples.example[0].h[1].a
139 // Example[0].TestD[1].b vec2 Examples.example[0].h[1].b
140 // Example[0].TestD[1].c[0] float[2] Examples.example[0].h[1].c[0]
141 // Example[0].TestD[1].c[1] Examples.example[0].h[1].c[1]
142 // Example[0].TestD[1].d vec2 Examples.example[0].h[1].d
143 // Example[0].TestD[1].e[0] mat3[2] Examples.example[0].h[1].e[0]
144 // Example[0].TestD[1].e[1] Examples.example[0].h[1].e[1]
145 // Example[0].i double Examples.example[0].i
146 // Example[0].j bool Examples.example[0].j
147 // Example[0].TestE.a dvec2 Examples.example[0].k.a
148 // Example[0].TestE.b int Examples.example[0].k.b
149 // Example[0].TestE.TestA[0].a float Examples.example[0].k.c[0].a
150 // Example[0].TestE.TestA[0].b[0] ivec3[3] Examples.example[0].k.c[0].b[0]
151 // Example[0].TestE.TestA[0].b[1] Examples.example[0].k.c[0].b[1]
152 // Example[0].TestE.TestA[0].b[2] Examples.example[0].k.c[0].b[2]
153 // Example[0].TestE.TestA[0].c int Examples.example[0].k.c[0].c
154 // Example[0].TestE.TestA[1].a float Examples.example[0].k.c[1].a
155 // Example[0].TestE.TestA[1].b[0] ivec3[3] Examples.example[0].k.c[1].b[0]
156 // Example[0].TestE.TestA[1].b[1] Examples.example[0].k.c[1].b[1]
157 // Example[0].TestE.TestA[1].b[2] Examples.example[0].k.c[1].b[2]
158 // Example[0].TestE.TestA[1].c int Examples.example[0].k.c[1].c
159 // Example[0].TestE.TestA[2].a float Examples.example[0].k.c[2].a
160 // Example[0].TestE.TestA[2].b[0] ivec3[3] Examples.example[0].k.c[2].b[0]
161 // Example[0].TestE.TestA[2].b[1] Examples.example[0].k.c[2].b[1]
162 // Example[0].TestE.TestA[2].b[2] Examples.example[0].k.c[2].b[2]
163 // Example[0].TestE.TestA[2].c int Examples.example[0].k.c[2].c
164 // Example[0].TestE.TestA[3].a float Examples.example[0].k.c[3].a
165 // Example[0].TestE.TestA[3].b[0] ivec3[3] Examples.example[0].k.c[3].b[0]
166 // Example[0].TestE.TestA[3].b[1] Examples.example[0].k.c[3].b[1]
167 // Example[0].TestE.TestA[3].b[2] Examples.example[0].k.c[3].b[2]
168 // Example[0].TestE.TestA[3].c int Examples.example[0].k.c[3].c
169 // Example[1].a float Examples.example[1].a
170 // Example[1].b vec2 Examples.example[1].b
171 // Example[1].c vec3 Examples.example[1].c
172 // Example[1].TestC.a float Examples.example[1].d.a
173 // Example[1].TestC.b bvec2 Examples.example[1].d.b
174 // Example[1].TestC.TestB[0].a bvec2 Examples.example[1].d.c[0].a
175 // Example[1].TestC.TestB[0].TestA[0].a float Examples.example[1].d.c[0].b[0].a
176 // Example[1].TestC.TestB[0].TestA[0].b[0] ivec3[3] Examples.example[1].d.c[0].b[0].b[0]
177 // Example[1].TestC.TestB[0].TestA[0].b[1] Examples.example[1].d.c[0].b[0].b[1]
178 // Example[1].TestC.TestB[0].TestA[0].b[2] Examples.example[1].d.c[0].b[0].b[2]
179 // Example[1].TestC.TestB[0].TestA[0].c int Examples.example[1].d.c[0].b[0].c
180 // Example[1].TestC.TestB[0].TestA[1].a float Examples.example[1].d.c[0].b[1].a
181 // Example[1].TestC.TestB[0].TestA[1].b[0] ivec3[3] Examples.example[1].d.c[0].b[1].b[0]
182 // Example[1].TestC.TestB[0].TestA[1].b[1] Examples.example[1].d.c[0].b[1].b[1]
183 // Example[1].TestC.TestB[0].TestA[1].b[2] Examples.example[1].d.c[0].b[1].b[2]
184 // Example[1].TestC.TestB[0].TestA[1].c int Examples.example[1].d.c[0].b[1].c
185 // Example[1].TestC.TestB[0].c float Examples.example[1].d.c[0].c
186 // Example[1].TestC.TestB[1].a bvec2 Examples.example[1].d.c[1].a
187 // Example[1].TestC.TestB[1].TestA[0].a float Examples.example[1].d.c[1].b[0].a
188 // Example[1].TestC.TestB[1].TestA[0].b[0] ivec3[3] Examples.example[1].d.c[1].b[0].b[0]
189 // Example[1].TestC.TestB[1].TestA[0].b[1] Examples.example[1].d.c[1].b[0].b[1]
190 // Example[1].TestC.TestB[1].TestA[0].b[2] Examples.example[1].d.c[1].b[0].b[2]
191 // Example[1].TestC.TestB[1].TestA[0].c int Examples.example[1].d.c[1].b[0].c
192 // Example[1].TestC.TestB[1].TestA[1].a float Examples.example[1].d.c[1].b[1].a
193 // Example[1].TestC.TestB[1].TestA[1].b[0] ivec3[3] Examples.example[1].d.c[1].b[1].b[0]
194 // Example[1].TestC.TestB[1].TestA[1].b[1] Examples.example[1].d.c[1].b[1].b[1]
195 // Example[1].TestC.TestB[1].TestA[1].b[2] Examples.example[1].d.c[1].b[1].b[2]
196 // Example[1].TestC.TestB[1].TestA[1].c int Examples.example[1].d.c[1].b[1].c
197 // Example[1].TestC.TestB[1].c float Examples.example[1].d.c[1].c
198 // Example[1].e float Examples.example[1].e
199 // Example[1].f[0] float[2] Examples.example[1].f[0]
200 // Example[1].f[1] Examples.example[1].f[1]
201 // Example[1].g mat2x3 Examples.example[1].g
202 // Example[1].TestD[0].a uvec3 Examples.example[1].h[0].a
203 // Example[1].TestD[0].b vec2 Examples.example[1].h[0].b
204 // Example[1].TestD[0].c[0] float[2] Examples.example[1].h[0].c[0]
205 // Example[1].TestD[0].c[1] Examples.example[1].h[0].c[1]
206 // Example[1].TestD[0].d vec2 Examples.example[1].h[0].d
207 // Example[1].TestD[0].e[0] mat3[2] Examples.example[1].h[0].e[0]
208 // Example[1].TestD[0].e[1] Examples.example[1].h[0].e[1]
209 // Example[1].TestD[1].a uvec3 Examples.example[1].h[1].a
210 // Example[1].TestD[1].b vec2 Examples.example[1].h[1].b
211 // Example[1].TestD[1].c[0] float[2] Examples.example[1].h[1].c[0]
212 // Example[1].TestD[1].c[1] Examples.example[1].h[1].c[1]
213 // Example[1].TestD[1].d vec2 Examples.example[1].h[1].d
214 // Example[1].TestD[1].e[0] mat3[2] Examples.example[1].h[1].e[0]
215 // Example[1].TestD[1].e[1] Examples.example[1].h[1].e[1]
216 // Example[1].i double Examples.example[1].i
217 // Example[1].j bool Examples.example[1].j
218 // Example[1].TestE.a dvec2 Examples.example[1].k.a
219 // Example[1].TestE.b int Examples.example[1].k.b
220 // Example[1].TestE.TestA[0].a float Examples.example[1].k.c[0].a
221 // Example[1].TestE.TestA[0].b[0] ivec3[3] Examples.example[1].k.c[0].b[0]
222 // Example[1].TestE.TestA[0].b[1] Examples.example[1].k.c[0].b[1]
223 // Example[1].TestE.TestA[0].b[2] Examples.example[1].k.c[0].b[2]
224 // Example[1].TestE.TestA[0].c int Examples.example[1].k.c[0].c
225 // Example[1].TestE.TestA[1].a float Examples.example[1].k.c[1].a
226 // Example[1].TestE.TestA[1].b[0] ivec3[3] Examples.example[1].k.c[1].b[0]
227 // Example[1].TestE.TestA[1].b[1] Examples.example[1].k.c[1].b[1]
228 // Example[1].TestE.TestA[1].b[2] Examples.example[1].k.c[1].b[2]
229 // Example[1].TestE.TestA[1].c int Examples.example[1].k.c[1].c
230 // Example[1].TestE.TestA[2].a float Examples.example[1].k.c[2].a
231 // Example[1].TestE.TestA[2].b[0] ivec3[3] Examples.example[1].k.c[2].b[0]
232 // Example[1].TestE.TestA[2].b[1] Examples.example[1].k.c[2].b[1]
233 // Example[1].TestE.TestA[2].b[2] Examples.example[1].k.c[2].b[2]
234 // Example[1].TestE.TestA[2].c int Examples.example[1].k.c[2].c
235 // Example[1].TestE.TestA[3].a float Examples.example[1].k.c[3].a
236 // Example[1].TestE.TestA[3].b[0] ivec3[3] Examples.example[1].k.c[3].b[0]
237 // Example[1].TestE.TestA[3].b[1] Examples.example[1].k.c[3].b[1]
238 // Example[1].TestE.TestA[3].b[2] Examples.example[1].k.c[3].b[2]
239 // Example[1].TestE.TestA[3].c int Examples.example[1].k.c[3].c
240 // Example[2].a float Examples.example[2].a
241 // Example[2].b vec2 Examples.example[2].b
242 // Example[2].c vec3 Examples.example[2].c
243 // Example[2].TestC.a float Examples.example[2].d.a
244 // Example[2].TestC.b bvec2 Examples.example[2].d.b
245 // Example[2].TestC.TestB[0].a bvec2 Examples.example[2].d.c[0].a
246 // Example[2].TestC.TestB[0].TestA[0].a float Examples.example[2].d.c[0].b[0].a
247 // Example[2].TestC.TestB[0].TestA[0].b[0] ivec3[3] Examples.example[2].d.c[0].b[0].b[0]
248 // Example[2].TestC.TestB[0].TestA[0].b[1] Examples.example[2].d.c[0].b[0].b[1]
249 // Example[2].TestC.TestB[0].TestA[0].b[2] Examples.example[2].d.c[0].b[0].b[2]
250 // Example[2].TestC.TestB[0].TestA[0].c int Examples.example[2].d.c[0].b[0].c
251 // Example[2].TestC.TestB[0].TestA[1].a float Examples.example[2].d.c[0].b[1].a
252 // Example[2].TestC.TestB[0].TestA[1].b[0] ivec3[3] Examples.example[2].d.c[0].b[1].b[0]
253 // Example[2].TestC.TestB[0].TestA[1].b[1] Examples.example[2].d.c[0].b[1].b[1]
254 // Example[2].TestC.TestB[0].TestA[1].b[2] Examples.example[2].d.c[0].b[1].b[2]
255 // Example[2].TestC.TestB[0].TestA[1].c int Examples.example[2].d.c[0].b[1].c
256 // Example[2].TestC.TestB[0].c float Examples.example[2].d.c[0].c
257 // Example[2].TestC.TestB[1].a bvec2 Examples.example[2].d.c[1].a
258 // Example[2].TestC.TestB[1].TestA[0].a float Examples.example[2].d.c[1].b[0].a
259 // Example[2].TestC.TestB[1].TestA[0].b[0] ivec3[3] Examples.example[2].d.c[1].b[0].b[0]
260 // Example[2].TestC.TestB[1].TestA[0].b[1] Examples.example[2].d.c[1].b[0].b[1]
261 // Example[2].TestC.TestB[1].TestA[0].b[2] Examples.example[2].d.c[1].b[0].b[2]
262 // Example[2].TestC.TestB[1].TestA[0].c int Examples.example[2].d.c[1].b[0].c
263 // Example[2].TestC.TestB[1].TestA[1].a float Examples.example[2].d.c[1].b[1].a
264 // Example[2].TestC.TestB[1].TestA[1].b[0] ivec3[3] Examples.example[2].d.c[1].b[1].b[0]
265 // Example[2].TestC.TestB[1].TestA[1].b[1] Examples.example[2].d.c[1].b[1].b[1]
266 // Example[2].TestC.TestB[1].TestA[1].b[2] Examples.example[2].d.c[1].b[1].b[2]
267 // Example[2].TestC.TestB[1].TestA[1].c int Examples.example[2].d.c[1].b[1].c
268 // Example[2].TestC.TestB[1].c float Examples.example[2].d.c[1].c
269 // Example[2].e float Examples.example[2].e
270 // Example[2].f[0] float[2] Examples.example[2].f[0]
271 // Example[2].f[1] Examples.example[2].f[1]
272 // Example[2].g mat2x3 Examples.example[2].g
273 // Example[2].TestD[0].a uvec3 Examples.example[2].h[0].a
274 // Example[2].TestD[0].b vec2 Examples.example[2].h[0].b
275 // Example[2].TestD[0].c[0] float[2] Examples.example[2].h[0].c[0]
276 // Example[2].TestD[0].c[1] Examples.example[2].h[0].c[1]
277 // Example[2].TestD[0].d vec2 Examples.example[2].h[0].d
278 // Example[2].TestD[0].e[0] mat3[2] Examples.example[2].h[0].e[0]
279 // Example[2].TestD[0].e[1] Examples.example[2].h[0].e[1]
280 // Example[2].TestD[1].a uvec3 Examples.example[2].h[1].a
281 // Example[2].TestD[1].b vec2 Examples.example[2].h[1].b
282 // Example[2].TestD[1].c[0] float[2] Examples.example[2].h[1].c[0]
283 // Example[2].TestD[1].c[1] Examples.example[2].h[1].c[1]
284 // Example[2].TestD[1].d vec2 Examples.example[2].h[1].d
285 // Example[2].TestD[1].e[0] mat3[2] Examples.example[2].h[1].e[0]
286 // Example[2].TestD[1].e[1] Examples.example[2].h[1].e[1]
287 // Example[2].i double Examples.example[2].i
288 // Example[2].j bool Examples.example[2].j
289 // Example[2].TestE.a dvec2 Examples.example[2].k.a
290 // Example[2].TestE.b int Examples.example[2].k.b
291 // Example[2].TestE.TestA[0].a float Examples.example[2].k.c[0].a
292 // Example[2].TestE.TestA[0].b[0] ivec3[3] Examples.example[2].k.c[0].b[0]
293 // Example[2].TestE.TestA[0].b[1] Examples.example[2].k.c[0].b[1]
294 // Example[2].TestE.TestA[0].b[2] Examples.example[2].k.c[0].b[2]
295 // Example[2].TestE.TestA[0].c int Examples.example[2].k.c[0].c
296 // Example[2].TestE.TestA[1].a float Examples.example[2].k.c[1].a
297 // Example[2].TestE.TestA[1].b[0] ivec3[3] Examples.example[2].k.c[1].b[0]
298 // Example[2].TestE.TestA[1].b[1] Examples.example[2].k.c[1].b[1]
299 // Example[2].TestE.TestA[1].b[2] Examples.example[2].k.c[1].b[2]
300 // Example[2].TestE.TestA[1].c int Examples.example[2].k.c[1].c
301 // Example[2].TestE.TestA[2].a float Examples.example[2].k.c[2].a
302 // Example[2].TestE.TestA[2].b[0] ivec3[3] Examples.example[2].k.c[2].b[0]
303 // Example[2].TestE.TestA[2].b[1] Examples.example[2].k.c[2].b[1]
304 // Example[2].TestE.TestA[2].b[2] Examples.example[2].k.c[2].b[2]
305 // Example[2].TestE.TestA[2].c int Examples.example[2].k.c[2].c
306 // Example[2].TestE.TestA[3].a float Examples.example[2].k.c[3].a
307 // Example[2].TestE.TestA[3].b[0] ivec3[3] Examples.example[2].k.c[3].b[0]
308 // Example[2].TestE.TestA[3].b[1] Examples.example[2].k.c[3].b[1]
309 // Example[2].TestE.TestA[3].b[2] Examples.example[2].k.c[3].b[2]
310 // Example[2].TestE.TestA[3].c int Examples.example[2].k.c[3].c
313 #ifdef OSG_BUILD_ACTIVE
314 // Headers
315 #include <OSGGLUT.h>
316 #include <OSGConfig.h>
317 #include <OSGSimpleGeometry.h>
318 #include <OSGGLUTWindow.h>
319 #include <OSGSimpleSceneManager.h>
320 #include <OSGBaseFunctions.h>
321 #include <OSGTransform.h>
322 #include <OSGGroup.h>
324 // new headers:
325 #include <OSGGLEXT.h>
326 #include <OSGShaderProgramChunk.h>
327 #include <OSGShaderProgram.h>
328 #include <OSGShaderVariableOSG.h>
329 #include <OSGChunkMaterial.h>
330 #include <OSGMaterialGroup.h>
331 #include <OSGMaterialChunkOverrideGroup.h>
332 #include <OSGShaderStorageBufferObjChunk.h>
333 #include <OSGPolygonChunk.h>
334 #include <OSGDepthChunk.h>
335 #include <OSGShaderProgramVariableChunk.h>
337 #else
338 // Headers
339 #include <OpenSG/OSGGLUT.h>
340 #include <OpenSG/OSGConfig.h>
341 #include <OpenSG/OSGSimpleGeometry.h>
342 #include <OpenSG/OSGGLUTWindow.h>
343 #include <OpenSG/OSGSimpleSceneManager.h>
344 #include <OpenSG/OSGBaseFunctions.h>
345 #include <OpenSG/OSGTransform.h>
346 #include <OpenSG/OSGGroup.h>
348 // new headers:
349 #include <OpenSG/OSGGLEXT.h>
350 #include <OpenSG/OSGShaderProgramChunk.h>
351 #include <OpenSG/OSGShaderProgram.h>
352 #include <OpenSG/OSGShaderVariableOSG.h>
353 #include <OpenSG/OSGChunkMaterial.h>
354 #include <OpenSG/OSGMaterialGroup.h>
355 #include <OpenSG/OSGMaterialChunkOverrideGroup.h>
356 #include <OpenSG/OSGShaderStorageBufferObjChunk.h>
357 #include <OpenSG/OSGPolygonChunk.h>
358 #include <OpenSG/OSGDepthChunk.h>
359 #include <OpenSG/OSGShaderProgramVariableChunk.h>
360 #endif
362 #define HAS_FP64_EXTENSION
365 // The SimpleSceneManager to manage simple applications
367 OSG::SimpleSceneManagerRefPtr mgr;
370 // Create a OpenSG ShaderStorageBufferObjChunk object which does
371 // perform the shader storage buffer object abstraction.
372 // For each block member entry (declared in the shader) a
373 // corresponding addXXX call is to be performed on the
374 // ssbo chunk. The cardinality for arrays must be provided
375 // to the function calls (defaults to 1).
376 // The matrix functions are defined in column-major order
377 // matching the default definition of GLSL. I.e. a addMat2x3(2)
378 // call would request space and layout for an array of two
379 // matrices with two columns and three rows.
381 OSG::ShaderStorageBufferObjChunkTransitPtr create_example_block_state()
383 OSG::ShaderStorageBufferObjChunkRefPtr ssbo = OSG::ShaderStorageBufferObjChunk::create();
385 ssbo->setBlockName("Examples");
386 ssbo->setUsage(GL_STREAM_DRAW);
388 ssbo->addFloat ("Examples.example[0].a");
389 ssbo->addVec2 ("Examples.example[0].b");
390 ssbo->addVec3 ("Examples.example[0].c");
391 ssbo->addFloat ("Examples.example[0].d.a");
392 ssbo->addBVec2 ("Examples.example[0].d.b");
393 ssbo->addBVec2 ("Examples.example[0].d.c[0].a");
394 ssbo->addFloat ("Examples.example[0].d.c[0].b[0].a");
395 ssbo->addIVec3 ("Examples.example[0].d.c[0].b[0].b", 3);
396 ssbo->addInt ("Examples.example[0].d.c[0].b[0].c");
397 ssbo->addFloat ("Examples.example[0].d.c[0].b[1].a");
398 ssbo->addIVec3 ("Examples.example[0].d.c[0].b[1].b", 3);
399 ssbo->addInt ("Examples.example[0].d.c[0].b[1].c");
400 ssbo->addFloat ("Examples.example[0].d.c[0].c");
401 ssbo->addBVec2 ("Examples.example[0].d.c[1].a");
402 ssbo->addFloat ("Examples.example[0].d.c[1].b[0].a");
403 ssbo->addIVec3 ("Examples.example[0].d.c[1].b[0].b", 3);
404 ssbo->addInt ("Examples.example[0].d.c[1].b[0].c");
405 ssbo->addFloat ("Examples.example[0].d.c[1].b[1].a");
406 ssbo->addIVec3 ("Examples.example[0].d.c[1].b[1].b", 3);
407 ssbo->addInt ("Examples.example[0].d.c[1].b[1].c");
408 ssbo->addFloat ("Examples.example[0].d.c[1].c");
409 ssbo->addFloat ("Examples.example[0].e");
410 ssbo->addFloat ("Examples.example[0].f", 2);
411 ssbo->addMat2x3 ("Examples.example[0].g");
412 ssbo->addUVec3 ("Examples.example[0].h[0].a");
413 ssbo->addVec2 ("Examples.example[0].h[0].b");
414 ssbo->addFloat ("Examples.example[0].h[0].c", 2);
415 ssbo->addVec2 ("Examples.example[0].h[0].d");
416 ssbo->addMat3 ("Examples.example[0].h[0].e", 2);
417 ssbo->addUVec3 ("Examples.example[0].h[1].a");
418 ssbo->addVec2 ("Examples.example[0].h[1].b");
419 ssbo->addFloat ("Examples.example[0].h[1].c", 2);
420 ssbo->addVec2 ("Examples.example[0].h[1].d");
421 ssbo->addMat3 ("Examples.example[0].h[1].e", 2);
422 #ifdef HAS_FP64_EXTENSION
423 ssbo->addDouble ("Examples.example[0].i");
424 #endif
425 ssbo->addBool ("Examples.example[0].j");
426 #ifdef HAS_FP64_EXTENSION
427 ssbo->addDVec2 ("Examples.example[0].k.a");
428 #endif
429 ssbo->addInt ("Examples.example[0].k.b");
430 ssbo->addFloat ("Examples.example[0].k.c[0].a");
431 ssbo->addIVec3 ("Examples.example[0].k.c[0].b", 3);
432 ssbo->addInt ("Examples.example[0].k.c[0].c");
433 ssbo->addFloat ("Examples.example[0].k.c[1].a");
434 ssbo->addIVec3 ("Examples.example[0].k.c[1].b", 3);
435 ssbo->addInt ("Examples.example[0].k.c[1].c");
436 ssbo->addFloat ("Examples.example[0].k.c[2].a");
437 ssbo->addIVec3 ("Examples.example[0].k.c[2].b", 3);
438 ssbo->addInt ("Examples.example[0].k.c[2].c");
439 ssbo->addFloat ("Examples.example[0].k.c[3].a");
440 ssbo->addIVec3 ("Examples.example[0].k.c[3].b", 3);
441 ssbo->addInt ("Examples.example[0].k.c[3].c");
443 ssbo->addFloat ("Examples.example[1].a");
444 ssbo->addVec2 ("Examples.example[1].b");
445 ssbo->addVec3 ("Examples.example[1].c");
446 ssbo->addFloat ("Examples.example[1].d.a");
447 ssbo->addBVec2 ("Examples.example[1].d.b");
448 ssbo->addBVec2 ("Examples.example[1].d.c[0].a");
449 ssbo->addFloat ("Examples.example[1].d.c[0].b[0].a");
450 ssbo->addIVec3 ("Examples.example[1].d.c[0].b[0].b", 3);
451 ssbo->addInt ("Examples.example[1].d.c[0].b[0].c");
452 ssbo->addFloat ("Examples.example[1].d.c[0].b[1].a");
453 ssbo->addIVec3 ("Examples.example[1].d.c[0].b[1].b", 3);
454 ssbo->addInt ("Examples.example[1].d.c[0].b[1].c");
455 ssbo->addFloat ("Examples.example[1].d.c[0].c");
456 ssbo->addBVec2 ("Examples.example[1].d.c[1].a");
457 ssbo->addFloat ("Examples.example[1].d.c[1].b[0].a");
458 ssbo->addIVec3 ("Examples.example[1].d.c[1].b[0].b", 3);
459 ssbo->addInt ("Examples.example[1].d.c[1].b[0].c");
460 ssbo->addFloat ("Examples.example[1].d.c[1].b[1].a");
461 ssbo->addIVec3 ("Examples.example[1].d.c[1].b[1].b", 3);
462 ssbo->addInt ("Examples.example[1].d.c[1].b[1].c");
463 ssbo->addFloat ("Examples.example[1].d.c[1].c");
464 ssbo->addFloat ("Examples.example[1].e");
465 ssbo->addFloat ("Examples.example[1].f", 2);
466 ssbo->addMat2x3 ("Examples.example[1].g");
467 ssbo->addUVec3 ("Examples.example[1].h[0].a");
468 ssbo->addVec2 ("Examples.example[1].h[0].b");
469 ssbo->addFloat ("Examples.example[1].h[0].c", 2);
470 ssbo->addVec2 ("Examples.example[1].h[0].d");
471 ssbo->addMat3 ("Examples.example[1].h[0].e", 2);
472 ssbo->addUVec3 ("Examples.example[1].h[1].a");
473 ssbo->addVec2 ("Examples.example[1].h[1].b");
474 ssbo->addFloat ("Examples.example[1].h[1].c", 2);
475 ssbo->addVec2 ("Examples.example[1].h[1].d");
476 ssbo->addMat3 ("Examples.example[1].h[1].e", 2);
477 #ifdef HAS_FP64_EXTENSION
478 ssbo->addDouble ("Examples.example[1].i");
479 #endif
480 ssbo->addBool ("Examples.example[1].j");
481 #ifdef HAS_FP64_EXTENSION
482 ssbo->addDVec2 ("Examples.example[1].k.a");
483 #endif
484 ssbo->addInt ("Examples.example[1].k.b");
485 ssbo->addFloat ("Examples.example[1].k.c[0].a");
486 ssbo->addIVec3 ("Examples.example[1].k.c[0].b", 3);
487 ssbo->addInt ("Examples.example[1].k.c[0].c");
488 ssbo->addFloat ("Examples.example[1].k.c[1].a");
489 ssbo->addIVec3 ("Examples.example[1].k.c[1].b", 3);
490 ssbo->addInt ("Examples.example[1].k.c[1].c");
491 ssbo->addFloat ("Examples.example[1].k.c[2].a");
492 ssbo->addIVec3 ("Examples.example[1].k.c[2].b", 3);
493 ssbo->addInt ("Examples.example[1].k.c[2].c");
494 ssbo->addFloat ("Examples.example[1].k.c[3].a");
495 ssbo->addIVec3 ("Examples.example[1].k.c[3].b", 3);
496 ssbo->addInt ("Examples.example[1].k.c[3].c");
498 ssbo->addFloat ("Examples.example[2].a");
499 ssbo->addVec2 ("Examples.example[2].b");
500 ssbo->addVec3 ("Examples.example[2].c");
501 ssbo->addFloat ("Examples.example[2].d.a");
502 ssbo->addBVec2 ("Examples.example[2].d.b");
503 ssbo->addBVec2 ("Examples.example[2].d.c[0].a");
504 ssbo->addFloat ("Examples.example[2].d.c[0].b[0].a");
505 ssbo->addIVec3 ("Examples.example[2].d.c[0].b[0].b", 3);
506 ssbo->addInt ("Examples.example[2].d.c[0].b[0].c");
507 ssbo->addFloat ("Examples.example[2].d.c[0].b[1].a");
508 ssbo->addIVec3 ("Examples.example[2].d.c[0].b[1].b", 3);
509 ssbo->addInt ("Examples.example[2].d.c[0].b[1].c");
510 ssbo->addFloat ("Examples.example[2].d.c[0].c");
511 ssbo->addBVec2 ("Examples.example[2].d.c[1].a");
512 ssbo->addFloat ("Examples.example[2].d.c[1].b[0].a");
513 ssbo->addIVec3 ("Examples.example[2].d.c[1].b[0].b", 3);
514 ssbo->addInt ("Examples.example[2].d.c[1].b[0].c");
515 ssbo->addFloat ("Examples.example[2].d.c[1].b[1].a");
516 ssbo->addIVec3 ("Examples.example[2].d.c[1].b[1].b", 3);
517 ssbo->addInt ("Examples.example[2].d.c[1].b[1].c");
518 ssbo->addFloat ("Examples.example[2].d.c[1].c");
519 ssbo->addFloat ("Examples.example[2].e");
520 ssbo->addFloat ("Examples.example[2].f", 2);
521 ssbo->addMat2x3 ("Examples.example[2].g");
522 ssbo->addUVec3 ("Examples.example[2].h[0].a");
523 ssbo->addVec2 ("Examples.example[2].h[0].b");
524 ssbo->addFloat ("Examples.example[2].h[0].c", 2);
525 ssbo->addVec2 ("Examples.example[2].h[0].d");
526 ssbo->addMat3 ("Examples.example[2].h[0].e", 2);
527 ssbo->addUVec3 ("Examples.example[2].h[1].a");
528 ssbo->addVec2 ("Examples.example[2].h[1].b");
529 ssbo->addFloat ("Examples.example[2].h[1].c", 2);
530 ssbo->addVec2 ("Examples.example[2].h[1].d");
531 ssbo->addMat3 ("Examples.example[2].h[1].e", 2);
532 #ifdef HAS_FP64_EXTENSION
533 ssbo->addDouble ("Examples.example[2].i");
534 #endif
535 ssbo->addBool ("Examples.example[2].j");
536 #ifdef HAS_FP64_EXTENSION
537 ssbo->addDVec2 ("Examples.example[2].k.a");
538 #endif
539 ssbo->addInt ("Examples.example[2].k.b");
540 ssbo->addFloat ("Examples.example[2].k.c[0].a");
541 ssbo->addIVec3 ("Examples.example[2].k.c[0].b", 3);
542 ssbo->addInt ("Examples.example[2].k.c[0].c");
543 ssbo->addFloat ("Examples.example[2].k.c[1].a");
544 ssbo->addIVec3 ("Examples.example[2].k.c[1].b", 3);
545 ssbo->addInt ("Examples.example[2].k.c[1].c");
546 ssbo->addFloat ("Examples.example[2].k.c[2].a");
547 ssbo->addIVec3 ("Examples.example[2].k.c[2].b", 3);
548 ssbo->addInt ("Examples.example[2].k.c[2].c");
549 ssbo->addFloat ("Examples.example[2].k.c[3].a");
550 ssbo->addIVec3 ("Examples.example[2].k.c[3].b", 3);
551 ssbo->addInt ("Examples.example[2].k.c[3].c");
553 return OSG::ShaderStorageBufferObjChunkTransitPtr(ssbo);
557 // Fill the ssbo chunk with values.
559 void update_example_block_state(OSG::ShaderStorageBufferObjChunk* ssbo)
561 ssbo->setFloat ("Examples.example[0].a", 1234.56f);
562 ssbo->setVec2 ("Examples.example[0].b", OSG::Vec2f(1.4f, 8.6f));
563 ssbo->setVec3 ("Examples.example[0].c", OSG::Vec3f(0.1f, 0.2f, 0.3f));
564 ssbo->setFloat ("Examples.example[0].d.a", 8123.45f);
565 ssbo->setBVec2 ("Examples.example[0].d.b", OSG::Vec2b(true, false));
566 ssbo->setBVec2 ("Examples.example[0].d.c[0].a", OSG::Vec2b(true, true));
567 ssbo->setFloat ("Examples.example[0].d.c[0].b[0].a", 7812.34f);
568 ssbo->setIVec3 ("Examples.example[0].d.c[0].b[0].b", OSG::Vec3i(0,-1,2), 0);
569 ssbo->setIVec3 ("Examples.example[0].d.c[0].b[0].b", OSG::Vec3i(1,-2,3), 1);
570 ssbo->setIVec3 ("Examples.example[0].d.c[0].b[0].b", OSG::Vec3i(4,-5,6), 2);
571 ssbo->setInt ("Examples.example[0].d.c[0].b[0].c", 6781);
572 ssbo->setFloat ("Examples.example[0].d.c[0].b[1].a", 5678.12f);
573 ssbo->setIVec3 ("Examples.example[0].d.c[0].b[1].b", OSG::Vec3i(-7,8,9), 0);
574 ssbo->setIVec3 ("Examples.example[0].d.c[0].b[1].b", OSG::Vec3i(-10,11,12), 1);
575 ssbo->setIVec3 ("Examples.example[0].d.c[0].b[1].b", OSG::Vec3i(-13,14,15), 2);
576 ssbo->setInt ("Examples.example[0].d.c[0].b[1].c", 4567);
577 ssbo->setFloat ("Examples.example[0].d.c[0].c", 3456.78f);
578 ssbo->setBVec2 ("Examples.example[0].d.c[1].a", OSG::Vec2b(false, true));
579 ssbo->setFloat ("Examples.example[0].d.c[1].b[0].a", 2345.67f);
580 ssbo->setIVec3 ("Examples.example[0].d.c[1].b[0].b", OSG::Vec3i(16,17,-18), 0);
581 ssbo->setIVec3 ("Examples.example[0].d.c[1].b[0].b", OSG::Vec3i(19,20,-21), 1);
582 ssbo->setIVec3 ("Examples.example[0].d.c[1].b[0].b", OSG::Vec3i(22,23,-24), 2);
583 ssbo->setInt ("Examples.example[0].d.c[1].b[0].c", 123);
584 ssbo->setFloat ("Examples.example[0].d.c[1].b[1].a", 812.34f);
585 ssbo->setIVec3 ("Examples.example[0].d.c[1].b[1].b", OSG::Vec3i(25,-26,27), 0);
586 ssbo->setIVec3 ("Examples.example[0].d.c[1].b[1].b", OSG::Vec3i(28,-29,30), 1);
587 ssbo->setIVec3 ("Examples.example[0].d.c[1].b[1].b", OSG::Vec3i(31,-32,33), 2);
588 ssbo->setInt ("Examples.example[0].d.c[1].b[1].c", 781);
589 ssbo->setFloat ("Examples.example[0].d.c[1].c", 678.12f);
590 ssbo->setFloat ("Examples.example[0].e", 567.81f);
591 ssbo->setFloat ("Examples.example[0].f", 456.78f, 0);
592 ssbo->setFloat ("Examples.example[0].f", 345.67f, 1);
594 // Matrix mxn (m rows and n columns):
595 // ----------------------------------
596 // test_mat = a11 a12 a13 a14
597 // a21 a22 a23 a24
598 // a31 a32 a33 a34
599 // a41 a42 a43 a44
600 // OpenSG takes rows...
601 OSG::Matrix4f mat01( 11.1f,12.2f,13.3f,14.4f, // row 1
602 21.1f,22.2f,23.3f,24.4f, // row 2
603 31.1f,32.2f,33.3f,34.4f, // row 3
604 41.1f,42.2f,43.3f,44.4f ); // row 4
606 // ... and provides elements in column-major order
607 // OSG::Real32* storage = mat1.getValues();
608 OSG::Vec4f column01 = mat01[1];
609 OSG::Vec4f column02 = mat01[2];
610 OSG::Vec4f column03 = mat01[3];
611 OSG::Vec4f column04 = mat01[4];
613 // GLSL uses column-major layout, i.e. mat2x3 is a matrix with 2 colums and 3 rows
615 // mat2x3 = a11 a12
616 // a21 a22
617 // a31 a32
619 ssbo->setMat2x3 ("Examples.example[0].g", mat01);
620 ssbo->setUVec3 ("Examples.example[0].h[0].a", OSG::Vec3u(91,82,73));
621 ssbo->setVec2 ("Examples.example[0].h[0].b", OSG::Vec2f(2.5f, 9.7f));
622 ssbo->setFloat ("Examples.example[0].h[0].c", 234.56f, 0);
623 ssbo->setFloat ("Examples.example[0].h[0].c", 12.34f, 1);
624 ssbo->setVec2 ("Examples.example[0].h[0].d", OSG::Vec2f(3.6f, 1.3f));
626 OSG::Matrix4f mat02( 1.1f, 1.2f, 1.3f, 1.4f, // row 1
627 2.1f, 2.2f, 2.3f, 2.4f, // row 2
628 3.1f, 3.2f, 3.3f, 3.4f, // row 3
629 4.1f, 4.2f, 4.3f, 4.4f ); // row 4
631 OSG::Matrix4f mat03( 1.2f, 1.3f, 1.4f, 1.5f, // row 1
632 -2.2f,-2.3f,-2.4f,-2.5f, // row 2
633 3.2f, 3.3f, 3.4f, 3.5f, // row 3
634 4.2f, 4.3f, 4.4f, 4.5f ); // row 4
636 ssbo->setMat3 ("Examples.example[0].h[0].e", mat02, 0);
637 ssbo->setMat3 ("Examples.example[0].h[0].e", mat03, 1);
638 ssbo->setUVec3 ("Examples.example[0].h[1].a", OSG::Vec3u(71,82,93));
639 ssbo->setVec2 ("Examples.example[0].h[1].b", OSG::Vec2f(4.5f, 2.4f));
640 ssbo->setFloat ("Examples.example[0].h[1].c", 81.23f, 0);
641 ssbo->setFloat ("Examples.example[0].h[1].c", 78.12f, 1);
642 ssbo->setVec2 ("Examples.example[0].h[1].d", OSG::Vec2f(5.7f, 3.5f));
644 OSG::Matrix4f mat04( 1.3f, 1.4f, 1.5f, 1.6f, // row 1
645 2.3f, 2.4f, 2.5f, 2.6f, // row 2
646 -3.3f,-3.4f,-3.5f,-3.6f, // row 3
647 4.3f, 4.4f, 4.5f, 4.6f ); // row 4
649 OSG::Matrix4f mat05( 1.4f, 1.5f, 1.6f, 1.7f, // row 1
650 2.4f, 2.5f, 2.6f, 2.7f, // row 2
651 3.4f, 3.5f, 3.6f, 3.7f, // row 3
652 -4.4f,-4.5f,-4.6f,-4.7f ); // row 4
654 ssbo->setMat3 ("Examples.example[0].h[1].e", mat04, 0);
655 ssbo->setMat3 ("Examples.example[0].h[1].e", mat05, 1);
656 #ifdef HAS_FP64_EXTENSION
657 ssbo->setDouble ("Examples.example[0].i", 94.345678);
658 #endif
659 ssbo->setBool ("Examples.example[0].j", true);
660 #ifdef HAS_FP64_EXTENSION
661 ssbo->setDVec2 ("Examples.example[0].k.a", OSG::Vec2d(12.874, -2346.985633));
662 #endif
663 ssbo->setInt ("Examples.example[0].k.b", 3);
664 ssbo->setFloat ("Examples.example[0].k.c[0].a", 67.81f);
665 ssbo->setIVec3 ("Examples.example[0].k.c[0].b", OSG::Vec3i(34,35,-36), 0);
666 ssbo->setIVec3 ("Examples.example[0].k.c[0].b", OSG::Vec3i(37,38,-39), 1);
667 ssbo->setIVec3 ("Examples.example[0].k.c[0].b", OSG::Vec3i(40,41,-42), 2);
668 ssbo->setInt ("Examples.example[0].k.c[0].c", -4);
669 ssbo->setFloat ("Examples.example[0].k.c[1].a", 56.78f);
670 ssbo->setIVec3 ("Examples.example[0].k.c[1].b", OSG::Vec3i(-43,44,45), 0);
671 ssbo->setIVec3 ("Examples.example[0].k.c[1].b", OSG::Vec3i(-46,47,48), 1);
672 ssbo->setIVec3 ("Examples.example[0].k.c[1].b", OSG::Vec3i(-49,50,51), 2);
673 ssbo->setInt ("Examples.example[0].k.c[1].c", -5);
674 ssbo->setFloat ("Examples.example[0].k.c[2].a", 45.67f);
675 ssbo->setIVec3 ("Examples.example[0].k.c[2].b", OSG::Vec3i(52,-53,54), 0);
676 ssbo->setIVec3 ("Examples.example[0].k.c[2].b", OSG::Vec3i(55,-56,57), 1);
677 ssbo->setIVec3 ("Examples.example[0].k.c[2].b", OSG::Vec3i(58,-59,60), 2);
678 ssbo->setInt ("Examples.example[0].k.c[2].c", -6);
679 ssbo->setFloat ("Examples.example[0].k.c[3].a", 34.56f);
680 ssbo->setIVec3 ("Examples.example[0].k.c[3].b", OSG::Vec3i(61,62,-63), 0);
681 ssbo->setIVec3 ("Examples.example[0].k.c[3].b", OSG::Vec3i(64,-65,66), 1);
682 ssbo->setIVec3 ("Examples.example[0].k.c[3].b", OSG::Vec3i(-67,68,69), 2);
683 ssbo->setInt ("Examples.example[0].k.c[3].c", 7);
687 ssbo->setFloat ("Examples.example[1].a", 91234.56f);
688 ssbo->setVec2 ("Examples.example[1].b", OSG::Vec2f(91.4f, 98.6f));
689 ssbo->setVec3 ("Examples.example[1].c", OSG::Vec3f(90.1f, 90.2f, 90.3f));
690 ssbo->setFloat ("Examples.example[1].d.a", 98123.45f);
691 ssbo->setBVec2 ("Examples.example[1].d.b", OSG::Vec2b(false, false));
692 ssbo->setBVec2 ("Examples.example[1].d.c[0].a", OSG::Vec2b(true, false));
693 ssbo->setFloat ("Examples.example[1].d.c[0].b[0].a", 97812.34f);
694 ssbo->setIVec3 ("Examples.example[1].d.c[0].b[0].b", OSG::Vec3i(90,-91,92), 0);
695 ssbo->setIVec3 ("Examples.example[1].d.c[0].b[0].b", OSG::Vec3i(91,-92,93), 1);
696 ssbo->setIVec3 ("Examples.example[1].d.c[0].b[0].b", OSG::Vec3i(94,-95,96), 2);
697 ssbo->setInt ("Examples.example[1].d.c[0].b[0].c", 6781);
698 ssbo->setFloat ("Examples.example[1].d.c[0].b[1].a", 5678.12f);
699 ssbo->setIVec3 ("Examples.example[1].d.c[0].b[1].b", OSG::Vec3i(-97,98,99), 0);
700 ssbo->setIVec3 ("Examples.example[1].d.c[0].b[1].b", OSG::Vec3i(-910,911,912), 1);
701 ssbo->setIVec3 ("Examples.example[1].d.c[0].b[1].b", OSG::Vec3i(-913,914,915), 2);
702 ssbo->setInt ("Examples.example[1].d.c[0].b[1].c", 94567);
703 ssbo->setFloat ("Examples.example[1].d.c[0].c", 93456.78f);
704 ssbo->setBVec2 ("Examples.example[1].d.c[1].a", OSG::Vec2b(false, true));
705 ssbo->setFloat ("Examples.example[1].d.c[1].b[0].a", 92345.67f);
706 ssbo->setIVec3 ("Examples.example[1].d.c[1].b[0].b", OSG::Vec3i(916,917,-918), 0);
707 ssbo->setIVec3 ("Examples.example[1].d.c[1].b[0].b", OSG::Vec3i(919,920,-921), 1);
708 ssbo->setIVec3 ("Examples.example[1].d.c[1].b[0].b", OSG::Vec3i(922,923,-924), 2);
709 ssbo->setInt ("Examples.example[1].d.c[1].b[0].c", 9123);
710 ssbo->setFloat ("Examples.example[1].d.c[1].b[1].a", 9812.34f);
711 ssbo->setIVec3 ("Examples.example[1].d.c[1].b[1].b", OSG::Vec3i(925,-926,927), 0);
712 ssbo->setIVec3 ("Examples.example[1].d.c[1].b[1].b", OSG::Vec3i(928,-929,930), 1);
713 ssbo->setIVec3 ("Examples.example[1].d.c[1].b[1].b", OSG::Vec3i(931,-932,933), 2);
714 ssbo->setInt ("Examples.example[1].d.c[1].b[1].c", 9781);
715 ssbo->setFloat ("Examples.example[1].d.c[1].c", 9678.12f);
716 ssbo->setFloat ("Examples.example[1].e", 9567.81f);
717 ssbo->setFloat ("Examples.example[1].f", 9456.78f, 0);
718 ssbo->setFloat ("Examples.example[1].f", 9345.67f, 1);
720 // Matrix mxn (m rows and n columns):
721 // ----------------------------------
722 // test_mat = a11 a12 a13 a14
723 // a21 a22 a23 a24
724 // a31 a32 a33 a34
725 // a41 a42 a43 a44
726 // OpenSG takes rows...
727 OSG::Matrix4f mat11( 911.1f,912.2f,913.3f,914.4f, // row 1
728 921.1f,922.2f,923.3f,924.4f, // row 2
729 931.1f,932.2f,933.3f,934.4f, // row 3
730 941.1f,942.2f,943.3f,944.4f ); // row 4
732 // ... and provides elements in column-major order
733 // OSG::Real32* storage = mat1.getValues();
734 OSG::Vec4f column11 = mat11[1];
735 OSG::Vec4f column12 = mat11[2];
736 OSG::Vec4f column13 = mat11[3];
737 OSG::Vec4f column14 = mat11[4];
739 // GLSL uses column-major layout, i.e. mat2x3 is a matrix with 2 colums and 3 rows
741 // mat2x3 = a11 a12
742 // a21 a22
743 // a31 a32
745 ssbo->setMat2x3 ("Examples.example[1].g", mat11);
746 ssbo->setUVec3 ("Examples.example[1].h[0].a", OSG::Vec3u(991,982,973));
747 ssbo->setVec2 ("Examples.example[1].h[0].b", OSG::Vec2f(92.5f, 99.7f));
748 ssbo->setFloat ("Examples.example[1].h[0].c", 9234.56f, 0);
749 ssbo->setFloat ("Examples.example[1].h[0].c", 912.34f, 1);
750 ssbo->setVec2 ("Examples.example[1].h[0].d", OSG::Vec2f(93.6f, 91.3f));
752 OSG::Matrix4f mat12( 91.1f, 91.2f, 91.3f, 91.4f, // row 1
753 92.1f, 92.2f, 92.3f, 92.4f, // row 2
754 93.1f, 93.2f, 93.3f, 93.4f, // row 3
755 94.1f, 94.2f, 94.3f, 94.4f ); // row 4
757 OSG::Matrix4f mat13( 91.2f, 91.3f, 91.4f, 91.5f, // row 1
758 -92.2f,-92.3f,-92.4f,-92.5f, // row 2
759 93.2f, 93.3f, 93.4f, 93.5f, // row 3
760 94.2f, 94.3f, 94.4f, 94.5f ); // row 4
762 ssbo->setMat3 ("Examples.example[1].h[0].e", mat12, 0);
763 ssbo->setMat3 ("Examples.example[1].h[0].e", mat13, 1);
764 ssbo->setUVec3 ("Examples.example[1].h[1].a", OSG::Vec3u(971,982,93));
765 ssbo->setVec2 ("Examples.example[1].h[1].b", OSG::Vec2f(94.5f, 92.4f));
766 ssbo->setFloat ("Examples.example[1].h[1].c", 981.23f, 0);
767 ssbo->setFloat ("Examples.example[1].h[1].c", 978.12f, 1);
768 ssbo->setVec2 ("Examples.example[1].h[1].d", OSG::Vec2f(95.7f, 93.5f));
770 OSG::Matrix4f mat14( 91.3f, 91.4f, 91.5f, 91.6f, // row 1
771 92.3f, 92.4f, 92.5f, 92.6f, // row 2
772 -93.3f,-93.4f,-93.5f,-93.6f, // row 3
773 94.3f, 94.4f, 94.5f, 94.6f ); // row 4
775 OSG::Matrix4f mat15( 91.4f, 91.5f, 91.6f, 91.7f, // row 1
776 92.4f, 92.5f, 92.6f, 92.7f, // row 2
777 93.4f, 93.5f, 93.6f, 93.7f, // row 3
778 -94.4f,-94.5f,-94.6f,-94.7f ); // row 4
780 ssbo->setMat3 ("Examples.example[1].h[1].e", mat14, 0);
781 ssbo->setMat3 ("Examples.example[1].h[1].e", mat15, 1);
782 #ifdef HAS_FP64_EXTENSION
783 ssbo->setDouble ("Examples.example[1].i", 994.345678);
784 #endif
785 ssbo->setBool ("Examples.example[1].j", false);
786 #ifdef HAS_FP64_EXTENSION
787 ssbo->setDVec2 ("Examples.example[1].k.a", OSG::Vec2d(912.874, -92346.985633));
788 #endif
789 ssbo->setInt ("Examples.example[1].k.b", 93);
790 ssbo->setFloat ("Examples.example[1].k.c[0].a", 967.81f);
791 ssbo->setIVec3 ("Examples.example[1].k.c[0].b", OSG::Vec3i(934,935,-936), 0);
792 ssbo->setIVec3 ("Examples.example[1].k.c[0].b", OSG::Vec3i(937,938,-939), 1);
793 ssbo->setIVec3 ("Examples.example[1].k.c[0].b", OSG::Vec3i(940,941,-942), 2);
794 ssbo->setInt ("Examples.example[1].k.c[0].c", -94);
795 ssbo->setFloat ("Examples.example[1].k.c[1].a", 956.78f);
796 ssbo->setIVec3 ("Examples.example[1].k.c[1].b", OSG::Vec3i(-943,944,945), 0);
797 ssbo->setIVec3 ("Examples.example[1].k.c[1].b", OSG::Vec3i(-946,947,948), 1);
798 ssbo->setIVec3 ("Examples.example[1].k.c[1].b", OSG::Vec3i(-949,950,951), 2);
799 ssbo->setInt ("Examples.example[1].k.c[1].c", -95);
800 ssbo->setFloat ("Examples.example[1].k.c[2].a", 945.67f);
801 ssbo->setIVec3 ("Examples.example[1].k.c[2].b", OSG::Vec3i(952,-953,954), 0);
802 ssbo->setIVec3 ("Examples.example[1].k.c[2].b", OSG::Vec3i(955,-956,957), 1);
803 ssbo->setIVec3 ("Examples.example[1].k.c[2].b", OSG::Vec3i(958,-959,960), 2);
804 ssbo->setInt ("Examples.example[1].k.c[2].c", -96);
805 ssbo->setFloat ("Examples.example[1].k.c[3].a", 934.56f);
806 ssbo->setIVec3 ("Examples.example[1].k.c[3].b", OSG::Vec3i(961,962,-963), 0);
807 ssbo->setIVec3 ("Examples.example[1].k.c[3].b", OSG::Vec3i(964,-965,966), 1);
808 ssbo->setIVec3 ("Examples.example[1].k.c[3].b", OSG::Vec3i(-967,968,969), 2);
809 ssbo->setInt ("Examples.example[1].k.c[3].c", 97);
813 ssbo->setFloat ("Examples.example[2].a", 71234.56f);
814 ssbo->setVec2 ("Examples.example[2].b", OSG::Vec2f(71.4f, 78.6f));
815 ssbo->setVec3 ("Examples.example[2].c", OSG::Vec3f(70.1f, 70.2f, 70.3f));
816 ssbo->setFloat ("Examples.example[2].d.a", 78123.45f);
817 ssbo->setBVec2 ("Examples.example[2].d.b", OSG::Vec2b(true, true));
818 ssbo->setBVec2 ("Examples.example[2].d.c[0].a", OSG::Vec2b(true, false));
819 ssbo->setFloat ("Examples.example[2].d.c[0].b[0].a", 77812.34f);
820 ssbo->setIVec3 ("Examples.example[2].d.c[0].b[0].b", OSG::Vec3i(70,-71,72), 0);
821 ssbo->setIVec3 ("Examples.example[2].d.c[0].b[0].b", OSG::Vec3i(71,-72,73), 1);
822 ssbo->setIVec3 ("Examples.example[2].d.c[0].b[0].b", OSG::Vec3i(74,-75,76), 2);
823 ssbo->setInt ("Examples.example[2].d.c[0].b[0].c", 76781);
824 ssbo->setFloat ("Examples.example[2].d.c[0].b[1].a", 75678.12f);
825 ssbo->setIVec3 ("Examples.example[2].d.c[0].b[1].b", OSG::Vec3i(-77,78,79), 0);
826 ssbo->setIVec3 ("Examples.example[2].d.c[0].b[1].b", OSG::Vec3i(-710,711,712), 1);
827 ssbo->setIVec3 ("Examples.example[2].d.c[0].b[1].b", OSG::Vec3i(-713,714,715), 2);
828 ssbo->setInt ("Examples.example[2].d.c[0].b[1].c", 74567);
829 ssbo->setFloat ("Examples.example[2].d.c[0].c", 73456.78f);
830 ssbo->setBVec2 ("Examples.example[2].d.c[1].a",OSG::Vec2b(true, true));
831 ssbo->setFloat ("Examples.example[2].d.c[1].b[0].a", 72345.67f);
832 ssbo->setIVec3 ("Examples.example[2].d.c[1].b[0].b", OSG::Vec3i(716,717,-718), 0);
833 ssbo->setIVec3 ("Examples.example[2].d.c[1].b[0].b", OSG::Vec3i(719,720,-721), 1);
834 ssbo->setIVec3 ("Examples.example[2].d.c[1].b[0].b", OSG::Vec3i(722,723,-724), 2);
835 ssbo->setInt ("Examples.example[2].d.c[1].b[0].c", 7123);
836 ssbo->setFloat ("Examples.example[2].d.c[1].b[1].a", 7812.34f);
837 ssbo->setIVec3 ("Examples.example[2].d.c[1].b[1].b", OSG::Vec3i(725,-726,727), 0);
838 ssbo->setIVec3 ("Examples.example[2].d.c[1].b[1].b", OSG::Vec3i(728,-729,730), 1);
839 ssbo->setIVec3 ("Examples.example[2].d.c[1].b[1].b", OSG::Vec3i(731,-732,733), 2);
840 ssbo->setInt ("Examples.example[2].d.c[1].b[1].c", 7781);
841 ssbo->setFloat ("Examples.example[2].d.c[1].c", 7678.12f);
842 ssbo->setFloat ("Examples.example[2].e", 7567.81f);
843 ssbo->setFloat ("Examples.example[2].f", 7456.78f, 0);
844 ssbo->setFloat ("Examples.example[2].f", 7345.67f, 1);
846 // Matrix mxn (m rows and n columns):
847 // ----------------------------------
848 // test_mat = a11 a12 a13 a14
849 // a21 a22 a23 a24
850 // a31 a32 a33 a34
851 // a41 a42 a43 a44
852 // OpenSG takes rows...
853 OSG::Matrix4f mat21( 711.1f,712.2f,713.3f,714.4f, // row 1
854 721.1f,722.2f,723.3f,724.4f, // row 2
855 731.1f,732.2f,733.3f,734.4f, // row 3
856 741.1f,742.2f,743.3f,744.4f ); // row 4
858 // ... and provides elements in column-major order
859 // OSG::Real32* storage = mat1.getValues();
860 OSG::Vec4f column21 = mat21[1];
861 OSG::Vec4f column22 = mat21[2];
862 OSG::Vec4f column23 = mat21[3];
863 OSG::Vec4f column24 = mat21[4];
865 // GLSL uses column-major layout, i.e. mat2x3 is a matrix with 2 colums and 3 rows
867 // mat2x3 = a11 a12
868 // a21 a22
869 // a31 a32
871 ssbo->setMat2x3 ("Examples.example[2].g", mat21);
872 ssbo->setUVec3 ("Examples.example[2].h[0].a", OSG::Vec3u(791,782,73));
873 ssbo->setVec2 ("Examples.example[2].h[0].b", OSG::Vec2f(72.5f, 79.7f));
874 ssbo->setFloat ("Examples.example[2].h[0].c", 7234.56f, 0);
875 ssbo->setFloat ("Examples.example[2].h[0].c", 712.34f, 1);
876 ssbo->setVec2 ("Examples.example[2].h[0].d", OSG::Vec2f(73.6f, 71.3f));
878 OSG::Matrix4f mat22( 71.1f, 71.2f, 71.3f, 71.4f, // row 1
879 72.1f, 72.2f, 72.3f, 72.4f, // row 2
880 73.1f, 73.2f, 73.3f, 73.4f, // row 3
881 74.1f, 74.2f, 74.3f, 74.4f ); // row 4
883 OSG::Matrix4f mat23( 71.2f, 71.3f, 71.4f, 71.5f, // row 1
884 -72.2f,-72.3f,-72.4f,-72.5f, // row 2
885 73.2f, 73.3f, 73.4f, 73.5f, // row 3
886 74.2f, 74.3f, 74.4f, 74.5f ); // row 4
888 ssbo->setMat3 ("Examples.example[2].h[0].e", mat22, 0);
889 ssbo->setMat3 ("Examples.example[2].h[0].e", mat23, 1);
890 ssbo->setUVec3 ("Examples.example[2].h[1].a", OSG::Vec3u(771,782,793));
891 ssbo->setVec2 ("Examples.example[2].h[1].b", OSG::Vec2f(74.5f, 72.4f));
892 ssbo->setFloat ("Examples.example[2].h[1].c", 781.23f, 0);
893 ssbo->setFloat ("Examples.example[2].h[1].c", 778.12f, 1);
894 ssbo->setVec2 ("Examples.example[2].h[1].d", OSG::Vec2f(75.7f, 73.5f));
896 OSG::Matrix4f mat24( 71.3f, 71.4f, 71.5f, 71.6f, // row 1
897 72.3f, 72.4f, 72.5f, 72.6f, // row 2
898 -73.3f,-73.4f,-73.5f,-73.6f, // row 3
899 74.3f, 74.4f, 74.5f, 74.6f ); // row 4
901 OSG::Matrix4f mat25( 71.4f, 71.5f, 71.6f, 71.7f, // row 1
902 72.4f, 72.5f, 72.6f, 72.7f, // row 2
903 73.4f, 73.5f, 73.6f, 73.7f, // row 3
904 -74.4f,-74.5f,-74.6f,-74.7f ); // row 4
906 ssbo->setMat3 ("Examples.example[2].h[1].e", mat24, 0);
907 ssbo->setMat3 ("Examples.example[2].h[1].e", mat25, 1);
908 #ifdef HAS_FP64_EXTENSION
909 ssbo->setDouble ("Examples.example[2].i", 794.345678);
910 #endif
911 ssbo->setBool ("Examples.example[2].j", true);
912 #ifdef HAS_FP64_EXTENSION
913 ssbo->setDVec2 ("Examples.example[2].k.a", OSG::Vec2d(712.874, -72346.985633));
914 #endif
915 ssbo->setInt ("Examples.example[2].k.b", 73);
916 ssbo->setFloat ("Examples.example[2].k.c[0].a", 767.81f);
917 ssbo->setIVec3 ("Examples.example[2].k.c[0].b", OSG::Vec3i(734,735,-736), 0);
918 ssbo->setIVec3 ("Examples.example[2].k.c[0].b", OSG::Vec3i(737,738,-739), 1);
919 ssbo->setIVec3 ("Examples.example[2].k.c[0].b", OSG::Vec3i(740,741,-742), 2);
920 ssbo->setInt ("Examples.example[2].k.c[0].c", -74);
921 ssbo->setFloat ("Examples.example[2].k.c[1].a", 756.78f);
922 ssbo->setIVec3 ("Examples.example[2].k.c[1].b", OSG::Vec3i(-743,744,745), 0);
923 ssbo->setIVec3 ("Examples.example[2].k.c[1].b", OSG::Vec3i(-746,747,748), 1);
924 ssbo->setIVec3 ("Examples.example[2].k.c[1].b", OSG::Vec3i(-749,750,751), 2);
925 ssbo->setInt ("Examples.example[2].k.c[1].c", -75);
926 ssbo->setFloat ("Examples.example[2].k.c[2].a", 745.67f);
927 ssbo->setIVec3 ("Examples.example[2].k.c[2].b", OSG::Vec3i(752,-753,754), 0);
928 ssbo->setIVec3 ("Examples.example[2].k.c[2].b", OSG::Vec3i(755,-756,757), 1);
929 ssbo->setIVec3 ("Examples.example[2].k.c[2].b", OSG::Vec3i(758,-759,760), 2);
930 ssbo->setInt ("Examples.example[2].k.c[2].c", -76);
931 ssbo->setFloat ("Examples.example[2].k.c[3].a", 734.56f);
932 ssbo->setIVec3 ("Examples.example[2].k.c[3].b", OSG::Vec3i(761,762,-763), 0);
933 ssbo->setIVec3 ("Examples.example[2].k.c[3].b", OSG::Vec3i(764,-765,766), 1);
934 ssbo->setIVec3 ("Examples.example[2].k.c[3].b", OSG::Vec3i(-767,768,769), 2);
935 ssbo->setInt ("Examples.example[2].k.c[3].c", 7);
939 // vertex shader program.
941 std::string get_vp_program();
944 // fragment shader program for bump mapping in surface local coordinates
946 std::string get_fp_program();
949 // a separate transformation for every object
951 OSG::TransformRefPtr cyltrans, tortrans;
954 // forward declaration so we can have the interesting stuff upfront
956 int setupGLUT(int *argc, char *argv[]);
959 // redraw the window
961 void display(void)
963 // create the matrix
964 OSG::Matrix m;
965 OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME );
967 // set the transforms' matrices
968 m.setTransform(OSG::Vec3f(0, 0, OSG::osgSin(t / 1000.f) * 1.5),
969 OSG::Quaternion( OSG::Vec3f (1, 0, 0), t / 500.f));
971 cyltrans->setMatrix(m);
973 m.setTransform(OSG::Vec3f(OSG::osgSin(t / 1000.f), 0, 0),
974 OSG::Quaternion( OSG::Vec3f (0, 0, 1), t / 1000.f));
976 tortrans->setMatrix(m);
978 OSG::commitChanges();
980 mgr->redraw();
984 // Initialize GLUT & OpenSG and set up the scene
986 int main(int argc, char **argv)
988 // OSG init
989 OSG::osgInit(argc,argv);
991 // GLUT init
992 int winid = setupGLUT(&argc, argv);
994 // open a new scope, because the pointers below should go out of scope
995 // before entering glutMainLoop.
996 // Otherwise OpenSG will complain about objects being alive after shutdown.
998 // the connection between GLUT and OpenSG
999 OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
1000 gwin->setGlutId(winid);
1001 gwin->init();
1003 // create the SimpleSceneManager helper
1004 mgr = OSG::SimpleSceneManager::create();
1005 mgr->setWindow(gwin);
1007 // create a pretty simple graph: a Group with two Transforms as children,
1008 // each of which carries a single Geometry.
1010 // The scene
1012 OSG::NodeRefPtr scene = OSG::Node::create();
1014 // The cylinder and its transformation
1015 OSG::NodeRefPtr cyl = OSG::Node::create();
1016 OSG::GeometryRefPtr cylgeo = OSG::makeCylinderGeo( 1.4f, .3f, 24,
1017 true, true, true );
1019 cyl->setCore(cylgeo);
1021 cyltrans = OSG::Transform::create();
1023 OSG::NodeRefPtr cyltransnode = OSG::Node::create();
1024 cyltransnode->setCore (cyltrans);
1025 cyltransnode->addChild(cyl );
1027 // add it to the scene
1028 scene->addChild(cyltransnode);
1030 // The torus and its transformation
1031 OSG::NodeRefPtr torus = OSG::Node::create();
1032 OSG::GeometryRefPtr torusgeo = OSG::makeTorusGeo( .2f, 1, 24, 36 );
1034 torus->setCore(torusgeo);
1036 tortrans = OSG::Transform::create();
1038 OSG::NodeRefPtr tortransnode = OSG::Node::create();
1039 tortransnode->setCore (tortrans);
1040 tortransnode->addChild(torus );
1042 // add it to the scene
1043 scene->addChild(tortransnode);
1046 // create the shader program
1048 OSG::ShaderProgramChunkRefPtr prog_chunk = OSG::ShaderProgramChunk::create();
1049 OSG::ShaderProgramRefPtr vertShader = OSG::ShaderProgram::createVertexShader();
1050 OSG::ShaderProgramRefPtr fragShader = OSG::ShaderProgram::createFragmentShader();
1052 vertShader->setProgram(get_vp_program());
1053 fragShader->setProgram(get_fp_program());
1056 // binding the shader storage block to a buffer binding point can be performed
1057 // either by calling the shaders's addShaderStorageBlock method or by
1058 // adding a 'buffer block' variable to a ShaderProgramVariableChunk.
1059 // In the following we use both variants for illustration.
1061 fragShader->addShaderStorageBlock("Examples", 1); // block binding point
1063 prog_chunk->addShader(vertShader);
1064 prog_chunk->addShader(fragShader);
1067 // create shader storage buffer object for block 'Examples'
1069 OSG::ShaderStorageBufferObjChunkRefPtr ssbo_example_block = create_example_block_state();
1071 update_example_block_state(ssbo_example_block);
1073 OSG::PolygonChunkRefPtr polygon_chunk = OSG::PolygonChunk::create();
1074 polygon_chunk->setFrontMode(GL_FILL);
1075 polygon_chunk->setBackMode(GL_FILL);
1076 polygon_chunk->setCullFace(GL_NONE);
1078 OSG::DepthChunkRefPtr depth_chunk = OSG::DepthChunk::create();
1079 depth_chunk->setEnable(true);
1081 OSG::ChunkMaterialRefPtr prog_state = OSG::ChunkMaterial::create();
1082 prog_state->addChunk(ssbo_example_block, 1); // buffer binding point 1
1083 prog_state->addChunk(prog_chunk);
1084 prog_state->addChunk(polygon_chunk);
1085 prog_state->addChunk(depth_chunk);
1087 OSG::MaterialChunkOverrideGroupRefPtr mgrp = OSG::MaterialChunkOverrideGroup::create();
1088 mgrp->setMaterial(prog_state);
1089 scene->setCore(mgrp);
1091 OSG::commitChanges();
1093 mgr->setRoot(scene);
1095 // show the whole scene
1096 mgr->showAll();
1099 // GLUT main loop
1100 glutMainLoop();
1102 return 0;
1106 // GLUT callback functions
1110 // react to size changes
1112 void reshape(int w, int h)
1114 mgr->resize(w, h);
1115 glutPostRedisplay();
1119 // react to mouse button presses
1121 void mouse(int button, int state, int x, int y)
1123 if (state)
1124 mgr->mouseButtonRelease(button, x, y);
1125 else
1126 mgr->mouseButtonPress(button, x, y);
1128 glutPostRedisplay();
1132 // react to mouse motions with pressed buttons
1134 void motion(int x, int y)
1136 mgr->mouseMove(x, y);
1137 glutPostRedisplay();
1141 // react to keys
1143 void keyboard(unsigned char k, int x, int y)
1145 switch(k)
1147 case 27:
1149 // clean up global variables
1150 cyltrans = NULL;
1151 tortrans = NULL;
1152 mgr = NULL;
1154 OSG::osgExit();
1155 exit(0);
1157 break;
1159 case 's':
1161 mgr->setStatistics(!mgr->getStatistics());
1163 break;
1168 // setup the GLUT library which handles the windows for us
1170 int setupGLUT(int *argc, char *argv[])
1172 glutInit(argc, argv);
1173 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
1175 int winid = glutCreateWindow("OpenSG");
1177 glutReshapeFunc(reshape);
1178 glutDisplayFunc(display);
1179 glutMouseFunc(mouse);
1180 glutMotionFunc(motion);
1181 glutKeyboardFunc(keyboard);
1183 // call the redraw function whenever there's nothing else to do
1184 glutIdleFunc(display);
1186 return winid;
1190 // vertex shader program.
1192 std::string get_vp_program()
1194 std::string vp_program =
1195 "\n"
1196 "#version 330 compatibility\n"
1197 "\n"
1198 "#extension GL_ARB_separate_shader_objects: enable\n"
1199 "#extension GL_ARB_uniform_buffer_object: enable\n"
1200 "\n"
1201 "void main()\n"
1202 "{\n"
1203 " gl_Position = ftransform();\n"
1204 "}\n"
1205 "\n"
1208 return vp_program;
1212 // fragment shader program for bump mapping in surface local coordinates
1214 std::string get_fp_program()
1216 std::string fp_program =
1217 "\n"
1218 "#version 440 compatibility\n"
1219 "\n"
1220 "#extension GL_ARB_separate_shader_objects: enable\n"
1221 "#extension GL_ARB_shader_storage_buffer_object: enable\n"
1222 "\n"
1223 #ifdef HAS_FP64_EXTENSION
1224 "#extension GL_ARB_gpu_shader_fp64: enable\n"
1225 #endif
1226 "\n"
1227 "struct TestA\n"
1228 "{\n"
1229 " float a;\n"
1230 " ivec3 b[3];\n"
1231 " int c;\n"
1232 "};\n"
1233 "\n"
1234 "struct TestB\n"
1235 "{\n"
1236 " bvec2 a;\n"
1237 " TestA b[2];\n"
1238 " float c;\n"
1239 "};\n"
1240 "\n"
1241 "struct TestC\n"
1242 "{\n"
1243 " float a;\n"
1244 " bvec2 b;\n"
1245 " TestB c[2];\n"
1246 "};\n"
1247 "\n"
1248 "struct TestD\n"
1249 "{\n"
1250 " uvec3 a;\n"
1251 " vec2 b;\n"
1252 " float c[2];\n"
1253 " vec2 d;\n"
1254 " mat3 e[2];\n"
1255 "};\n"
1256 "\n"
1257 "struct TestE\n"
1258 "{\n"
1259 #ifdef HAS_FP64_EXTENSION
1260 " dvec2 a;\n"
1261 #endif
1262 " int b;\n"
1263 " TestA c[4];\n"
1264 "};\n"
1265 "\n"
1266 "struct Example\n"
1267 "{\n"
1268 " float a;\n"
1269 " vec2 b;\n"
1270 " vec3 c;\n"
1271 " TestC d;\n"
1272 " float e;\n"
1273 " float f[2];\n"
1274 " mat2x3 g;\n"
1275 " TestD h[2];\n"
1276 #ifdef HAS_FP64_EXTENSION
1277 " double i;\n"
1278 #endif
1279 " bool j;\n"
1280 " TestE k;\n"
1281 "};\n"
1282 "\n"
1283 "layout (shared) buffer Examples\n"
1284 "{\n"
1285 " Example example[3];\n"
1286 "} examples;\n"
1287 "\n"
1288 "\n"
1289 "layout(location = 0) out vec4 vFragColor;\n"
1290 "\n"
1291 "\n"
1292 "void main()\n"
1293 "{\n"
1294 "\n"
1295 " vec4 error = vec4(1.0, 0.0, 0.0, 1.0);\n"
1296 " vec4 color = vec4(0.0, 1.0, 0.0, 1.0);\n"
1297 "\n"
1298 "\n"
1299 " float examples_example_0_a = examples.example[0].a;\n"
1300 " vec2 examples_example_0_b = examples.example[0].b;\n"
1301 " vec3 examples_example_0_c = examples.example[0].c;\n"
1302 " float examples_example_0_d_a = examples.example[0].d.a;\n"
1303 " bvec2 examples_example_0_d_b = examples.example[0].d.b;\n"
1304 " bvec2 examples_example_0_d_c_0_a = examples.example[0].d.c[0].a;\n"
1305 " float examples_example_0_d_c_0_b_0_a = examples.example[0].d.c[0].b[0].a;\n"
1306 " ivec3 examples_example_0_d_c_0_b_0_b_0 = examples.example[0].d.c[0].b[0].b[0];\n"
1307 " ivec3 examples_example_0_d_c_0_b_0_b_1 = examples.example[0].d.c[0].b[0].b[1];\n"
1308 " ivec3 examples_example_0_d_c_0_b_0_b_2 = examples.example[0].d.c[0].b[0].b[2];\n"
1309 " int examples_example_0_d_c_0_b_0_c = examples.example[0].d.c[0].b[0].c;\n"
1310 " float examples_example_0_d_c_0_b_1_a = examples.example[0].d.c[0].b[1].a;\n"
1311 " ivec3 examples_example_0_d_c_0_b_1_b_0 = examples.example[0].d.c[0].b[1].b[0];\n"
1312 " ivec3 examples_example_0_d_c_0_b_1_b_1 = examples.example[0].d.c[0].b[1].b[1];\n"
1313 " ivec3 examples_example_0_d_c_0_b_1_b_2 = examples.example[0].d.c[0].b[1].b[2];\n"
1314 " int examples_example_0_d_c_0_b_1_c = examples.example[0].d.c[0].b[1].c;\n"
1315 " float examples_example_0_d_c_0_c = examples.example[0].d.c[0].c;\n"
1316 " bvec2 examples_example_0_d_c_1_a = examples.example[0].d.c[1].a;\n"
1317 " float examples_example_0_d_c_1_b_0_a = examples.example[0].d.c[1].b[0].a;\n"
1318 " ivec3 examples_example_0_d_c_1_b_0_b_0 = examples.example[0].d.c[1].b[0].b[0];\n"
1319 " ivec3 examples_example_0_d_c_1_b_0_b_1 = examples.example[0].d.c[1].b[0].b[1];\n"
1320 " ivec3 examples_example_0_d_c_1_b_0_b_2 = examples.example[0].d.c[1].b[0].b[2];\n"
1321 " int examples_example_0_d_c_1_b_0_c = examples.example[0].d.c[1].b[0].c;\n"
1322 " float examples_example_0_d_c_1_b_1_a = examples.example[0].d.c[1].b[1].a;\n"
1323 " ivec3 examples_example_0_d_c_1_b_1_b_0 = examples.example[0].d.c[1].b[1].b[0];\n"
1324 " ivec3 examples_example_0_d_c_1_b_1_b_1 = examples.example[0].d.c[1].b[1].b[1];\n"
1325 " ivec3 examples_example_0_d_c_1_b_1_b_2 = examples.example[0].d.c[1].b[1].b[2];\n"
1326 " int examples_example_0_d_c_1_b_1_c = examples.example[0].d.c[1].b[1].c;\n"
1327 " float examples_example_0_d_c_1_c = examples.example[0].d.c[1].c;\n"
1328 " float examples_example_0_e = examples.example[0].e;\n"
1329 " float examples_example_0_f_0 = examples.example[0].f[0];\n"
1330 " float examples_example_0_f_1 = examples.example[0].f[1];\n"
1331 " mat2x3 examples_example_0_g = examples.example[0].g;\n"
1332 " uvec3 examples_example_0_h_0_a = examples.example[0].h[0].a;\n"
1333 " vec2 examples_example_0_h_0_b = examples.example[0].h[0].b;\n"
1334 " float examples_example_0_h_0_c_0 = examples.example[0].h[0].c[0];\n"
1335 " float examples_example_0_h_0_c_1 = examples.example[0].h[0].c[1];\n"
1336 " vec2 examples_example_0_h_0_d = examples.example[0].h[0].d;\n"
1337 " mat3 examples_example_0_h_0_e_0 = examples.example[0].h[0].e[0];\n"
1338 " mat3 examples_example_0_h_0_e_1 = examples.example[0].h[0].e[1];\n"
1339 " uvec3 examples_example_0_h_1_a = examples.example[0].h[1].a;\n"
1340 " vec2 examples_example_0_h_1_b = examples.example[0].h[1].b;\n"
1341 " float examples_example_0_h_1_c_0 = examples.example[0].h[1].c[0];\n"
1342 " float examples_example_0_h_1_c_1 = examples.example[0].h[1].c[1];\n"
1343 " vec2 examples_example_0_h_1_d = examples.example[0].h[1].d;\n"
1344 " mat3 examples_example_0_h_1_e_0 = examples.example[0].h[1].e[0];\n"
1345 " mat3 examples_example_0_h_1_e_1 = examples.example[0].h[1].e[1];\n"
1346 #ifdef HAS_FP64_EXTENSION
1347 " double examples_example_0_i = examples.example[0].i;\n"
1348 #endif
1349 " bool examples_example_0_j = examples.example[0].j;\n"
1350 #ifdef HAS_FP64_EXTENSION
1351 " dvec2 examples_example_0_k_a = examples.example[0].k.a;\n"
1352 #endif
1353 " int examples_example_0_k_b = examples.example[0].k.b;\n"
1354 " float examples_example_0_k_c_0_a = examples.example[0].k.c[0].a;\n"
1355 " ivec3 examples_example_0_k_c_0_b_0 = examples.example[0].k.c[0].b[0];\n"
1356 " ivec3 examples_example_0_k_c_0_b_1 = examples.example[0].k.c[0].b[1];\n"
1357 " ivec3 examples_example_0_k_c_0_b_2 = examples.example[0].k.c[0].b[2];\n"
1358 " int examples_example_0_k_c_0_c = examples.example[0].k.c[0].c;\n"
1359 " float examples_example_0_k_c_1_a = examples.example[0].k.c[1].a;\n"
1360 " ivec3 examples_example_0_k_c_1_b_0 = examples.example[0].k.c[1].b[0];\n"
1361 " ivec3 examples_example_0_k_c_1_b_1 = examples.example[0].k.c[1].b[1];\n"
1362 " ivec3 examples_example_0_k_c_1_b_2 = examples.example[0].k.c[1].b[2];\n"
1363 " int examples_example_0_k_c_1_c = examples.example[0].k.c[1].c;\n"
1364 " float examples_example_0_k_c_2_a = examples.example[0].k.c[2].a;\n"
1365 " ivec3 examples_example_0_k_c_2_b_0 = examples.example[0].k.c[2].b[0];\n"
1366 " ivec3 examples_example_0_k_c_2_b_1 = examples.example[0].k.c[2].b[1];\n"
1367 " ivec3 examples_example_0_k_c_2_b_2 = examples.example[0].k.c[2].b[2];\n"
1368 " int examples_example_0_k_c_2_c = examples.example[0].k.c[2].c;\n"
1369 " float examples_example_0_k_c_3_a = examples.example[0].k.c[3].a;\n"
1370 " ivec3 examples_example_0_k_c_3_b_0 = examples.example[0].k.c[3].b[0];\n"
1371 " ivec3 examples_example_0_k_c_3_b_1 = examples.example[0].k.c[3].b[1];\n"
1372 " ivec3 examples_example_0_k_c_3_b_2 = examples.example[0].k.c[3].b[2];\n"
1373 " int examples_example_0_k_c_3_c = examples.example[0].k.c[3].c;\n"
1374 "\n"
1375 " float examples_example_1_a = examples.example[1].a;\n"
1376 " vec2 examples_example_1_b = examples.example[1].b;\n"
1377 " vec3 examples_example_1_c = examples.example[1].c;\n"
1378 " float examples_example_1_d_a = examples.example[1].d.a;\n"
1379 " bvec2 examples_example_1_d_b = examples.example[1].d.b;\n"
1380 " bvec2 examples_example_1_d_c_0_a = examples.example[1].d.c[0].a;\n"
1381 " float examples_example_1_d_c_0_b_0_a = examples.example[1].d.c[0].b[0].a;\n"
1382 " ivec3 examples_example_1_d_c_0_b_0_b_0 = examples.example[1].d.c[0].b[0].b[0];\n"
1383 " ivec3 examples_example_1_d_c_0_b_0_b_1 = examples.example[1].d.c[0].b[0].b[1];\n"
1384 " ivec3 examples_example_1_d_c_0_b_0_b_2 = examples.example[1].d.c[0].b[0].b[2];\n"
1385 " int examples_example_1_d_c_0_b_0_c = examples.example[1].d.c[0].b[0].c;\n"
1386 " float examples_example_1_d_c_0_b_1_a = examples.example[1].d.c[0].b[1].a;\n"
1387 " ivec3 examples_example_1_d_c_0_b_1_b_0 = examples.example[1].d.c[0].b[1].b[0];\n"
1388 " ivec3 examples_example_1_d_c_0_b_1_b_1 = examples.example[1].d.c[0].b[1].b[1];\n"
1389 " ivec3 examples_example_1_d_c_0_b_1_b_2 = examples.example[1].d.c[0].b[1].b[2];\n"
1390 " int examples_example_1_d_c_0_b_1_c = examples.example[1].d.c[0].b[1].c;\n"
1391 " float examples_example_1_d_c_0_c = examples.example[1].d.c[0].c;\n"
1392 " bvec2 examples_example_1_d_c_1_a = examples.example[1].d.c[1].a;\n"
1393 " float examples_example_1_d_c_1_b_0_a = examples.example[1].d.c[1].b[0].a;\n"
1394 " ivec3 examples_example_1_d_c_1_b_0_b_0 = examples.example[1].d.c[1].b[0].b[0];\n"
1395 " ivec3 examples_example_1_d_c_1_b_0_b_1 = examples.example[1].d.c[1].b[0].b[1];\n"
1396 " ivec3 examples_example_1_d_c_1_b_0_b_2 = examples.example[1].d.c[1].b[0].b[2];\n"
1397 " int examples_example_1_d_c_1_b_0_c = examples.example[1].d.c[1].b[0].c;\n"
1398 " float examples_example_1_d_c_1_b_1_a = examples.example[1].d.c[1].b[1].a;\n"
1399 " ivec3 examples_example_1_d_c_1_b_1_b_0 = examples.example[1].d.c[1].b[1].b[0];\n"
1400 " ivec3 examples_example_1_d_c_1_b_1_b_1 = examples.example[1].d.c[1].b[1].b[1];\n"
1401 " ivec3 examples_example_1_d_c_1_b_1_b_2 = examples.example[1].d.c[1].b[1].b[2];\n"
1402 " int examples_example_1_d_c_1_b_1_c = examples.example[1].d.c[1].b[1].c;\n"
1403 " float examples_example_1_d_c_1_c = examples.example[1].d.c[1].c;\n"
1404 " float examples_example_1_e = examples.example[1].e;\n"
1405 " float examples_example_1_f_0 = examples.example[1].f[0];\n"
1406 " float examples_example_1_f_1 = examples.example[1].f[1];\n"
1407 " mat2x3 examples_example_1_g = examples.example[1].g;\n"
1408 " uvec3 examples_example_1_h_0_a = examples.example[1].h[0].a;\n"
1409 " vec2 examples_example_1_h_0_b = examples.example[1].h[0].b;\n"
1410 " float examples_example_1_h_0_c_0 = examples.example[1].h[0].c[0];\n"
1411 " float examples_example_1_h_0_c_1 = examples.example[1].h[0].c[1];\n"
1412 " vec2 examples_example_1_h_0_d = examples.example[1].h[0].d;\n"
1413 " mat3 examples_example_1_h_0_e_0 = examples.example[1].h[0].e[0];\n"
1414 " mat3 examples_example_1_h_0_e_1 = examples.example[1].h[0].e[1];\n"
1415 " uvec3 examples_example_1_h_1_a = examples.example[1].h[1].a;\n"
1416 " vec2 examples_example_1_h_1_b = examples.example[1].h[1].b;\n"
1417 " float examples_example_1_h_1_c_0 = examples.example[1].h[1].c[0];\n"
1418 " float examples_example_1_h_1_c_1 = examples.example[1].h[1].c[1];\n"
1419 " vec2 examples_example_1_h_1_d = examples.example[1].h[1].d;\n"
1420 " mat3 examples_example_1_h_1_e_0 = examples.example[1].h[1].e[0];\n"
1421 " mat3 examples_example_1_h_1_e_1 = examples.example[1].h[1].e[1];\n"
1422 #ifdef HAS_FP64_EXTENSION
1423 " double examples_example_1_i = examples.example[1].i;\n"
1424 #endif
1425 " bool examples_example_1_j = examples.example[1].j;\n"
1426 #ifdef HAS_FP64_EXTENSION
1427 " dvec2 examples_example_1_k_a = examples.example[1].k.a;\n"
1428 #endif
1429 " int examples_example_1_k_b = examples.example[1].k.b;\n"
1430 " float examples_example_1_k_c_0_a = examples.example[1].k.c[0].a;\n"
1431 " ivec3 examples_example_1_k_c_0_b_0 = examples.example[1].k.c[0].b[0];\n"
1432 " ivec3 examples_example_1_k_c_0_b_1 = examples.example[1].k.c[0].b[1];\n"
1433 " ivec3 examples_example_1_k_c_0_b_2 = examples.example[1].k.c[0].b[2];\n"
1434 " int examples_example_1_k_c_0_c = examples.example[1].k.c[0].c;\n"
1435 " float examples_example_1_k_c_1_a = examples.example[1].k.c[1].a;\n"
1436 " ivec3 examples_example_1_k_c_1_b_0 = examples.example[1].k.c[1].b[0];\n"
1437 " ivec3 examples_example_1_k_c_1_b_1 = examples.example[1].k.c[1].b[1];\n"
1438 " ivec3 examples_example_1_k_c_1_b_2 = examples.example[1].k.c[1].b[2];\n"
1439 " int examples_example_1_k_c_1_c = examples.example[1].k.c[1].c;\n"
1440 " float examples_example_1_k_c_2_a = examples.example[1].k.c[2].a;\n"
1441 " ivec3 examples_example_1_k_c_2_b_0 = examples.example[1].k.c[2].b[0];\n"
1442 " ivec3 examples_example_1_k_c_2_b_1 = examples.example[1].k.c[2].b[1];\n"
1443 " ivec3 examples_example_1_k_c_2_b_2 = examples.example[1].k.c[2].b[2];\n"
1444 " int examples_example_1_k_c_2_c = examples.example[1].k.c[2].c;\n"
1445 " float examples_example_1_k_c_3_a = examples.example[1].k.c[3].a;\n"
1446 " ivec3 examples_example_1_k_c_3_b_0 = examples.example[1].k.c[3].b[0];\n"
1447 " ivec3 examples_example_1_k_c_3_b_1 = examples.example[1].k.c[3].b[1];\n"
1448 " ivec3 examples_example_1_k_c_3_b_2 = examples.example[1].k.c[3].b[2];\n"
1449 " int examples_example_1_k_c_3_c = examples.example[1].k.c[3].c;\n"
1450 "\n"
1451 " float examples_example_2_a = examples.example[2].a;\n"
1452 " vec2 examples_example_2_b = examples.example[2].b;\n"
1453 " vec3 examples_example_2_c = examples.example[2].c;\n"
1454 " float examples_example_2_d_a = examples.example[2].d.a;\n"
1455 " bvec2 examples_example_2_d_b = examples.example[2].d.b;\n"
1456 " bvec2 examples_example_2_d_c_0_a = examples.example[2].d.c[0].a;\n"
1457 " float examples_example_2_d_c_0_b_0_a = examples.example[2].d.c[0].b[0].a;\n"
1458 " ivec3 examples_example_2_d_c_0_b_0_b_0 = examples.example[2].d.c[0].b[0].b[0];\n"
1459 " ivec3 examples_example_2_d_c_0_b_0_b_1 = examples.example[2].d.c[0].b[0].b[1];\n"
1460 " ivec3 examples_example_2_d_c_0_b_0_b_2 = examples.example[2].d.c[0].b[0].b[2];\n"
1461 " int examples_example_2_d_c_0_b_0_c = examples.example[2].d.c[0].b[0].c;\n"
1462 " float examples_example_2_d_c_0_b_1_a = examples.example[2].d.c[0].b[1].a;\n"
1463 " ivec3 examples_example_2_d_c_0_b_1_b_0 = examples.example[2].d.c[0].b[1].b[0];\n"
1464 " ivec3 examples_example_2_d_c_0_b_1_b_1 = examples.example[2].d.c[0].b[1].b[1];\n"
1465 " ivec3 examples_example_2_d_c_0_b_1_b_2 = examples.example[2].d.c[0].b[1].b[2];\n"
1466 " int examples_example_2_d_c_0_b_1_c = examples.example[2].d.c[0].b[1].c;\n"
1467 " float examples_example_2_d_c_0_c = examples.example[2].d.c[0].c;\n"
1468 " bvec2 examples_example_2_d_c_1_a = examples.example[2].d.c[1].a;\n"
1469 " float examples_example_2_d_c_1_b_0_a = examples.example[2].d.c[1].b[0].a;\n"
1470 " ivec3 examples_example_2_d_c_1_b_0_b_0 = examples.example[2].d.c[1].b[0].b[0];\n"
1471 " ivec3 examples_example_2_d_c_1_b_0_b_1 = examples.example[2].d.c[1].b[0].b[1];\n"
1472 " ivec3 examples_example_2_d_c_1_b_0_b_2 = examples.example[2].d.c[1].b[0].b[2];\n"
1473 " int examples_example_2_d_c_1_b_0_c = examples.example[2].d.c[1].b[0].c;\n"
1474 " float examples_example_2_d_c_1_b_1_a = examples.example[2].d.c[1].b[1].a;\n"
1475 " ivec3 examples_example_2_d_c_1_b_1_b_0 = examples.example[2].d.c[1].b[1].b[0];\n"
1476 " ivec3 examples_example_2_d_c_1_b_1_b_1 = examples.example[2].d.c[1].b[1].b[1];\n"
1477 " ivec3 examples_example_2_d_c_1_b_1_b_2 = examples.example[2].d.c[1].b[1].b[2];\n"
1478 " int examples_example_2_d_c_1_b_1_c = examples.example[2].d.c[1].b[1].c;\n"
1479 " float examples_example_2_d_c_1_c = examples.example[2].d.c[1].c;\n"
1480 " float examples_example_2_e = examples.example[2].e;\n"
1481 " float examples_example_2_f_0 = examples.example[2].f[0];\n"
1482 " float examples_example_2_f_1 = examples.example[2].f[1];\n"
1483 " mat2x3 examples_example_2_g = examples.example[2].g;\n"
1484 " uvec3 examples_example_2_h_0_a = examples.example[2].h[0].a;\n"
1485 " vec2 examples_example_2_h_0_b = examples.example[2].h[0].b;\n"
1486 " float examples_example_2_h_0_c_0 = examples.example[2].h[0].c[0];\n"
1487 " float examples_example_2_h_0_c_1 = examples.example[2].h[0].c[1];\n"
1488 " vec2 examples_example_2_h_0_d = examples.example[2].h[0].d;\n"
1489 " mat3 examples_example_2_h_0_e_0 = examples.example[2].h[0].e[0];\n"
1490 " mat3 examples_example_2_h_0_e_1 = examples.example[2].h[0].e[1];\n"
1491 " uvec3 examples_example_2_h_1_a = examples.example[2].h[1].a;\n"
1492 " vec2 examples_example_2_h_1_b = examples.example[2].h[1].b;\n"
1493 " float examples_example_2_h_1_c_0 = examples.example[2].h[1].c[0];\n"
1494 " float examples_example_2_h_1_c_1 = examples.example[2].h[1].c[1];\n"
1495 " vec2 examples_example_2_h_1_d = examples.example[2].h[1].d;\n"
1496 " mat3 examples_example_2_h_1_e_0 = examples.example[2].h[1].e[0];\n"
1497 " mat3 examples_example_2_h_1_e_1 = examples.example[2].h[1].e[1];\n"
1498 #ifdef HAS_FP64_EXTENSION
1499 " double examples_example_2_i = examples.example[2].i;\n"
1500 #endif
1501 " bool examples_example_2_j = examples.example[2].j;\n"
1502 #ifdef HAS_FP64_EXTENSION
1503 " dvec2 examples_example_2_k_a = examples.example[2].k.a;\n"
1504 #endif
1505 " int examples_example_2_k_b = examples.example[2].k.b;\n"
1506 " float examples_example_2_k_c_0_a = examples.example[2].k.c[0].a;\n"
1507 " ivec3 examples_example_2_k_c_0_b_0 = examples.example[2].k.c[0].b[0];\n"
1508 " ivec3 examples_example_2_k_c_0_b_1 = examples.example[2].k.c[0].b[1];\n"
1509 " ivec3 examples_example_2_k_c_0_b_2 = examples.example[2].k.c[0].b[2];\n"
1510 " int examples_example_2_k_c_0_c = examples.example[2].k.c[0].c;\n"
1511 " float examples_example_2_k_c_1_a = examples.example[2].k.c[1].a;\n"
1512 " ivec3 examples_example_2_k_c_1_b_0 = examples.example[2].k.c[1].b[0];\n"
1513 " ivec3 examples_example_2_k_c_1_b_1 = examples.example[2].k.c[1].b[1];\n"
1514 " ivec3 examples_example_2_k_c_1_b_2 = examples.example[2].k.c[1].b[2];\n"
1515 " int examples_example_2_k_c_1_c = examples.example[2].k.c[1].c;\n"
1516 " float examples_example_2_k_c_2_a = examples.example[2].k.c[2].a;\n"
1517 " ivec3 examples_example_2_k_c_2_b_0 = examples.example[2].k.c[2].b[0];\n"
1518 " ivec3 examples_example_2_k_c_2_b_1 = examples.example[2].k.c[2].b[1];\n"
1519 " ivec3 examples_example_2_k_c_2_b_2 = examples.example[2].k.c[2].b[2];\n"
1520 " int examples_example_2_k_c_2_c = examples.example[2].k.c[2].c;\n"
1521 " float examples_example_2_k_c_3_a = examples.example[2].k.c[3].a;\n"
1522 " ivec3 examples_example_2_k_c_3_b_0 = examples.example[2].k.c[3].b[0];\n"
1523 " ivec3 examples_example_2_k_c_3_b_1 = examples.example[2].k.c[3].b[1];\n"
1524 " ivec3 examples_example_2_k_c_3_b_2 = examples.example[2].k.c[3].b[2];\n"
1525 " int examples_example_2_k_c_3_c = examples.example[2].k.c[3].c;\n"
1526 "\n"
1527 "\n"
1528 " if (examples_example_0_a != 1234.56) color = error;\n"
1529 " if (examples_example_0_b != vec2(1.4, 8.6)) color = error;\n"
1530 " if (examples_example_0_c != vec3(0.1, 0.2, 0.3)) color = error;\n"
1531 " if (examples_example_0_d_a != 8123.45) color = error;\n"
1532 " if (examples_example_0_d_b != bvec2(true, false)) color = error;\n"
1533 " if (examples_example_0_d_c_0_a != bvec2(true, true)) color = error;\n"
1534 " if (examples_example_0_d_c_0_b_0_a != 7812.34) color = error;\n"
1535 " if (examples_example_0_d_c_0_b_0_b_0 != ivec3(0,-1,2)) color = error;\n"
1536 " if (examples_example_0_d_c_0_b_0_b_1 != ivec3(1,-2,3)) color = error;\n"
1537 " if (examples_example_0_d_c_0_b_0_b_2 != ivec3(4,-5,6)) color = error;\n"
1538 " if (examples_example_0_d_c_0_b_0_c != 6781) color = error;\n"
1539 " if (examples_example_0_d_c_0_b_1_a != 5678.12) color = error;\n"
1540 " if (examples_example_0_d_c_0_b_1_b_0 != ivec3(-7,8,9)) color = error;\n"
1541 " if (examples_example_0_d_c_0_b_1_b_1 != ivec3(-10,11,12)) color = error;\n"
1542 " if (examples_example_0_d_c_0_b_1_b_2 != ivec3(-13,14,15)) color = error;\n"
1543 " if (examples_example_0_d_c_0_b_1_c != 4567) color = error;\n"
1544 " if (examples_example_0_d_c_0_c != 3456.78) color = error;\n"
1545 " if (examples_example_0_d_c_1_a != bvec2(false, true)) color = error;\n"
1546 " if (examples_example_0_d_c_1_b_0_a != 2345.67) color = error;\n"
1547 " if (examples_example_0_d_c_1_b_0_b_0 != ivec3(16,17,-18)) color = error;\n"
1548 " if (examples_example_0_d_c_1_b_0_b_1 != ivec3(19,20,-21)) color = error;\n"
1549 " if (examples_example_0_d_c_1_b_0_b_2 != ivec3(22,23,-24)) color = error;\n"
1550 " if (examples_example_0_d_c_1_b_0_c != 123) color = error;\n"
1551 " if (examples_example_0_d_c_1_b_1_a != 812.34) color = error;\n"
1552 " if (examples_example_0_d_c_1_b_1_b_0 != ivec3(25,-26,27)) color = error;\n"
1553 " if (examples_example_0_d_c_1_b_1_b_1 != ivec3(28,-29,30)) color = error;\n"
1554 " if (examples_example_0_d_c_1_b_1_b_2 != ivec3(31,-32,33)) color = error;\n"
1555 " if (examples_example_0_d_c_1_b_1_c != 781) color = error;\n"
1556 " if (examples_example_0_d_c_1_c != 678.12) color = error;\n"
1557 " if (examples_example_0_e != 567.81) color = error;\n"
1558 " if (examples_example_0_f_0 != 456.78) color = error;\n"
1559 " if (examples_example_0_f_1 != 345.67) color = error;\n"
1560 " if (examples_example_0_g[0][0] != 11.1) color = error;\n"
1561 " if (examples_example_0_g[0][1] != 21.1) color = error;\n"
1562 " if (examples_example_0_g[0][2] != 31.1) color = error;\n"
1563 " if (examples_example_0_g[1][0] != 12.2) color = error;\n"
1564 " if (examples_example_0_g[1][1] != 22.2) color = error;\n"
1565 " if (examples_example_0_g[1][2] != 32.2) color = error;\n"
1566 " if (examples_example_0_h_0_a != uvec3(91,82,73)) color = error;\n"
1567 " if (examples_example_0_h_0_b != vec2(2.5, 9.7)) color = error;\n"
1568 " if (examples_example_0_h_0_c_0 != 234.56) color = error;\n"
1569 " if (examples_example_0_h_0_c_1 != 12.34) color = error;\n"
1570 " if (examples_example_0_h_0_d != vec2(3.6, 1.3)) color = error;\n"
1571 " if (examples_example_0_h_0_e_0[0][0] != 1.1) color = error;\n"
1572 " if (examples_example_0_h_0_e_0[0][1] != 2.1) color = error;\n"
1573 " if (examples_example_0_h_0_e_0[0][2] != 3.1) color = error;\n"
1574 " if (examples_example_0_h_0_e_0[1][0] != 1.2) color = error;\n"
1575 " if (examples_example_0_h_0_e_0[1][1] != 2.2) color = error;\n"
1576 " if (examples_example_0_h_0_e_0[1][2] != 3.2) color = error;\n"
1577 " if (examples_example_0_h_0_e_0[2][0] != 1.3) color = error;\n"
1578 " if (examples_example_0_h_0_e_0[2][1] != 2.3) color = error;\n"
1579 " if (examples_example_0_h_0_e_0[2][2] != 3.3) color = error;\n"
1580 " if (examples_example_0_h_0_e_1[0][0] != 1.2) color = error;\n"
1581 " if (examples_example_0_h_0_e_1[0][1] !=-2.2) color = error;\n"
1582 " if (examples_example_0_h_0_e_1[0][2] != 3.2) color = error;\n"
1583 " if (examples_example_0_h_0_e_1[1][0] != 1.3) color = error;\n"
1584 " if (examples_example_0_h_0_e_1[1][1] !=-2.3) color = error;\n"
1585 " if (examples_example_0_h_0_e_1[1][2] != 3.3) color = error;\n"
1586 " if (examples_example_0_h_0_e_1[2][0] != 1.4) color = error;\n"
1587 " if (examples_example_0_h_0_e_1[2][1] !=-2.4) color = error;\n"
1588 " if (examples_example_0_h_0_e_1[2][2] != 3.4) color = error;\n"
1589 " if (examples_example_0_h_1_a != uvec3(71,82,93)) color = error;\n"
1590 " if (examples_example_0_h_1_b != vec2(4.5, 2.4)) color = error;\n"
1591 " if (examples_example_0_h_1_c_0 != 81.23) color = error;\n"
1592 " if (examples_example_0_h_1_c_1 != 78.12) color = error;\n"
1593 " if (examples_example_0_h_1_d != vec2(5.7, 3.5)) color = error;\n"
1594 " if (examples_example_0_h_1_e_0[0][0] != 1.3) color = error;\n"
1595 " if (examples_example_0_h_1_e_0[0][1] != 2.3) color = error;\n"
1596 " if (examples_example_0_h_1_e_0[0][2] !=-3.3) color = error;\n"
1597 " if (examples_example_0_h_1_e_0[1][0] != 1.4) color = error;\n"
1598 " if (examples_example_0_h_1_e_0[1][1] != 2.4) color = error;\n"
1599 " if (examples_example_0_h_1_e_0[1][2] !=-3.4) color = error;\n"
1600 " if (examples_example_0_h_1_e_0[2][0] != 1.5) color = error;\n"
1601 " if (examples_example_0_h_1_e_0[2][1] != 2.5) color = error;\n"
1602 " if (examples_example_0_h_1_e_0[2][2] !=-3.5) color = error;\n"
1603 " if (examples_example_0_h_1_e_1[0][0] != 1.4) color = error;\n"
1604 " if (examples_example_0_h_1_e_1[0][1] != 2.4) color = error;\n"
1605 " if (examples_example_0_h_1_e_1[0][2] != 3.4) color = error;\n"
1606 " if (examples_example_0_h_1_e_1[1][0] != 1.5) color = error;\n"
1607 " if (examples_example_0_h_1_e_1[1][1] != 2.5) color = error;\n"
1608 " if (examples_example_0_h_1_e_1[1][2] != 3.5) color = error;\n"
1609 " if (examples_example_0_h_1_e_1[2][0] != 1.6) color = error;\n"
1610 " if (examples_example_0_h_1_e_1[2][1] != 2.6) color = error;\n"
1611 " if (examples_example_0_h_1_e_1[2][2] != 3.6) color = error;\n"
1612 #ifdef HAS_FP64_EXTENSION
1613 " if (examples_example_0_i != 94.345678LF) color = error;\n"
1614 #endif
1615 " if (examples_example_0_j != true) color = error;\n"
1616 #ifdef HAS_FP64_EXTENSION
1617 " if (examples_example_0_k_a != dvec2(12.874LF, -2346.985633LF)) color = error;\n"
1618 #endif
1619 " if (examples_example_0_k_b != 3) color = error;\n"
1620 " if (examples_example_0_k_c_0_a != 67.81) color = error;\n"
1621 " if (examples_example_0_k_c_0_b_0 != ivec3(34,35,-36)) color = error;\n"
1622 " if (examples_example_0_k_c_0_b_1 != ivec3(37,38,-39)) color = error;\n"
1623 " if (examples_example_0_k_c_0_b_2 != ivec3(40,41,-42)) color = error;\n"
1624 " if (examples_example_0_k_c_0_c != -4) color = error;\n"
1625 " if (examples_example_0_k_c_1_a != 56.78) color = error;\n"
1626 " if (examples_example_0_k_c_1_b_0 != ivec3(-43,44,45)) color = error;\n"
1627 " if (examples_example_0_k_c_1_b_1 != ivec3(-46,47,48)) color = error;\n"
1628 " if (examples_example_0_k_c_1_b_2 != ivec3(-49,50,51)) color = error;\n"
1629 " if (examples_example_0_k_c_1_c != -5) color = error;\n"
1630 " if (examples_example_0_k_c_2_a != 45.67) color = error;\n"
1631 " if (examples_example_0_k_c_2_b_0 != ivec3(52,-53,54)) color = error;\n"
1632 " if (examples_example_0_k_c_2_b_1 != ivec3(55,-56,57)) color = error;\n"
1633 " if (examples_example_0_k_c_2_b_2 != ivec3(58,-59,60)) color = error;\n"
1634 " if (examples_example_0_k_c_2_c != -6) color = error;\n"
1635 " if (examples_example_0_k_c_3_a != 34.56) color = error;\n"
1636 " if (examples_example_0_k_c_3_b_0 != ivec3(61,62,-63)) color = error;\n"
1637 " if (examples_example_0_k_c_3_b_1 != ivec3(64,-65,66)) color = error;\n"
1638 " if (examples_example_0_k_c_3_b_2 != ivec3(-67,68,69)) color = error;\n"
1639 " if (examples_example_0_k_c_3_c != 7) color = error;\n"
1640 " if (examples_example_1_a != 91234.56) color = error;\n"
1641 " if (examples_example_1_b != vec2(91.4, 98.6)) color = error;\n"
1642 " if (examples_example_1_c != vec3(90.1, 90.2, 90.3)) color = error;\n"
1643 " if (examples_example_1_d_a != 98123.45) color = error;\n"
1644 " if (examples_example_1_d_b != bvec2(false, false)) color = error;\n"
1645 " if (examples_example_1_d_c_0_a != bvec2(true, false)) color = error;\n"
1646 " if (examples_example_1_d_c_0_b_0_a != 97812.34) color = error;\n"
1647 " if (examples_example_1_d_c_0_b_0_b_0 != ivec3(90,-91,92)) color = error;\n"
1648 " if (examples_example_1_d_c_0_b_0_b_1 != ivec3(91,-92,93)) color = error;\n"
1649 " if (examples_example_1_d_c_0_b_0_b_2 != ivec3(94,-95,96)) color = error;\n"
1650 " if (examples_example_1_d_c_0_b_0_c != 6781) color = error;\n"
1651 " if (examples_example_1_d_c_0_b_1_a != 5678.12) color = error;\n"
1652 " if (examples_example_1_d_c_0_b_1_b_0 != ivec3(-97,98,99)) color = error;\n"
1653 " if (examples_example_1_d_c_0_b_1_b_1 != ivec3(-910,911,912)) color = error;\n"
1654 " if (examples_example_1_d_c_0_b_1_b_2 != ivec3(-913,914,915)) color = error;\n"
1655 " if (examples_example_1_d_c_0_b_1_c != 94567) color = error;\n"
1656 " if (examples_example_1_d_c_0_c != 93456.78) color = error;\n"
1657 " if (examples_example_1_d_c_1_a != bvec2(false, true)) color = error;\n"
1658 " if (examples_example_1_d_c_1_b_0_a != 92345.67) color = error;\n"
1659 " if (examples_example_1_d_c_1_b_0_b_0 != ivec3(916,917,-918)) color = error;\n"
1660 " if (examples_example_1_d_c_1_b_0_b_1 != ivec3(919,920,-921)) color = error;\n"
1661 " if (examples_example_1_d_c_1_b_0_b_2 != ivec3(922,923,-924)) color = error;\n"
1662 " if (examples_example_1_d_c_1_b_0_c != 9123) color = error;\n"
1663 " if (examples_example_1_d_c_1_b_1_a != 9812.34) color = error;\n"
1664 " if (examples_example_1_d_c_1_b_1_b_0 != ivec3(925,-926,927)) color = error;\n"
1665 " if (examples_example_1_d_c_1_b_1_b_1 != ivec3(928,-929,930)) color = error;\n"
1666 " if (examples_example_1_d_c_1_b_1_b_2 != ivec3(931,-932,933)) color = error;\n"
1667 " if (examples_example_1_d_c_1_b_1_c != 9781) color = error;\n"
1668 " if (examples_example_1_d_c_1_c != 9678.12) color = error;\n"
1669 " if (examples_example_1_e != 9567.81) color = error;\n"
1670 " if (examples_example_1_f_0 != 9456.78) color = error;\n"
1671 " if (examples_example_1_f_1 != 9345.67) color = error;\n"
1672 " if (examples_example_1_g[0][0] != 911.1) color = error;\n"
1673 " if (examples_example_1_g[0][1] != 921.1) color = error;\n"
1674 " if (examples_example_1_g[0][2] != 931.1) color = error;\n"
1675 " if (examples_example_1_g[1][0] != 912.2) color = error;\n"
1676 " if (examples_example_1_g[1][1] != 922.2) color = error;\n"
1677 " if (examples_example_1_g[1][2] != 932.2) color = error;\n"
1678 " if (examples_example_1_h_0_a != uvec3(991,982,973)) color = error;\n"
1679 " if (examples_example_1_h_0_b != vec2(92.5, 99.7)) color = error;\n"
1680 " if (examples_example_1_h_0_c_0 != 9234.56) color = error;\n"
1681 " if (examples_example_1_h_0_c_1 != 912.34) color = error;\n"
1682 " if (examples_example_1_h_0_d != vec2(93.6, 91.3)) color = error;\n"
1683 " if (examples_example_1_h_0_e_0[0][0] != 91.1) color = error;\n"
1684 " if (examples_example_1_h_0_e_0[0][1] != 92.1) color = error;\n"
1685 " if (examples_example_1_h_0_e_0[0][2] != 93.1) color = error;\n"
1686 " if (examples_example_1_h_0_e_0[1][0] != 91.2) color = error;\n"
1687 " if (examples_example_1_h_0_e_0[1][1] != 92.2) color = error;\n"
1688 " if (examples_example_1_h_0_e_0[1][2] != 93.2) color = error;\n"
1689 " if (examples_example_1_h_0_e_0[2][0] != 91.3) color = error;\n"
1690 " if (examples_example_1_h_0_e_0[2][1] != 92.3) color = error;\n"
1691 " if (examples_example_1_h_0_e_0[2][2] != 93.3) color = error;\n"
1692 " if (examples_example_1_h_0_e_1[0][0] != 91.2) color = error;\n"
1693 " if (examples_example_1_h_0_e_1[0][1] !=-92.2) color = error;\n"
1694 " if (examples_example_1_h_0_e_1[0][2] != 93.2) color = error;\n"
1695 " if (examples_example_1_h_0_e_1[1][0] != 91.3) color = error;\n"
1696 " if (examples_example_1_h_0_e_1[1][1] !=-92.3) color = error;\n"
1697 " if (examples_example_1_h_0_e_1[1][2] != 93.3) color = error;\n"
1698 " if (examples_example_1_h_0_e_1[2][0] != 91.4) color = error;\n"
1699 " if (examples_example_1_h_0_e_1[2][1] !=-92.4) color = error;\n"
1700 " if (examples_example_1_h_0_e_1[2][2] != 93.4) color = error;\n"
1701 " if (examples_example_1_h_1_a != uvec3(971,982,93)) color = error;\n"
1702 " if (examples_example_1_h_1_b != vec2(94.5, 92.4)) color = error;\n"
1703 " if (examples_example_1_h_1_c_0 != 981.23) color = error;\n"
1704 " if (examples_example_1_h_1_c_1 != 978.12) color = error;\n"
1705 " if (examples_example_1_h_1_d != vec2(95.7, 93.5)) color = error;\n"
1706 " if (examples_example_1_h_1_e_0[0][0] != 91.3) color = error;\n"
1707 " if (examples_example_1_h_1_e_0[0][1] != 92.3) color = error;\n"
1708 " if (examples_example_1_h_1_e_0[0][2] !=-93.3) color = error;\n"
1709 " if (examples_example_1_h_1_e_0[1][0] != 91.4) color = error;\n"
1710 " if (examples_example_1_h_1_e_0[1][1] != 92.4) color = error;\n"
1711 " if (examples_example_1_h_1_e_0[1][2] !=-93.4) color = error;\n"
1712 " if (examples_example_1_h_1_e_0[2][0] != 91.5) color = error;\n"
1713 " if (examples_example_1_h_1_e_0[2][1] != 92.5) color = error;\n"
1714 " if (examples_example_1_h_1_e_0[2][2] !=-93.5) color = error;\n"
1715 " if (examples_example_1_h_1_e_1[0][0] != 91.4) color = error;\n"
1716 " if (examples_example_1_h_1_e_1[0][1] != 92.4) color = error;\n"
1717 " if (examples_example_1_h_1_e_1[0][2] != 93.4) color = error;\n"
1718 " if (examples_example_1_h_1_e_1[1][0] != 91.5) color = error;\n"
1719 " if (examples_example_1_h_1_e_1[1][1] != 92.5) color = error;\n"
1720 " if (examples_example_1_h_1_e_1[1][2] != 93.5) color = error;\n"
1721 " if (examples_example_1_h_1_e_1[2][0] != 91.6) color = error;\n"
1722 " if (examples_example_1_h_1_e_1[2][1] != 92.6) color = error;\n"
1723 " if (examples_example_1_h_1_e_1[2][2] != 93.6) color = error;\n"
1724 #ifdef HAS_FP64_EXTENSION
1725 " if (examples_example_1_i != 994.345678LF) color = error;\n"
1726 #endif
1727 " if (examples_example_1_j != false) color = error;\n"
1728 #ifdef HAS_FP64_EXTENSION
1729 " if (examples_example_1_k_a != dvec2(912.874LF,-92346.985633LF))color = error;\n"
1730 #endif
1731 " if (examples_example_1_k_b != 93) color = error;\n"
1732 " if (examples_example_1_k_c_0_a != 967.81) color = error;\n"
1733 " if (examples_example_1_k_c_0_b_0 != ivec3(934,935,-936)) color = error;\n"
1734 " if (examples_example_1_k_c_0_b_1 != ivec3(937,938,-939)) color = error;\n"
1735 " if (examples_example_1_k_c_0_b_2 != ivec3(940,941,-942)) color = error;\n"
1736 " if (examples_example_1_k_c_0_c != -94) color = error;\n"
1737 " if (examples_example_1_k_c_1_a != 956.78) color = error;\n"
1738 " if (examples_example_1_k_c_1_b_0 != ivec3(-943,944,945)) color = error;\n"
1739 " if (examples_example_1_k_c_1_b_1 != ivec3(-946,947,948)) color = error;\n"
1740 " if (examples_example_1_k_c_1_b_2 != ivec3(-949,950,951)) color = error;\n"
1741 " if (examples_example_1_k_c_1_c != -95) color = error;\n"
1742 " if (examples_example_1_k_c_2_a != 945.67) color = error;\n"
1743 " if (examples_example_1_k_c_2_b_0 != ivec3(952,-953,954)) color = error;\n"
1744 " if (examples_example_1_k_c_2_b_1 != ivec3(955,-956,957)) color = error;\n"
1745 " if (examples_example_1_k_c_2_b_2 != ivec3(958,-959,960)) color = error;\n"
1746 " if (examples_example_1_k_c_2_c != -96) color = error;\n"
1747 " if (examples_example_1_k_c_3_a != 934.56) color = error;\n"
1748 " if (examples_example_1_k_c_3_b_0 != ivec3(961,962,-963)) color = error;\n"
1749 " if (examples_example_1_k_c_3_b_1 != ivec3(964,-965,966)) color = error;\n"
1750 " if (examples_example_1_k_c_3_b_2 != ivec3(-967,968,969)) color = error;\n"
1751 " if (examples_example_1_k_c_3_c != 97) color = error;\n"
1752 " if (examples_example_2_a != 71234.56) color = error;\n"
1753 " if (examples_example_2_b != vec2(71.4, 78.6)) color = error;\n"
1754 " if (examples_example_2_c != vec3(70.1, 70.2, 70.3)) color = error;\n"
1755 " if (examples_example_2_d_a != 78123.45) color = error;\n"
1756 " if (examples_example_2_d_b != bvec2(true, true)) color = error;\n"
1757 " if (examples_example_2_d_c_0_a != bvec2(true, false)) color = error;\n"
1758 " if (examples_example_2_d_c_0_b_0_a != 77812.34) color = error;\n"
1759 " if (examples_example_2_d_c_0_b_0_b_0 != ivec3(70,-71,72)) color = error;\n"
1760 " if (examples_example_2_d_c_0_b_0_b_1 != ivec3(71,-72,73)) color = error;\n"
1761 " if (examples_example_2_d_c_0_b_0_b_2 != ivec3(74,-75,76)) color = error;\n"
1762 " if (examples_example_2_d_c_0_b_0_c != 76781) color = error;\n"
1763 " if (examples_example_2_d_c_0_b_1_a != 75678.12) color = error;\n"
1764 " if (examples_example_2_d_c_0_b_1_b_0 != ivec3(-77,78,79)) color = error;\n"
1765 " if (examples_example_2_d_c_0_b_1_b_1 != ivec3(-710,711,712)) color = error;\n"
1766 " if (examples_example_2_d_c_0_b_1_b_2 != ivec3(-713,714,715)) color = error;\n"
1767 " if (examples_example_2_d_c_0_b_1_c != 74567) color = error;\n"
1768 " if (examples_example_2_d_c_0_c != 73456.78) color = error;\n"
1769 " if (examples_example_2_d_c_1_a != bvec2(true, true)) color = error;\n"
1770 " if (examples_example_2_d_c_1_b_0_a != 72345.67) color = error;\n"
1771 " if (examples_example_2_d_c_1_b_0_b_0 != ivec3(716,717,-718)) color = error;\n"
1772 " if (examples_example_2_d_c_1_b_0_b_1 != ivec3(719,720,-721)) color = error;\n"
1773 " if (examples_example_2_d_c_1_b_0_b_2 != ivec3(722,723,-724)) color = error;\n"
1774 " if (examples_example_2_d_c_1_b_0_c != 7123) color = error;\n"
1775 " if (examples_example_2_d_c_1_b_1_a != 7812.34) color = error;\n"
1776 " if (examples_example_2_d_c_1_b_1_b_0 != ivec3(725,-726,727)) color = error;\n"
1777 " if (examples_example_2_d_c_1_b_1_b_1 != ivec3(728,-729,730)) color = error;\n"
1778 " if (examples_example_2_d_c_1_b_1_b_2 != ivec3(731,-732,733)) color = error;\n"
1779 " if (examples_example_2_d_c_1_b_1_c != 7781) color = error;\n"
1780 " if (examples_example_2_d_c_1_c != 7678.12) color = error;\n"
1781 " if (examples_example_2_e != 7567.81) color = error;\n"
1782 " if (examples_example_2_f_0 != 7456.78) color = error;\n"
1783 " if (examples_example_2_f_1 != 7345.67) color = error;\n"
1784 " if (examples_example_2_g[0][0] != 711.1) color = error;\n"
1785 " if (examples_example_2_g[0][1] != 721.1) color = error;\n"
1786 " if (examples_example_2_g[0][2] != 731.1) color = error;\n"
1787 " if (examples_example_2_g[1][0] != 712.2) color = error;\n"
1788 " if (examples_example_2_g[1][1] != 722.2) color = error;\n"
1789 " if (examples_example_2_g[1][2] != 732.2) color = error;\n"
1790 " if (examples_example_2_h_0_a != uvec3(791,782,73)) color = error;\n"
1791 " if (examples_example_2_h_0_b != vec2(72.5, 79.7)) color = error;\n"
1792 " if (examples_example_2_h_0_c_0 != 7234.56) color = error;\n"
1793 " if (examples_example_2_h_0_c_1 != 712.34) color = error;\n"
1794 " if (examples_example_2_h_0_d != vec2(73.6, 71.3)) color = error;\n"
1795 " if (examples_example_2_h_0_e_0[0][0] != 71.1) color = error;\n"
1796 " if (examples_example_2_h_0_e_0[0][1] != 72.1) color = error;\n"
1797 " if (examples_example_2_h_0_e_0[0][2] != 73.1) color = error;\n"
1798 " if (examples_example_2_h_0_e_0[1][0] != 71.2) color = error;\n"
1799 " if (examples_example_2_h_0_e_0[1][1] != 72.2) color = error;\n"
1800 " if (examples_example_2_h_0_e_0[1][2] != 73.2) color = error;\n"
1801 " if (examples_example_2_h_0_e_0[2][0] != 71.3) color = error;\n"
1802 " if (examples_example_2_h_0_e_0[2][1] != 72.3) color = error;\n"
1803 " if (examples_example_2_h_0_e_0[2][2] != 73.3) color = error;\n"
1804 " if (examples_example_2_h_0_e_1[0][0] != 71.2) color = error;\n"
1805 " if (examples_example_2_h_0_e_1[0][1] !=-72.2) color = error;\n"
1806 " if (examples_example_2_h_0_e_1[0][2] != 73.2) color = error;\n"
1807 " if (examples_example_2_h_0_e_1[1][0] != 71.3) color = error;\n"
1808 " if (examples_example_2_h_0_e_1[1][1] !=-72.3) color = error;\n"
1809 " if (examples_example_2_h_0_e_1[1][2] != 73.3) color = error;\n"
1810 " if (examples_example_2_h_0_e_1[2][0] != 71.4) color = error;\n"
1811 " if (examples_example_2_h_0_e_1[2][1] !=-72.4) color = error;\n"
1812 " if (examples_example_2_h_0_e_1[2][2] != 73.4) color = error;\n"
1813 " if (examples_example_2_h_1_a != uvec3(771,782,793)) color = error;\n"
1814 " if (examples_example_2_h_1_b != vec2(74.5, 72.4)) color = error;\n"
1815 " if (examples_example_2_h_1_c_0 != 781.23) color = error;\n"
1816 " if (examples_example_2_h_1_c_1 != 778.12) color = error;\n"
1817 " if (examples_example_2_h_1_d != vec2(75.7, 73.5)) color = error;\n"
1818 " if (examples_example_2_h_1_e_0[0][0] != 71.3) color = error;\n"
1819 " if (examples_example_2_h_1_e_0[0][1] != 72.3) color = error;\n"
1820 " if (examples_example_2_h_1_e_0[0][2] !=-73.3) color = error;\n"
1821 " if (examples_example_2_h_1_e_0[1][0] != 71.4) color = error;\n"
1822 " if (examples_example_2_h_1_e_0[1][1] != 72.4) color = error;\n"
1823 " if (examples_example_2_h_1_e_0[1][2] !=-73.4) color = error;\n"
1824 " if (examples_example_2_h_1_e_0[2][0] != 71.5) color = error;\n"
1825 " if (examples_example_2_h_1_e_0[2][1] != 72.5) color = error;\n"
1826 " if (examples_example_2_h_1_e_0[2][2] !=-73.5) color = error;\n"
1827 " if (examples_example_2_h_1_e_1[0][0] != 71.4) color = error;\n"
1828 " if (examples_example_2_h_1_e_1[0][1] != 72.4) color = error;\n"
1829 " if (examples_example_2_h_1_e_1[0][2] != 73.4) color = error;\n"
1830 " if (examples_example_2_h_1_e_1[1][0] != 71.5) color = error;\n"
1831 " if (examples_example_2_h_1_e_1[1][1] != 72.5) color = error;\n"
1832 " if (examples_example_2_h_1_e_1[1][2] != 73.5) color = error;\n"
1833 " if (examples_example_2_h_1_e_1[2][0] != 71.6) color = error;\n"
1834 " if (examples_example_2_h_1_e_1[2][1] != 72.6) color = error;\n"
1835 " if (examples_example_2_h_1_e_1[2][2] != 73.6) color = error;\n"
1836 #ifdef HAS_FP64_EXTENSION
1837 " if (examples_example_2_i != 794.345678LF) color = error;\n"
1838 #endif
1839 " if (examples_example_2_j != true) color = error;\n"
1840 #ifdef HAS_FP64_EXTENSION
1841 " if (examples_example_2_k_a != dvec2(712.874LF,-72346.985633LF))color = error;\n"
1842 #endif
1843 " if (examples_example_2_k_b != 73) color = error;\n"
1844 " if (examples_example_2_k_c_0_a != 767.81) color = error;\n"
1845 " if (examples_example_2_k_c_0_b_0 != ivec3(734,735,-736)) color = error;\n"
1846 " if (examples_example_2_k_c_0_b_1 != ivec3(737,738,-739)) color = error;\n"
1847 " if (examples_example_2_k_c_0_b_2 != ivec3(740,741,-742)) color = error;\n"
1848 " if (examples_example_2_k_c_0_c != -74) color = error;\n"
1849 " if (examples_example_2_k_c_1_a != 756.78) color = error;\n"
1850 " if (examples_example_2_k_c_1_b_0 != ivec3(-743,744,745)) color = error;\n"
1851 " if (examples_example_2_k_c_1_b_1 != ivec3(-746,747,748)) color = error;\n"
1852 " if (examples_example_2_k_c_1_b_2 != ivec3(-749,750,751)) color = error;\n"
1853 " if (examples_example_2_k_c_1_c != -75) color = error;\n"
1854 " if (examples_example_2_k_c_2_a != 745.67) color = error;\n"
1855 " if (examples_example_2_k_c_2_b_0 != ivec3(752,-753,754)) color = error;\n"
1856 " if (examples_example_2_k_c_2_b_1 != ivec3(755,-756,757)) color = error;\n"
1857 " if (examples_example_2_k_c_2_b_2 != ivec3(758,-759,760)) color = error;\n"
1858 " if (examples_example_2_k_c_2_c != -76) color = error;\n"
1859 " if (examples_example_2_k_c_3_a != 734.56) color = error;\n"
1860 " if (examples_example_2_k_c_3_b_0 != ivec3(761,762,-763)) color = error;\n"
1861 " if (examples_example_2_k_c_3_b_1 != ivec3(764,-765,766)) color = error;\n"
1862 " if (examples_example_2_k_c_3_b_2 != ivec3(-767,768,769)) color = error;\n"
1863 " if (examples_example_2_k_c_3_c != 7) color = error;\n"
1864 "\n"
1865 "\n"
1866 " vFragColor = color;\n"
1867 "}\n"
1868 "\n"
1871 return fp_program;