changed: gcc8 base update
[opensg.git] / Examples / Simple / multipropertyubochunk_test.cpp
blob5a7ded79b3e686069db6da24cf098afb5f692bdc
1 // OpenSG Test Example: MultiPropertyUBOChunk test
2 //
3 // This example test the MultiPropertyUBOChunk
4 //
5 // Outcome on running this example:
6 // 1. animated green cylinder and torus
7 // => your platform provides all GLSL capabilities used in this
8 // example. Congratulations :-)
9 //
10 // 2. animated red cylinder and torus
11 // => the shader is actively working but some detail is not
12 // working properly. E.g.:
13 // - On ATI/AMD the usage of double fails at the time
14 // writing the example on the authors Radeon 5700 series
15 // platform.
16 // 3. animated gold or black looking cylinder and torus
17 // => the shader is not working at all. Something is miserabely
18 // wrong on your platform.
20 // The example uses the following uniform buffer block named 'ExampleBlock'
21 // which is declared in the shader code below.
23 // layout (std140) uniform ExampleBlock {
24 // float f1;
25 // vec3 v31;
26 // vec3 v32;
27 // float f2;
28 // int i1;
29 // int i2;
30 // vec3 v33;
31 // mat4 m41;
32 // uint u1;
33 // bool b1;
34 // vec4 v41;
35 // mat4 m42;
36 // #ifdef HAS_FP64_EXTENSION
37 // double d1;
38 // #endif
39 // float f3;
40 // } example;
43 #ifdef OSG_BUILD_ACTIVE
44 // Headers
45 #include <OSGGLUT.h>
46 #include <OSGConfig.h>
47 #include <OSGSimpleGeometry.h>
48 #include <OSGGLUTWindow.h>
49 #include <OSGSimpleSceneManager.h>
50 #include <OSGBaseFunctions.h>
51 #include <OSGTransform.h>
52 #include <OSGGroup.h>
54 // new headers:
55 #include <OSGGLEXT.h>
56 #include <OSGShaderProgramChunk.h>
57 #include <OSGShaderProgram.h>
58 #include <OSGShaderVariableOSG.h>
59 #include <OSGChunkMaterial.h>
60 #include <OSGMaterialGroup.h>
61 #include <OSGMaterialChunkOverrideGroup.h>
62 #include <OSGMultiPropertyUBOChunk.h>
63 #include <OSGPolygonChunk.h>
64 #include <OSGDepthChunk.h>
65 #include <OSGShaderProgramVariableChunk.h>
67 #else
68 // Headers
69 #include <OpenSG/OSGGLUT.h>
70 #include <OpenSG/OSGConfig.h>
71 #include <OpenSG/OSGSimpleGeometry.h>
72 #include <OpenSG/OSGGLUTWindow.h>
73 #include <OpenSG/OSGSimpleSceneManager.h>
74 #include <OpenSG/OSGBaseFunctions.h>
75 #include <OpenSG/OSGTransform.h>
76 #include <OpenSG/OSGGroup.h>
78 // new headers:
79 #include <OpenSG/OSGGLEXT.h>
80 #include <OpenSG/OSGShaderProgramChunk.h>
81 #include <OpenSG/OSGShaderProgram.h>
82 #include <OpenSG/OSGShaderVariableOSG.h>
83 #include <OpenSG/OSGChunkMaterial.h>
84 #include <OpenSG/OSGMaterialGroup.h>
85 #include <OpenSG/OSGMaterialChunkOverrideGroup.h>
86 #include <OpenSG/OSGMultiPropertyUBOChunk.h>
87 #include <OpenSG/OSGPolygonChunk.h>
88 #include <OpenSG/OSGDepthChunk.h>
89 #include <OpenSG/OSGShaderProgramVariableChunk.h>
90 #endif
92 #define HAS_FP64_EXTENSION
95 // The SimpleSceneManager to manage simple applications
97 OSG::SimpleSceneManagerRefPtr mgr;
100 // Create a OpenSG MultiPropertyUBOChunk object which does
101 // perform the shader storage buffer object abstraction.
104 OSG::UInt32 f1_id, v31_id, v32_id, f2_id, i1_id, i2_id,
105 v33_id, m41_id, u1_id, b1_id, v41_id, m42_id,
106 #ifdef HAS_FP64_EXTENSION
107 d1_id,
108 #endif
109 f3_id;
111 OSG::MultiPropertyUBOChunkTransitPtr create_example_block_state()
113 OSG::MultiPropertyUBOChunkRefPtr mpChunk = OSG::MultiPropertyUBOChunk::create();
115 OSG::UInt32 float_id, double_id, int_id, uint_id, bool_id, vec3_id, vec4_id, mat4_id;
117 float_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: FLOAT_T, 1); f1_id = float_id;
118 vec3_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: VEC3_T, 2); v31_id = vec3_id++; v32_id = vec3_id;
119 float_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: FLOAT_T, 1); f2_id = float_id;
120 int_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: INT_T, 2); i1_id = int_id++; i2_id = int_id;
121 vec3_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: VEC3_T, 1); v33_id = vec3_id;
122 mat4_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: MAT4_T, 1); m41_id = mat4_id;
123 uint_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: UINT_T, 1); u1_id = uint_id;
124 bool_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: BOOL_T, 1); b1_id = bool_id;
125 vec4_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: VEC4_T, 1); v41_id = vec4_id;
126 mat4_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: MAT4_T, 1); m42_id = mat4_id;
127 #ifdef HAS_FP64_EXTENSION
128 double_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: DOUBLE_T, 1); d1_id = double_id;
129 #endif
130 float_id = mpChunk->addMember(OSG::MultiPropertyUBOChunk:: FLOAT_T, 1); f3_id = float_id;
132 mpChunk->setUsage(GL_STREAM_DRAW);
134 OSG::UInt32 idx0 = mpChunk->addProperty();
135 OSG::UInt32 idx1 = mpChunk->addProperty();
136 OSG::UInt32 idx2 = mpChunk->addProperty();
138 OSG::Real32 f1_0 = 10.7f, f1_1 = -14.9f, f1_2 = 0.34f;
139 OSG::Vec3f v31_0(10.1f, 20.2f, 30.3f), v31_1(11.1f, 21.2f, 31.3f), v31_2(12.1f, 22.2f, 32.3f);
140 OSG::Vec3f v32_0(-0.1f, -0.2f, -0.3f), v32_1(-1.1f, -1.2f, -1.3f), v32_2(-2.1f, -2.2f, -2.3f);
141 OSG::Real32 f2_0 = 1210.7f, f2_1 = -1214.9f, f2_2 = 12.34f;
142 OSG::Int32 i1_0 = 15, i1_1 = -16, i1_2 = 17;
143 OSG::Int32 i2_0 = 18, i2_1 = -19, i2_2 =-27;
144 OSG::Vec3f v33_0(-0.01f, -0.02f, -0.03f), v33_1(-1.01f, -1.02f, -1.03f), v33_2(-2.01f, -2.02f, -2.03f);
145 OSG::Matrix m41_0( 1.f, 2.f, 3.f, 4.f,
146 5.f, 6.f, 7.f, 8.f,
147 9.f,10.f,11.f,12.f,
148 13.f,14.f,15.f,16.f),
150 m41_1( -1.f, -2.f, -3.f, -4.f,
151 -5.f, -6.f, -7.f, -8.f,
152 -9.f,-10.f,-11.f,-12.f,
153 -13.f,-14.f,-15.f,-16.f),
155 m41_2( -109.f, -209.f, -309.f, -409.f,
156 -509.f, -609.f, -709.f, -809.f,
157 -909.f,-1009.f,-1109.f,-1209.f,
158 -1309.f,-1409.f,-1509.f,-1609.f);
160 OSG::UInt32 u1_0 = 100, u1_1 = 200, u1_2 = 300;
161 bool b1_0 = true, b1_1 = true, b1_2 = false;
163 OSG::Vec4f v41_0(-270.1f, -270.2f, -270.3f, -270.4f), v41_1(-127.1f, -127.2f, -127.3f, -127.4f), v41_2(-227.1f, -227.2f, -227.3f, -227.4f);
164 OSG::Matrix m42_0( 91.f, 92.f, 93.f, 94.f,
165 95.f, 96.f, 97.f, 98.f,
166 99.f,910.f,911.f,912.f,
167 913.f,914.f,915.f,916.f),
169 m42_1( -91.f, -92.f, -93.f, -94.f,
170 -95.f, -96.f, -97.f, -98.f,
171 -99.f,-910.f,-911.f,-912.f,
172 -913.f,-914.f,-915.f,-916.f),
174 m42_2( -9109.f, -9209.f, -9309.f, -9409.f,
175 -9509.f, -9609.f, -9709.f, -9809.f,
176 -9909.f,-91009.f,-91109.f,-91209.f,
177 -91309.f,-91409.f,-91509.f,-91609.f);
179 #ifdef HAS_FP64_EXTENSION
180 OSG::Real64 d1_0 = 1253.8, d1_1 = 2253.6, d1_2 = 3253.4;
181 #endif
182 OSG::Real32 f3_0 = 6510.3f, f3_1 = -6514.4f, f3_2 = 650.54f;
184 mpChunk->setFloatProperty (idx0, f1_id, f1_0);
185 mpChunk->setVec3Property (idx0, v31_id, v31_0);
186 mpChunk->setVec3Property (idx0, v32_id, v32_0);
187 mpChunk->setFloatProperty (idx0, f2_id, f2_0);
188 mpChunk->setIntProperty (idx0, i1_id, i1_0);
189 mpChunk->setIntProperty (idx0, i2_id, i2_0);
190 mpChunk->setVec3Property (idx0, v33_id, v33_0);
191 mpChunk->setMat4Property (idx0, m41_id, m41_0);
192 mpChunk->setUIntProperty (idx0, u1_id, u1_0);
193 mpChunk->setBoolProperty (idx0, b1_id, b1_0);
194 mpChunk->setVec4Property (idx0, v41_id, v41_0);
195 mpChunk->setMat4Property (idx0, m42_id, m42_0);
196 #ifdef HAS_FP64_EXTENSION
197 mpChunk->setDoubleProperty(idx0, d1_id, d1_0);
198 #endif
199 mpChunk->setFloatProperty (idx0, f3_id, f3_0);
202 mpChunk->setFloatProperty (idx1, f1_id, f1_1);
203 mpChunk->setVec3Property (idx1, v31_id, v31_1);
204 mpChunk->setVec3Property (idx1, v32_id, v32_1);
205 mpChunk->setFloatProperty (idx1, f2_id, f2_1);
206 mpChunk->setIntProperty (idx1, i1_id, i1_1);
207 mpChunk->setIntProperty (idx1, i2_id, i2_1);
208 mpChunk->setVec3Property (idx1, v33_id, v33_1);
209 mpChunk->setMat4Property (idx1, m41_id, m41_1);
210 mpChunk->setUIntProperty (idx1, u1_id, u1_1);
211 mpChunk->setBoolProperty (idx1, b1_id, b1_1);
212 mpChunk->setVec4Property (idx1, v41_id, v41_1);
213 mpChunk->setMat4Property (idx1, m42_id, m42_1);
214 #ifdef HAS_FP64_EXTENSION
215 mpChunk->setDoubleProperty(idx1, d1_id, d1_1);
216 #endif
217 mpChunk->setFloatProperty (idx1, f3_id, f3_1);
220 mpChunk->setFloatProperty (idx2, f1_id, f1_2);
221 mpChunk->setVec3Property (idx2, v31_id, v31_2);
222 mpChunk->setVec3Property (idx2, v32_id, v32_2);
223 mpChunk->setFloatProperty (idx2, f2_id, f2_2);
224 mpChunk->setIntProperty (idx2, i1_id, i1_2);
225 mpChunk->setIntProperty (idx2, i2_id, i2_2);
226 mpChunk->setVec3Property (idx2, v33_id, v33_2);
227 mpChunk->setMat4Property (idx2, m41_id, m41_2);
228 mpChunk->setUIntProperty (idx2, u1_id, u1_2);
229 mpChunk->setBoolProperty (idx2, b1_id, b1_2);
230 mpChunk->setVec4Property (idx2, v41_id, v41_2);
231 mpChunk->setMat4Property (idx2, m42_id, m42_2);
232 #ifdef HAS_FP64_EXTENSION
233 mpChunk->setDoubleProperty(idx2, d1_id, d1_2);
234 #endif
235 mpChunk->setFloatProperty (idx2, f3_id, f3_2);
237 return OSG::MultiPropertyUBOChunkTransitPtr(mpChunk);
241 // vertex shader program.
243 std::string get_vp_program();
246 // fragment shader program for bump mapping in surface local coordinates
248 std::string get_fp_program();
251 // a separate transformation for every object
253 OSG::TransformRefPtr cyltrans, tortrans;
256 // forward declaration so we can have the interesting stuff upfront
258 int setupGLUT(int *argc, char *argv[]);
261 // redraw the window
263 void display(void)
265 // create the matrix
266 OSG::Matrix m;
267 OSG::Real32 t = glutGet(GLUT_ELAPSED_TIME );
269 // set the transforms' matrices
270 m.setTransform(OSG::Vec3f(0, 0, OSG::osgSin(t / 1000.f) * 1.5),
271 OSG::Quaternion( OSG::Vec3f (1, 0, 0), t / 500.f));
273 cyltrans->setMatrix(m);
275 m.setTransform(OSG::Vec3f(OSG::osgSin(t / 1000.f), 0, 0),
276 OSG::Quaternion( OSG::Vec3f (0, 0, 1), t / 1000.f));
278 tortrans->setMatrix(m);
280 OSG::commitChanges();
282 mgr->redraw();
286 // Initialize GLUT & OpenSG and set up the scene
288 int main(int argc, char **argv)
290 // OSG init
291 OSG::osgInit(argc,argv);
293 // GLUT init
294 int winid = setupGLUT(&argc, argv);
296 // open a new scope, because the pointers below should go out of scope
297 // before entering glutMainLoop.
298 // Otherwise OpenSG will complain about objects being alive after shutdown.
300 // the connection between GLUT and OpenSG
301 OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create();
302 gwin->setGlutId(winid);
303 gwin->init();
305 // create the SimpleSceneManager helper
306 mgr = OSG::SimpleSceneManager::create();
307 mgr->setWindow(gwin);
309 // create a pretty simple graph: a Group with two Transforms as children,
310 // each of which carries a single Geometry.
312 // The scene
314 OSG::NodeRefPtr scene = OSG::Node::create();
316 // The cylinder and its transformation
317 OSG::NodeRefPtr cyl = OSG::Node::create();
318 OSG::GeometryRefPtr cylgeo = OSG::makeCylinderGeo( 1.4f, .3f, 24,
319 true, true, true );
321 cyl->setCore(cylgeo);
323 cyltrans = OSG::Transform::create();
325 OSG::NodeRefPtr cyltransnode = OSG::Node::create();
326 cyltransnode->setCore (cyltrans);
327 cyltransnode->addChild(cyl );
329 // add it to the scene
330 scene->addChild(cyltransnode);
332 // The torus and its transformation
333 OSG::NodeRefPtr torus = OSG::Node::create();
334 OSG::GeometryRefPtr torusgeo = OSG::makeTorusGeo( .2f, 1, 24, 36 );
336 torus->setCore(torusgeo);
338 tortrans = OSG::Transform::create();
340 OSG::NodeRefPtr tortransnode = OSG::Node::create();
341 tortransnode->setCore (tortrans);
342 tortransnode->addChild(torus );
344 // add it to the scene
345 scene->addChild(tortransnode);
348 // create the shader program
350 OSG::ShaderProgramChunkRefPtr prog_chunk = OSG::ShaderProgramChunk::create();
351 OSG::ShaderProgramRefPtr vertShader = OSG::ShaderProgram::createVertexShader();
352 OSG::ShaderProgramRefPtr fragShader = OSG::ShaderProgram::createFragmentShader();
354 vertShader->setProgram(get_vp_program());
355 fragShader->setProgram(get_fp_program());
358 // binding the shader storage block to a buffer binding point can be performed
359 // either by calling the shaders's addShaderStorageBlock method or by
360 // adding a 'buffer block' variable to a ShaderProgramVariableChunk.
361 // In the following we use both variants for illustration.
363 fragShader->addUniformBlock("ExampleBlock", 1); // block binding point
365 prog_chunk->addShader(vertShader);
366 prog_chunk->addShader(fragShader);
369 // create shader storage buffer object for block 'ExampleBlock'
371 OSG::MultiPropertyUBOChunkRefPtr ubo_example_block = create_example_block_state();
373 OSG::PolygonChunkRefPtr polygon_chunk = OSG::PolygonChunk::create();
374 polygon_chunk->setFrontMode(GL_FILL);
375 polygon_chunk->setBackMode(GL_FILL);
376 polygon_chunk->setCullFace(GL_NONE);
378 OSG::DepthChunkRefPtr depth_chunk = OSG::DepthChunk::create();
379 depth_chunk->setEnable(true);
381 OSG::ChunkMaterialRefPtr prog_state = OSG::ChunkMaterial::create();
382 prog_state->addChunk(ubo_example_block, 1); // buffer binding point 1
383 prog_state->addChunk(prog_chunk);
384 prog_state->addChunk(polygon_chunk);
385 prog_state->addChunk(depth_chunk);
387 OSG::MaterialChunkOverrideGroupRefPtr mgrp = OSG::MaterialChunkOverrideGroup::create();
388 mgrp->setMaterial(prog_state);
389 scene->setCore(mgrp);
391 OSG::commitChanges();
393 mgr->setRoot(scene);
395 // show the whole scene
396 mgr->showAll();
399 // GLUT main loop
400 glutMainLoop();
402 return 0;
406 // GLUT callback functions
410 // react to size changes
412 void reshape(int w, int h)
414 mgr->resize(w, h);
415 glutPostRedisplay();
419 // react to mouse button presses
421 void mouse(int button, int state, int x, int y)
423 if (state)
424 mgr->mouseButtonRelease(button, x, y);
425 else
426 mgr->mouseButtonPress(button, x, y);
428 glutPostRedisplay();
432 // react to mouse motions with pressed buttons
434 void motion(int x, int y)
436 mgr->mouseMove(x, y);
437 glutPostRedisplay();
441 // react to keys
443 void keyboard(unsigned char k, int x, int y)
445 switch(k)
447 case 27:
449 // clean up global variables
450 cyltrans = NULL;
451 tortrans = NULL;
452 mgr = NULL;
454 OSG::osgExit();
455 exit(0);
457 break;
459 case 's':
461 mgr->setStatistics(!mgr->getStatistics());
463 break;
468 // setup the GLUT library which handles the windows for us
470 int setupGLUT(int *argc, char *argv[])
472 glutInit(argc, argv);
473 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
475 int winid = glutCreateWindow("OpenSG");
477 glutReshapeFunc(reshape);
478 glutDisplayFunc(display);
479 glutMouseFunc(mouse);
480 glutMotionFunc(motion);
481 glutKeyboardFunc(keyboard);
483 // call the redraw function whenever there's nothing else to do
484 glutIdleFunc(display);
486 return winid;
490 // vertex shader program.
492 std::string get_vp_program()
494 using namespace std;
496 stringstream ost;
498 ost << "#version 330 compatibility"
499 << endl << ""
500 << endl << "#extension GL_ARB_separate_shader_objects: enable"
501 << endl << "#extension GL_ARB_uniform_buffer_object: enable"
502 << endl << ""
503 << endl << "void main()"
504 << endl << "{"
505 << endl << " gl_Position = ftransform();"
506 << endl << "}"
507 << endl << ""
508 << endl;
510 return ost.str();
514 // fragment shader program for bump mapping in surface local coordinates
516 std::string get_fp_program()
518 using namespace std;
520 stringstream ost;
522 ost << "#version 440 compatibility"
523 << endl << ""
524 << endl << "#extension GL_ARB_separate_shader_objects: enable"
525 << endl << "#extension GL_ARB_uniform_buffer_object: enable"
526 << endl << ""
527 #ifdef HAS_FP64_EXTENSION
528 << endl << "#extension GL_ARB_gpu_shader_fp64: enable"
529 #endif
530 << endl << ""
531 << endl << "double eps = 1.0e-6;"
532 << endl << "const int numEntries = 3;"
533 << endl << ""
534 << endl << "struct Example"
535 << endl << "{"
536 << endl << " float f1;"
537 << endl << " vec3 v31;"
538 << endl << " vec3 v32;"
539 << endl << " float f2;"
540 << endl << " int i1;"
541 << endl << " int i2;"
542 << endl << " vec3 v33;"
543 << endl << " mat4 m41;"
544 << endl << " uint u1;"
545 << endl << " bool b1;"
546 << endl << " vec4 v41;"
547 << endl << " mat4 m42;"
548 #ifdef HAS_FP64_EXTENSION
549 << endl << " double d1;"
550 #endif
551 << endl << " float f3;"
552 << endl << "} example;"
553 << endl << ""
554 << endl << "layout (std140) uniform ExampleBlock"
555 << endl << "{"
556 << endl << " Example example[numEntries];"
557 << endl << "} examples;"
558 << endl << ""
559 << endl << "layout(location = 0) out vec4 vFragColor;"
560 << endl << ""
561 << endl << "void main()"
562 << endl << "{"
563 << endl << ""
564 << endl << " vec4 error = vec4(1.0, 0.0, 0.0, 1.0);"
565 << endl << " vec4 color = vec4(0.0, 1.0, 0.0, 1.0);"
566 << endl << ""
567 << endl << " float f1_0 = 10.7f;"
568 << endl << " float f1_1 = -14.9f;"
569 << endl << " float f1_2 = 0.34f;"
570 << endl << ""
571 << endl << " vec3 v31_0 = vec3(10.1f, 20.2f, 30.3f);"
572 << endl << " vec3 v31_1 = vec3(11.1f, 21.2f, 31.3f);"
573 << endl << " vec3 v31_2 = vec3(12.1f, 22.2f, 32.3f);"
574 << endl << ""
575 << endl << " vec3 v32_0 = vec3(-0.1f, -0.2f, -0.3f);"
576 << endl << " vec3 v32_1 = vec3(-1.1f, -1.2f, -1.3f);"
577 << endl << " vec3 v32_2 = vec3(-2.1f, -2.2f, -2.3f);"
578 << endl << ""
579 << endl << " float f2_0 = 1210.7f;"
580 << endl << " float f2_1 = -1214.9f;"
581 << endl << " float f2_2 = 12.34f;"
582 << endl << ""
583 << endl << " int i1_0 = 15;"
584 << endl << " int i1_1 = -16;"
585 << endl << " int i1_2 = 17;"
586 << endl << ""
587 << endl << " int i2_0 = 18;"
588 << endl << " int i2_1 = -19;"
589 << endl << " int i2_2 =-27;"
590 << endl << ""
591 << endl << " vec3 v33_0 = vec3(-0.01f, -0.02f, -0.03f);"
592 << endl << " vec3 v33_1 = vec3(-1.01f, -1.02f, -1.03f);"
593 << endl << " vec3 v33_2 = vec3(-2.01f, -2.02f, -2.03f);"
594 << endl << ""
595 << endl << " //"
596 << endl << " // The matrix elements are expected to be column-major layout."
597 << endl << " // The OpenSG element wise contructor expects the elements in"
598 << endl << " // row-major layout. Therefore we have to transpose all matrices"
599 << endl << " // of the example once!"
600 << endl << " //"
601 << endl << " mat4 m41_0 = mat4( 1.f, 2.f, 3.f, 4.f,"
602 << endl << " 5.f, 6.f, 7.f, 8.f,"
603 << endl << " 9.f,10.f,11.f,12.f,"
604 << endl << " 13.f,14.f,15.f,16.f);"
605 << endl << " m41_0 = transpose(m41_0);"
606 << endl << ""
607 << endl << " mat4 m41_1 = mat4( -1.f, -2.f, -3.f, -4.f,"
608 << endl << " -5.f, -6.f, -7.f, -8.f,"
609 << endl << " -9.f,-10.f,-11.f,-12.f,"
610 << endl << " -13.f,-14.f,-15.f,-16.f);"
611 << endl << " m41_1 = transpose(m41_1);"
612 << endl << ""
613 << endl << " mat4 m41_2 = mat4( -109.f, -209.f, -309.f, -409.f,"
614 << endl << " -509.f, -609.f, -709.f, -809.f,"
615 << endl << " -909.f,-1009.f,-1109.f,-1209.f,"
616 << endl << " -1309.f,-1409.f,-1509.f,-1609.f);"
617 << endl << " m41_2 = transpose(m41_2);"
618 << endl << ""
619 << endl << " uint u1_0 = 100;"
620 << endl << " uint u1_1 = 200;"
621 << endl << " uint u1_2 = 300;"
622 << endl << ""
623 << endl << " bool b1_0 = true;"
624 << endl << " bool b1_1 = true;"
625 << endl << " bool b1_2 = false;"
626 << endl << ""
627 << endl << " vec4 v41_0 = vec4(-270.1f, -270.2f, -270.3f, -270.4f);"
628 << endl << " vec4 v41_1 = vec4(-127.1f, -127.2f, -127.3f, -127.4f);"
629 << endl << " vec4 v41_2 = vec4(-227.1f, -227.2f, -227.3f, -227.4f);"
630 << endl << ""
631 << endl << " mat4 m42_0 = mat4( 91.f, 92.f, 93.f, 94.f,"
632 << endl << " 95.f, 96.f, 97.f, 98.f,"
633 << endl << " 99.f,910.f,911.f,912.f,"
634 << endl << " 913.f,914.f,915.f,916.f);"
635 << endl << " m42_0 = transpose(m42_0);"
636 << endl << ""
637 << endl << " mat4 m42_1 = mat4( -91.f, -92.f, -93.f, -94.f,"
638 << endl << " -95.f, -96.f, -97.f, -98.f,"
639 << endl << " -99.f,-910.f,-911.f,-912.f,"
640 << endl << " -913.f,-914.f,-915.f,-916.f);"
641 << endl << " m42_1 = transpose(m42_1);"
642 << endl << ""
643 << endl << " mat4 m42_2 = mat4( -9109.f, -9209.f, -9309.f, -9409.f,"
644 << endl << " -9509.f, -9609.f, -9709.f, -9809.f,"
645 << endl << " -9909.f,-91009.f,-91109.f,-91209.f,"
646 << endl << " -91309.f,-91409.f,-91509.f,-91609.f);"
647 << endl << " m42_2 = transpose(m42_2);"
648 << endl << ""
649 #ifdef HAS_FP64_EXTENSION
650 << endl << " double d1_0 = 1253.8;"
651 << endl << " double d1_1 = 2253.6;"
652 << endl << " double d1_2 = 3253.4;"
653 #endif
654 << endl << ""
655 << endl << " float f3_0 = 6510.3f;"
656 << endl << " float f3_1 = -6514.4f;"
657 << endl << " float f3_2 = 650.54f;"
658 << endl << ""
659 << endl << " if (examples.example[0].f1 != f1_0)"
660 << endl << " color = error;"
661 << endl << " if (examples.example[0].v31 != v31_0)"
662 << endl << " color = error;"
663 << endl << " if (examples.example[0].v32 != v32_0)"
664 << endl << " color = error;"
665 << endl << " if (examples.example[0].f2 != f2_0)"
666 << endl << " color = error;"
667 << endl << " if (examples.example[0].i1 != i1_0)"
668 << endl << " color = error;"
669 << endl << " if (examples.example[0].i2 != i2_0)"
670 << endl << " color = error;"
671 << endl << " if (examples.example[0].v33 != v33_0)"
672 << endl << " color = error;"
673 << endl << " if (examples.example[0].m41 != m41_0)"
674 << endl << " color = error;"
675 << endl << " if (examples.example[0].u1 != u1_0)"
676 << endl << " color = error;"
677 << endl << " if (examples.example[0].b1 != b1_0)"
678 << endl << " color = error;"
679 << endl << " if (examples.example[0].v41 != v41_0)"
680 << endl << " color = error;"
681 << endl << " if (examples.example[0].m42 != m42_0)"
682 << endl << " color = error;"
683 #ifdef HAS_FP64_EXTENSION
684 << endl << " if (abs(examples.example[0].d1 - d1_0) < eps)"
685 << endl << " color = error;"
686 #endif
687 << endl << " if (examples.example[0].f3 != f3_0)"
688 << endl << " color = error;"
689 << endl << " if (examples.example[1].f1 != f1_1)"
690 << endl << " color = error;"
691 << endl << " if (examples.example[1].v31 != v31_1)"
692 << endl << " color = error;"
693 << endl << " if (examples.example[1].v32 != v32_1)"
694 << endl << " color = error;"
695 << endl << " if (examples.example[1].f2 != f2_1)"
696 << endl << " color = error;"
697 << endl << " if (examples.example[1].i1 != i1_1)"
698 << endl << " color = error;"
699 << endl << " if (examples.example[1].i2 != i2_1)"
700 << endl << " color = error;"
701 << endl << " if (examples.example[1].v33 != v33_1)"
702 << endl << " color = error;"
703 << endl << " if (examples.example[1].m41 != m41_1)"
704 << endl << " color = error;"
705 << endl << " if (examples.example[1].u1 != u1_1)"
706 << endl << " color = error;"
707 << endl << " if (examples.example[1].b1 != b1_1)"
708 << endl << " color = error;"
709 << endl << " if (examples.example[1].v41 != v41_1)"
710 << endl << " color = error;"
711 << endl << " if (examples.example[1].m42 != m42_1)"
712 << endl << " color = error;"
713 #ifdef HAS_FP64_EXTENSION
714 << endl << " if (abs(examples.example[1].d1 - d1_1) < eps)"
715 << endl << " color = error;"
716 #endif
717 << endl << " if (examples.example[1].f3 != f3_1)"
718 << endl << " color = error;"
719 << endl << " if (examples.example[2].f1 != f1_2)"
720 << endl << " color = error;"
721 << endl << " if (examples.example[2].v31 != v31_2)"
722 << endl << " color = error;"
723 << endl << " if (examples.example[2].v32 != v32_2)"
724 << endl << " color = error;"
725 << endl << " if (examples.example[2].f2 != f2_2)"
726 << endl << " color = error;"
727 << endl << " if (examples.example[2].i1 != i1_2)"
728 << endl << " color = error;"
729 << endl << " if (examples.example[2].i2 != i2_2)"
730 << endl << " color = error;"
731 << endl << " if (examples.example[2].v33 != v33_2)"
732 << endl << " color = error;"
733 << endl << " if (examples.example[2].m41 != m41_2)"
734 << endl << " color = error;"
735 << endl << " if (examples.example[2].u1 != u1_2)"
736 << endl << " color = error;"
737 << endl << " if (examples.example[2].b1 != b1_2)"
738 << endl << " color = error;"
739 << endl << " if (examples.example[2].v41 != v41_2)"
740 << endl << " color = error;"
741 << endl << " if (examples.example[2].m42 != m42_2)"
742 << endl << " color = error;"
743 #ifdef HAS_FP64_EXTENSION
744 << endl << " if (abs(examples.example[2].d1 - d1_2) < eps)"
745 << endl << " color = error;"
746 #endif
747 << endl << " if (examples.example[2].f3 != f3_2)"
748 << endl << " color = error;"
749 << endl << ""
750 << endl << " vFragColor = color;"
751 << endl << "}"
752 << endl << ""
753 << endl;
755 return ost.str();