1 /**************************************************************************\
2  * Copyright (c) Kongsberg Oil & Gas Technologies AS
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holder nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 \**************************************************************************/
32 
33 /*!
34   \class SoShaderParameter SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
35   \brief The SoShaderParameter class is the base class for all shader parameter classes.
36 
37   In addition to the \a name and \a identifier field, all subclasses have a
38   \a value field which is used for specifying the parameter value.
39 
40   \ingroup shaders
41 */
42 
43 /*!
44   \var SoSFString SoShaderParameter::name
45 
46   The shader parameter name. Used for Cg and GLSL programs.
47 */
48 
49 /*!
50   \var SoSFInt32 SoShaderParameter::identifier
51 
52   The shader parameter identifier. Used for ARB shader programs.
53 */
54 
55 /*!
56   \class SoUniformShaderParameter SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
57   \brief The SoUniformShaderParameter class is the base class for all uniform shader variables.
58 
59   Uniform shader variables are used to pass parameters from the scene graph to the shader
60   program.
61 
62   In the shader program the variable is declared like this:
63 
64   \verbatim
65   uniform float shininess;
66   \endverbatim
67 
68   See \ref coin_shaders "Shaders in Coin" for more information.
69 
70   \ingroup shaders
71 */
72 
73 /*!
74   \fn void SoUniformShaderParameter::updateParameter(SoGLShaderObject *shaderObject)
75   \brief Updates the shader parameter in the OpenGL state with the content of the value field.
76 */
77 
78 /*!
79   \class SoShaderParameter1f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
80   \brief The SoShaderParameter1f class is used to define a floating point value as
81          shader parameter.
82 
83   \ingroup shaders
84 */
85 
86 /*!
87   \var SoSFFloat SoShaderParameter1f::value
88 
89   The shader parameter value.
90 */
91 
92 /*!
93   \class SoShaderParameter1i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
94   \brief The SoShaderParameter1i class is used to define an integer value as
95          shader parameter.
96 
97   \ingroup shaders
98 */
99 
100 /*!
101   \var SoSFInt32 SoShaderParameter1i::value
102 
103   The shader parameter value.
104 */
105 
106 /*!
107   \class SoShaderParameter2f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
108   \brief The SoShaderParameter2f class is used to define a two-dimensional floating
109          point value as shader parameter.
110 
111   \ingroup shaders
112 */
113 
114 /*!
115   \var SoSFVec2f SoShaderParameter2f::value
116 
117   The shader parameter value.
118 */
119 
120 /*!
121   \class SoShaderParameter2i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
122   \brief The SoShaderParameter2i class is used to define a two-dimensional integer
123          value as shader parameter.
124 
125   \ingroup shaders
126 */
127 
128 /*!
129   \var SoSFVec2i32 SoShaderParameter2i::value
130 
131   The shader parameter value.
132 */
133 
134 /*!
135   \class SoShaderParameter3f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
136   \brief The SoShaderParameter3f class is used to define a three-dimensional floating
137          point value as shader parameter.
138 
139   \ingroup shaders
140 */
141 
142 /*!
143   \var SoSFVec3f SoShaderParameter3f::value
144 
145   The shader parameter value.
146 */
147 
148 /*!
149   \class SoShaderParameter3i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
150   \brief The SoShaderParameter3i class is used to define a three-dimensional integer
151          value as shader parameter.
152 
153   \ingroup shaders
154 */
155 
156 /*!
157   \var SoSFVec3i32 SoShaderParameter3i::value
158 
159   The shader parameter value.
160 */
161 
162 /*!
163   \class SoShaderParameter4f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
164   \brief The SoShaderParameter4f class is used to define a four-dimensional floating
165          point value as shader parameter.
166 
167   \ingroup shaders
168 */
169 
170 /*!
171   \var SoSFVec4f SoShaderParameter4f::value
172 
173   The shader parameter value.
174 */
175 
176 /*!
177   \class SoShaderParameter4i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
178   \brief The SoShaderParameter4i class is used to define a four-dimensional integer
179          value as shader parameter.
180 
181   \ingroup shaders
182 */
183 
184 /*!
185   \var SoSFVec4i32 SoShaderParameter4i::value
186 
187   The shader parameter value.
188 */
189 
190 /*!
191   \class SoShaderParameterArray1f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
192   \brief The SoShaderParameterArray1f class is used to define a floating point array as
193          shader parameter.
194 
195   \ingroup shaders
196 */
197 
198 /*!
199   \var SoMFFloat SoShaderParameterArray1f::value
200 
201   The shader parameter value.
202 */
203 
204 /*!
205   \class SoShaderParameterArray1i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
206   \brief The SoShaderParameterArray1i class is used to define an integer array as
207          shader parameter.
208 
209   \ingroup shaders
210 */
211 
212 /*!
213   \var SoMFInt32 SoShaderParameterArray1i::value
214 
215   The shader parameter value.
216 */
217 
218 /*!
219   \class SoShaderParameterArray2f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
220   \brief The SoShaderParameterArray2f class is used to define a two-dimensional floating
221          point array as shader parameter.
222 
223   \ingroup shaders
224 */
225 
226 /*!
227   \var SoMFVec2f SoShaderParameterArray2f::value
228 
229   The shader parameter value.
230 */
231 
232 /*!
233   \class SoShaderParameterArray2i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
234   \brief The SoShaderParameterArray2i class is used to define a two-dimensional integer
235          array as shader parameter.
236 
237   \ingroup shaders
238 */
239 
240 /*!
241   \var SoMFVec2i32 SoShaderParameterArray2i::value
242 
243   The shader parameter value.
244 */
245 
246 /*!
247   \class SoShaderParameterArray3f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
248   \brief The SoShaderParameterArray3f class is used to define a three-dimensional floating
249          point array as shader parameter.
250 
251   \ingroup shaders
252 */
253 
254 /*!
255   \var SoMFVec3f SoShaderParameterArray3f::value
256 
257   The shader parameter value.
258 */
259 
260 /*!
261   \class SoShaderParameterArray3i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
262   \brief The SoShaderParameterArray3i class is used to define a three-dimensional integer
263          array as shader parameter.
264 
265   \ingroup shaders
266 */
267 
268 /*!
269   \var SoMFVec3i32 SoShaderParameterArray3i::value
270 
271   The shader parameter value.
272 */
273 
274 /*!
275   \class SoShaderParameterArray4f SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
276   \brief The SoShaderParameterArray4f class is used to define a four-dimensional floating
277          point array as shader parameter.
278 
279   \ingroup shaders
280 */
281 
282 /*!
283   \var SoMFVec4f SoShaderParameterArray4f::value
284 
285   The shader parameter value.
286 */
287 
288 /*!
289   \class SoShaderParameterArray4i SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
290   \brief The SoShaderParameterArray4i class is used to define a four-dimensional integer
291          array as shader parameter.
292 
293   \ingroup shaders
294 */
295 
296 /*!
297   \var SoMFVec4i32 SoShaderParameter4i::value
298 
299   The shader parameter value.
300 */
301 
302 /*!
303   \class SoShaderParameterMatrix SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
304   \brief The SoShaderParameterMatrix class is used to define a matrix as shader parameter.
305 
306   \ingroup shaders
307 */
308 
309 /*!
310   \var SoSFMatrix SoShaderParameterMatrix::value
311 
312   The shader parameter value.
313 */
314 
315 /*!
316   \class SoShaderParameterMatrixArray SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
317   \brief The SoShaderParameterMatrixArray class is used to define a matrix array as
318          shader parameter.
319 
320   \ingroup shaders
321 */
322 
323 /*!
324   \var SoMFMatrix SoShaderParameterMatrixArray::value
325 
326   The shader parameter value.
327 */
328 
329 /*!
330   \class SoShaderStateMatrixParameter SoShaderParameter.h Inventor/nodes/SoShaderParameter.h
331   \brief The SoShaderStateMatrixParameter class is used to define a matrix as
332          shader parameter whose content is derived from the traversal state.
333 
334   Unlike other parameter classes, SoShaderStateMatrixParameter does not have a
335   value field. The value member is protected and updated automatically from the
336   traversal state.
337 
338   \ingroup shaders
339 */
340 
341 /*!
342   \enum SoShaderStateMatrixParameter::MatrixType
343 
344   Defines the different matrix types.
345 */
346 
347 /*!
348   \var SoSFEnum SoShaderStateMatrixParameter::matrixType
349 
350   Defines the matrix type value for the uniform shader variable.
351 */
352 
353 /*!
354   \enum SoShaderStateMatrixParameter::MatrixTransform
355 
356   Defines different transformations that can be applied to a matrix.
357 */
358 
359 /*!
360   \var SoSFEnum SoShaderStateMatrixParameter::matrixTransform
361 
362   Defines a transformation that is applied to the matrix value.
363   The default value of IDENTITY keeps the value unchanged.
364 */
365 
366 
367 #include <Inventor/nodes/SoShaderParameter.h>
368 #include <Inventor/actions/SoGLRenderAction.h>
369 #include <Inventor/elements/SoModelMatrixElement.h>
370 #include <Inventor/elements/SoViewingMatrixElement.h>
371 #include <Inventor/elements/SoProjectionMatrixElement.h>
372 #include <Inventor/elements/SoGLMultiTextureMatrixElement.h>
373 #include <Inventor/elements/SoTextureUnitElement.h>
374 
375 #include <cassert>
376 
377 #include "nodes/SoSubNodeP.h"
378 #include "misc/SbHash.h"
379 #include "glue/cg.h"
380 #include "shaders/SoGLShaderObject.h"
381 #include "shaders/SoGLShaderParameter.h"
382 #include "shaders/SoGLCgShaderParameter.h"
383 
384 /* **************************************************************************
385  * *** SoShaderParameter ***
386  * **************************************************************************/
387 
388 SO_NODE_ABSTRACT_SOURCE(SoShaderParameter);
389 
390 // doc from parent
391 void
initClass(void)392 SoShaderParameter::initClass(void)
393 {
394   SO_NODE_INTERNAL_INIT_ABSTRACT_CLASS(SoShaderParameter,
395                                        SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
396 }
397 
398 /*!
399   Constructor.
400 */
SoShaderParameter(void)401 SoShaderParameter::SoShaderParameter(void)
402 {
403   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter);
404 
405   SO_NODE_ADD_FIELD(name, (""));
406   SO_NODE_ADD_FIELD(identifier, (0));
407 }
408 
409 /*!
410   Destructor.
411 */
~SoShaderParameter()412 SoShaderParameter::~SoShaderParameter()
413 {
414 }
415 
416 #define PRIVATE(obj) obj->pimpl
417 
418 /* **************************************************************************
419  * *** SoUniformShaderParameter ***
420  * **************************************************************************/
421 
422 class SoUniformShaderParameterP {
423 public:
SoUniformShaderParameterP()424   SoUniformShaderParameterP() { }
~SoUniformShaderParameterP()425   ~SoUniformShaderParameterP() {
426     SbList <uint32_t> keylist;
427     this->glparams.makeKeyList(keylist);
428     for (int i = 0; i < keylist.getLength(); i++) {
429       SoGLShaderParameter * param;
430       (void) this->glparams.get(keylist[i], param);
431       deleteGLParameter(param);
432     }
433   }
deleteGLParameter(SoGLShaderParameter * COIN_UNUSED_ARG (param))434   static void deleteGLParameter(SoGLShaderParameter * COIN_UNUSED_ARG(param)) {
435     // FIXME: schedule for delete, pederb 2005-11-30
436   }
437   // FIXME: add a cache context destruction callback, pederb 2005-11-30
438   SbHash<uint32_t, SoGLShaderParameter *> glparams;
439 };
440 
441 SO_NODE_ABSTRACT_SOURCE(SoUniformShaderParameter);
442 
443 void
initClass(void)444 SoUniformShaderParameter::initClass(void)
445 {
446   SO_NODE_INTERNAL_INIT_ABSTRACT_CLASS(SoUniformShaderParameter,
447                                        SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
448 }
449 
SoUniformShaderParameter(void)450 SoUniformShaderParameter::SoUniformShaderParameter(void)
451 {
452   SO_NODE_INTERNAL_CONSTRUCTOR(SoUniformShaderParameter);
453 
454   PRIVATE(this) = new SoUniformShaderParameterP;
455 }
456 
~SoUniformShaderParameter()457 SoUniformShaderParameter::~SoUniformShaderParameter()
458 {
459   delete PRIVATE(this);
460 }
461 
462 void
ensureParameter(SoGLShaderObject * shader)463 SoUniformShaderParameter::ensureParameter(SoGLShaderObject * shader)
464 {
465   assert(shader);
466   const uint32_t context = shader->getCacheContext();
467   SoGLShaderParameter * param;
468   if (!PRIVATE(this)->glparams.get(context, param)) {
469     param = shader->getNewParameter();
470     (void) PRIVATE(this)->glparams.put(context, param);
471   }
472   if (param->shaderType() != shader->shaderType()) {
473     SoUniformShaderParameterP::deleteGLParameter(param);
474     param = shader->getNewParameter();
475     (void) PRIVATE(this)->glparams.put(context, param);
476   }
477 }
478 
479 SoGLShaderParameter *
getGLShaderParameter(const uint32_t cachecontext)480 SoUniformShaderParameter::getGLShaderParameter(const uint32_t cachecontext)
481 {
482   SoGLShaderParameter * glparam;
483   if (PRIVATE(this)->glparams.get(cachecontext, glparam)) return glparam;
484   return NULL;
485 }
486 
487 
488 /* **************************************************************************
489  * *** SoShaderParameter1f ***
490  * **************************************************************************/
491 
492 
493 SO_NODE_SOURCE(SoShaderParameter1f);
494 
initClass(void)495 void SoShaderParameter1f::initClass(void)
496 {
497   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter1f,
498                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
499 }
500 
SoShaderParameter1f(void)501 SoShaderParameter1f::SoShaderParameter1f(void)
502 {
503   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter1f);
504   SO_NODE_ADD_FIELD(value, (0));
505 }
506 
~SoShaderParameter1f()507 SoShaderParameter1f::~SoShaderParameter1f()
508 {
509 }
510 
511 void
updateParameter(SoGLShaderObject * shader)512 SoShaderParameter1f::updateParameter(SoGLShaderObject *shader)
513 {
514   this->ensureParameter(shader);
515   this->getGLShaderParameter(shader->getCacheContext())->set1f(shader,
516                                                                this->value.getValue(),
517                                                                this->name.getValue().getString(),
518                                                                this->identifier.getValue());
519 }
520 
521 /* **************************************************************************
522  * *** SoShaderParameter2f ***
523  * **************************************************************************/
524 
525 
526 SO_NODE_SOURCE(SoShaderParameter2f);
527 
initClass(void)528 void SoShaderParameter2f::initClass(void)
529 {
530   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter2f,
531                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
532 }
533 
SoShaderParameter2f(void)534 SoShaderParameter2f::SoShaderParameter2f(void)
535 {
536   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter2f);
537   SO_NODE_ADD_FIELD(value, (0,0));
538 }
539 
~SoShaderParameter2f()540 SoShaderParameter2f::~SoShaderParameter2f()
541 {
542 }
543 
updateParameter(SoGLShaderObject * shader)544 void SoShaderParameter2f::updateParameter(SoGLShaderObject *shader)
545 {
546   this->ensureParameter(shader);
547   this->getGLShaderParameter(shader->getCacheContext())->set2f(shader,
548                          this->value.getValue().getValue(),
549                          this->name.getValue().getString(),
550                          this->identifier.getValue());
551 }
552 
553 /* **************************************************************************
554  * *** SoShaderParameter3f ***
555  * **************************************************************************/
556 
557 
558 SO_NODE_SOURCE(SoShaderParameter3f);
559 
initClass(void)560 void SoShaderParameter3f::initClass(void)
561 {
562   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter3f,
563                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
564 }
565 
SoShaderParameter3f(void)566 SoShaderParameter3f::SoShaderParameter3f(void)
567 {
568   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter3f);
569   SO_NODE_ADD_FIELD(value, (0,0,0));
570 }
571 
~SoShaderParameter3f()572 SoShaderParameter3f::~SoShaderParameter3f()
573 {
574 }
575 
updateParameter(SoGLShaderObject * shader)576 void SoShaderParameter3f::updateParameter(SoGLShaderObject *shader)
577 {
578   this->ensureParameter(shader);
579   this->getGLShaderParameter(shader->getCacheContext())->set3f(shader,
580                          this->value.getValue().getValue(),
581                          this->name.getValue().getString(),
582                          this->identifier.getValue());
583 }
584 
585 /* **************************************************************************
586  * *** SoShaderParameter4f ***
587  * **************************************************************************/
588 
589 
590 SO_NODE_SOURCE(SoShaderParameter4f);
591 
initClass(void)592 void SoShaderParameter4f::initClass(void)
593 {
594   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter4f,
595                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
596 }
597 
SoShaderParameter4f(void)598 SoShaderParameter4f::SoShaderParameter4f(void)
599 {
600   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter4f);
601   SO_NODE_ADD_FIELD(value, (0,0,0,0));
602 }
603 
~SoShaderParameter4f()604 SoShaderParameter4f::~SoShaderParameter4f()
605 {
606 }
607 
updateParameter(SoGLShaderObject * shader)608 void SoShaderParameter4f::updateParameter(SoGLShaderObject *shader)
609 {
610   this->ensureParameter(shader);
611   this->getGLShaderParameter(shader->getCacheContext())->set4f(shader,
612                          this->value.getValue().getValue(),
613                          this->name.getValue().getString(),
614                          this->identifier.getValue());
615 }
616 
617 /* **************************************************************************
618  * *** SoShaderStateMatrixParameter ***
619  * **************************************************************************/
620 
621 SO_NODE_SOURCE(SoShaderStateMatrixParameter);
622 
initClass(void)623 void SoShaderStateMatrixParameter::initClass(void)
624 {
625   SO_NODE_INTERNAL_INIT_CLASS(SoShaderStateMatrixParameter,
626                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
627 
628   SO_ENABLE(SoGLRenderAction, SoModelMatrixElement);
629   SO_ENABLE(SoGLRenderAction, SoViewingMatrixElement);
630   SO_ENABLE(SoGLRenderAction, SoProjectionMatrixElement);
631   SO_ENABLE(SoGLRenderAction, SoGLMultiTextureMatrixElement);
632   SO_ENABLE(SoGLRenderAction, SoTextureUnitElement);
633 }
634 
SoShaderStateMatrixParameter(void)635 SoShaderStateMatrixParameter::SoShaderStateMatrixParameter(void)
636 {
637   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderStateMatrixParameter);
638 
639   SO_NODE_DEFINE_ENUM_VALUE(MatrixType, MODELVIEW);
640   SO_NODE_DEFINE_ENUM_VALUE(MatrixType, PROJECTION);
641   SO_NODE_DEFINE_ENUM_VALUE(MatrixType, TEXTURE);
642   SO_NODE_DEFINE_ENUM_VALUE(MatrixType, MODELVIEW_PROJECTION);
643 
644   SO_NODE_ADD_FIELD(matrixType, (MODELVIEW));
645   SO_NODE_SET_SF_ENUM_TYPE(matrixType, MatrixType);
646 
647 
648   SO_NODE_DEFINE_ENUM_VALUE(MatrixTransform, IDENTITY);
649   SO_NODE_DEFINE_ENUM_VALUE(MatrixTransform, TRANSPOSE);
650   SO_NODE_DEFINE_ENUM_VALUE(MatrixTransform, INVERSE);
651   SO_NODE_DEFINE_ENUM_VALUE(MatrixTransform, INVERSE_TRANSPOSE);
652 
653   SO_NODE_ADD_FIELD(matrixTransform, (IDENTITY));
654   SO_NODE_SET_SF_ENUM_TYPE(matrixTransform, MatrixTransform);
655 
656   value = SbMatrix::identity();
657 }
658 
~SoShaderStateMatrixParameter()659 SoShaderStateMatrixParameter::~SoShaderStateMatrixParameter()
660 {
661 
662 }
663 
664 // State matrices work differently with CG!
665 // COMMENT: Because they are only defined in CG (and not in ARB or GLSL)
666 //          a state matrix uniform delivers the current GL_MODELVIEW,
667 //          GL_PROJECTION,... matrices, which can be also accessed via
668 //          glstate.matrix.modelview, glstate.matrix.projection,...
669 //          since CG 1.2 (or earlier)
670 //                                           -- 20050126 martin.
671 //          In ARB or GLSL the matrices are retrieved from the state
672 //          in the updateValue() method and then set here as uniform
673 //          variables of type matrix.
674 //                                           -- 20141129 thomas.
675 void
updateParameter(SoGLShaderObject * shader)676 SoShaderStateMatrixParameter::updateParameter(SoGLShaderObject *shader)
677 {
678   if (this->name.isDefault()) return;
679 
680   this->ensureParameter(shader);
681 
682   if (shader->shaderType() == SoShader::CG_SHADER) {
683     CGGLenum type;
684     switch (this->matrixType.getValue()) {
685     case MODELVIEW: type = CG_GL_MODELVIEW_MATRIX; break;
686     case PROJECTION: type = CG_GL_PROJECTION_MATRIX; break;
687     case TEXTURE: type = CG_GL_TEXTURE_MATRIX; break;
688     case MODELVIEW_PROJECTION: type = CG_GL_MODELVIEW_PROJECTION_MATRIX; break;
689     default: assert(0 && "illegal shader type"); break;
690     }
691 
692     CGGLenum tform;
693     switch (this->matrixTransform.getValue()) {
694     case IDENTITY: tform = CG_GL_MATRIX_IDENTITY; break;
695     case TRANSPOSE: tform = CG_GL_MATRIX_TRANSPOSE; break;
696     case INVERSE: tform = CG_GL_MATRIX_INVERSE; break;
697     case INVERSE_TRANSPOSE: tform = CG_GL_MATRIX_INVERSE_TRANSPOSE; break;
698     default: assert(0 && "illegal matrix transform type"); break;
699     }
700 
701     SoGLCgShaderParameter * param = (SoGLCgShaderParameter *)
702       this->getGLShaderParameter(shader->getCacheContext());
703     param->setState(shader, type, tform, this->name.getValue().getString());
704   }
705   else {
706     // if not CG then set the value retrieved from state before
707 	this->getGLShaderParameter(shader->getCacheContext())->setMatrix(
708         shader,
709         value,
710         this->name.getValue().getString(),
711         this->identifier.getValue());
712   }
713 }
714 
715 /*!
716  * Updates matrix value from state
717  */
718 void
updateValue(SoState * state)719 SoShaderStateMatrixParameter::updateValue(SoState *state)
720 {
721   SbMatrix matrix = SbMatrix::identity();
722   switch (this->matrixType.getValue()) {
723     case MODELVIEW: {
724       matrix = SoModelMatrixElement::get(state);
725       matrix.multRight(SoViewingMatrixElement::get(state));
726     } break;
727     case PROJECTION: {
728       matrix = SoProjectionMatrixElement::get(state);
729     } break;
730     case TEXTURE: {
731       int unit = SoTextureUnitElement::get(state);
732       matrix = SoGLMultiTextureMatrixElement::get(state, unit);
733     } break;
734     case MODELVIEW_PROJECTION: {
735       matrix = SoModelMatrixElement::get(state);
736       matrix.multRight(SoViewingMatrixElement::get(state));
737       matrix.multRight(SoProjectionMatrixElement::get(state));
738     } break;
739     default: assert(0 && "illegal matrix type"); break;
740   }
741 
742   switch (this->matrixTransform.getValue()) {
743   case IDENTITY: value = matrix; break;
744   case TRANSPOSE: value = matrix.transpose(); break;
745   case INVERSE: value = matrix.inverse(); break;
746   case INVERSE_TRANSPOSE: value = matrix.inverse().transpose(); break;
747   default: assert(0 && "illegal matrix transform type"); break;
748   }
749 }
750 
751 /* **************************************************************************
752  * ***                      SoShaderParameterArray1f                      ***
753  * **************************************************************************/
754 
755 SO_NODE_SOURCE(SoShaderParameterArray1f);
756 
initClass(void)757 void SoShaderParameterArray1f::initClass(void)
758 {
759   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray1f,
760                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
761 }
762 
SoShaderParameterArray1f(void)763 SoShaderParameterArray1f::SoShaderParameterArray1f(void)
764 {
765   SO_NODE_CONSTRUCTOR(SoShaderParameterArray1f);
766   SO_NODE_ADD_FIELD(value, (0));
767 }
768 
~SoShaderParameterArray1f()769 SoShaderParameterArray1f::~SoShaderParameterArray1f()
770 {
771 }
772 
updateParameter(SoGLShaderObject * shader)773 void SoShaderParameterArray1f::updateParameter(SoGLShaderObject *shader)
774 {
775   this->ensureParameter(shader);
776   this->getGLShaderParameter(shader->getCacheContext())->set1fv(shader,
777                                                                 this->value.getNum(),
778                                                                 this->value.getValues(0),
779                                                                 this->name.getValue().getString(),
780                                                                 this->identifier.getValue());
781 }
782 
783 /* **************************************************************************
784  * ***                      SoShaderParameterArray2f                      ***
785  * **************************************************************************/
786 
787 SO_NODE_SOURCE(SoShaderParameterArray2f);
788 
initClass(void)789 void SoShaderParameterArray2f::initClass(void)
790 {
791   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray2f,
792                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
793 }
794 
SoShaderParameterArray2f(void)795 SoShaderParameterArray2f::SoShaderParameterArray2f(void)
796 {
797   SO_NODE_CONSTRUCTOR(SoShaderParameterArray2f);
798   SO_NODE_ADD_FIELD(value, (SbVec2f(0,0)));
799 }
800 
~SoShaderParameterArray2f()801 SoShaderParameterArray2f::~SoShaderParameterArray2f()
802 {
803 }
804 
updateParameter(SoGLShaderObject * shader)805 void SoShaderParameterArray2f::updateParameter(SoGLShaderObject *shader)
806 {
807   this->ensureParameter(shader);
808 
809   int     num    = this->value.getNum();
810   float * buffer = NULL;
811 
812   if (num > 0) {
813     buffer = new float[2*num];
814     for (int i=0; i<num; i++) {
815       buffer[2*i+0] = this->value[i][0];
816       buffer[2*i+1] = this->value[i][1];
817     }
818   }
819 
820   this->getGLShaderParameter(shader->getCacheContext())
821         ->set2fv(shader, num, buffer,
822                  this->name.getValue().getString(),
823                  this->identifier.getValue());
824   delete[] buffer;
825 }
826 
827 /* **************************************************************************
828  * ***                      SoShaderParameterArray3f                      ***
829  * **************************************************************************/
830 
831 SO_NODE_SOURCE(SoShaderParameterArray3f);
832 
initClass(void)833 void SoShaderParameterArray3f::initClass(void)
834 {
835   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray3f,
836                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
837 }
838 
SoShaderParameterArray3f(void)839 SoShaderParameterArray3f::SoShaderParameterArray3f(void)
840 {
841   SO_NODE_CONSTRUCTOR(SoShaderParameterArray3f);
842   SO_NODE_ADD_FIELD(value, (SbVec3f(0,0,0)));
843 }
844 
~SoShaderParameterArray3f()845 SoShaderParameterArray3f::~SoShaderParameterArray3f()
846 {
847 }
848 
updateParameter(SoGLShaderObject * shader)849 void SoShaderParameterArray3f::updateParameter(SoGLShaderObject *shader)
850 {
851   this->ensureParameter(shader);
852 
853   int     num    = this->value.getNum();
854   float * buffer = NULL;
855 
856   if (num > 0) {
857     buffer = new float[3*num];
858     for (int i=0; i<num; i++) {
859       buffer[3*i+0] = this->value[i][0];
860       buffer[3*i+1] = this->value[i][1];
861       buffer[3*i+2] = this->value[i][2];
862     }
863   }
864 
865   this->getGLShaderParameter(shader->getCacheContext())->set3fv(shader, num, buffer,
866                                                                 this->name.getValue().getString(),
867                                                                 this->identifier.getValue());
868   delete[] buffer;
869 }
870 
871 /* **************************************************************************
872  * ***                      SoShaderParameterArray4f                      ***
873  * **************************************************************************/
874 
875 SO_NODE_SOURCE(SoShaderParameterArray4f);
876 
initClass(void)877 void SoShaderParameterArray4f::initClass(void)
878 {
879   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray4f,
880                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
881 }
882 
SoShaderParameterArray4f(void)883 SoShaderParameterArray4f::SoShaderParameterArray4f(void)
884 {
885   SO_NODE_CONSTRUCTOR(SoShaderParameterArray4f);
886   SO_NODE_ADD_FIELD(value, (SbVec4f(0,0,0,0)));
887 }
888 
~SoShaderParameterArray4f()889 SoShaderParameterArray4f::~SoShaderParameterArray4f()
890 {
891 }
892 
updateParameter(SoGLShaderObject * shader)893 void SoShaderParameterArray4f::updateParameter(SoGLShaderObject *shader)
894 {
895   this->ensureParameter(shader);
896 
897   int     num    = this->value.getNum();
898   float * buffer = NULL;
899 
900   if (num > 0) {
901     buffer = new float[4*num];
902     for (int i=0; i<num; i++) {
903       buffer[4*i+0] = this->value[i][0];
904       buffer[4*i+1] = this->value[i][1];
905       buffer[4*i+2] = this->value[i][2];
906       buffer[4*i+3] = this->value[i][3];
907     }
908   }
909 
910   this->getGLShaderParameter(shader->getCacheContext())
911         ->set4fv(shader, num, buffer,
912                  this->name.getValue().getString(),
913                  this->identifier.getValue());
914   delete[] buffer;
915 }
916 
917 /* **************************************************************************
918  * ***                       SoShaderParameterMatrix                      ***
919  * **************************************************************************/
920 
921 SO_NODE_SOURCE(SoShaderParameterMatrix);
922 
initClass(void)923 void SoShaderParameterMatrix::initClass(void)
924 {
925   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterMatrix,
926                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
927 }
928 
SoShaderParameterMatrix(void)929 SoShaderParameterMatrix::SoShaderParameterMatrix(void)
930 {
931   SO_NODE_CONSTRUCTOR(SoShaderParameterMatrix);
932   SO_NODE_ADD_FIELD(value, (SbMatrix(1,0,0,0,
933                                      0,1,0,0,
934                                      0,0,1,0,
935                                      0,0,0,1)));
936 }
937 
~SoShaderParameterMatrix()938 SoShaderParameterMatrix::~SoShaderParameterMatrix()
939 {
940 }
941 
updateParameter(SoGLShaderObject * shader)942 void SoShaderParameterMatrix::updateParameter(SoGLShaderObject *shader)
943 {
944   this->ensureParameter(shader);
945 
946   this->getGLShaderParameter(shader->getCacheContext())->setMatrix(shader,  this->value.getValue()[0],
947                                                                    this->name.getValue().getString(),
948                                                                    this->identifier.getValue());
949 }
950 
951 /* **************************************************************************
952  * ***                       SoShaderParameterMatrixArray                 ***
953  * **************************************************************************/
954 
955 SO_NODE_SOURCE(SoShaderParameterMatrixArray);
956 
initClass(void)957 void SoShaderParameterMatrixArray::initClass(void)
958 {
959   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterMatrixArray,
960                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
961 }
962 
SoShaderParameterMatrixArray(void)963 SoShaderParameterMatrixArray::SoShaderParameterMatrixArray(void)
964 {
965   SO_NODE_CONSTRUCTOR(SoShaderParameterMatrixArray);
966   SO_NODE_ADD_FIELD(value, (SbMatrix(1,0,0,0,
967                                      0,1,0,0,
968                                      0,0,1,0,
969                                      0,0,0,1)));
970 }
971 
~SoShaderParameterMatrixArray()972 SoShaderParameterMatrixArray::~SoShaderParameterMatrixArray()
973 {
974 }
975 
updateParameter(SoGLShaderObject * shader)976 void SoShaderParameterMatrixArray::updateParameter(SoGLShaderObject *shader)
977 {
978   this->ensureParameter(shader);
979 
980   int     num    = this->value.getNum();
981   float * buffer = NULL;
982 
983   if (num > 0) {
984     buffer = new float[16*num];
985     float * ptr = buffer;
986     for (int i=0; i<num; i++) {
987       const float * matrix = this->value[i].getValue()[0];
988       for (int j=0; j<16; j++) *(ptr++) = *(matrix++);
989     }
990   }
991 
992   this->getGLShaderParameter(shader->getCacheContext())
993         ->setMatrixArray(shader, num, buffer,
994                          this->name.getValue().getString(),
995                          this->identifier.getValue());
996 
997   delete[] buffer;
998 }
999 
1000 
1001 /* **************************************************************************
1002  * *** SoShaderParameter1i ***
1003  * **************************************************************************/
1004 
1005 
1006 SO_NODE_SOURCE(SoShaderParameter1i);
1007 
initClass(void)1008 void SoShaderParameter1i::initClass(void)
1009 {
1010   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter1i,
1011                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1012 }
1013 
SoShaderParameter1i(void)1014 SoShaderParameter1i::SoShaderParameter1i(void)
1015 {
1016   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter1i);
1017   SO_NODE_ADD_FIELD(value, (0));
1018 }
1019 
~SoShaderParameter1i()1020 SoShaderParameter1i::~SoShaderParameter1i()
1021 {
1022 }
1023 
1024 void
updateParameter(SoGLShaderObject * shader)1025 SoShaderParameter1i::updateParameter(SoGLShaderObject *shader)
1026 {
1027   this->ensureParameter(shader);
1028   this->getGLShaderParameter(shader->getCacheContext())->set1i(shader,
1029                                                                this->value.getValue(),
1030                                                                this->name.getValue().getString(),
1031                                                                this->identifier.getValue());
1032 }
1033 
1034 /* **************************************************************************
1035  * *** SoShaderParameter2i ***
1036  * **************************************************************************/
1037 
1038 SO_NODE_SOURCE(SoShaderParameter2i);
1039 
SoShaderParameter2i()1040 SoShaderParameter2i::SoShaderParameter2i()
1041 {
1042   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter2i);
1043   SO_NODE_ADD_FIELD(value, (0,0));
1044 }
1045 
~SoShaderParameter2i()1046 SoShaderParameter2i::~SoShaderParameter2i()
1047 {
1048 }
1049 
1050 void
initClass()1051 SoShaderParameter2i::initClass()
1052 {
1053   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter2i,
1054                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1055 }
1056 
1057 void
updateParameter(SoGLShaderObject * shader)1058 SoShaderParameter2i::updateParameter(SoGLShaderObject *shader)
1059 {
1060   this->ensureParameter(shader);
1061   this->getGLShaderParameter(shader->getCacheContext())->set2i(shader,
1062                                                                this->value.getValue().getValue(),
1063                                                                this->name.getValue().getString(),
1064                                                                this->identifier.getValue());
1065 }
1066 
1067 /* **************************************************************************
1068  * *** SoShaderParameter3i ***
1069  * **************************************************************************/
1070 
1071 SO_NODE_SOURCE(SoShaderParameter3i);
1072 
SoShaderParameter3i()1073 SoShaderParameter3i::SoShaderParameter3i()
1074 {
1075   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter3i);
1076   SO_NODE_ADD_FIELD(value, (0,0,0));
1077 }
1078 
~SoShaderParameter3i()1079 SoShaderParameter3i::~SoShaderParameter3i()
1080 {
1081 }
1082 
1083 void
initClass()1084 SoShaderParameter3i::initClass()
1085 {
1086   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter3i,
1087                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1088 }
1089 
1090 void
updateParameter(SoGLShaderObject * shader)1091 SoShaderParameter3i::updateParameter(SoGLShaderObject *shader)
1092 {
1093   this->ensureParameter(shader);
1094   this->getGLShaderParameter(shader->getCacheContext())->set3i(shader,
1095                                                                this->value.getValue().getValue(),
1096                                                                this->name.getValue().getString(),
1097                                                                this->identifier.getValue());
1098 }
1099 
1100 /* **************************************************************************
1101  * *** SoShaderParameter4i ***
1102  * **************************************************************************/
1103 
1104 SO_NODE_SOURCE(SoShaderParameter4i);
1105 
SoShaderParameter4i()1106 SoShaderParameter4i::SoShaderParameter4i()
1107 {
1108   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameter4i);
1109   SO_NODE_ADD_FIELD(value, (0,0,0,0));
1110 }
1111 
~SoShaderParameter4i()1112 SoShaderParameter4i::~SoShaderParameter4i()
1113 {
1114 }
1115 
1116 void
initClass()1117 SoShaderParameter4i::initClass()
1118 {
1119   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameter4i,
1120                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1121 }
1122 
1123 void
updateParameter(SoGLShaderObject * shader)1124 SoShaderParameter4i::updateParameter(SoGLShaderObject *shader)
1125 {
1126   this->ensureParameter(shader);
1127   this->getGLShaderParameter(shader->getCacheContext())->set4i(shader,
1128                                                                this->value.getValue().getValue(),
1129                                                                this->name.getValue().getString(),
1130                                                                this->identifier.getValue());
1131 }
1132 
1133 /* **************************************************************************
1134  * *** SoShaderParameterArray1i ***
1135  * **************************************************************************/
1136 
1137 SO_NODE_SOURCE(SoShaderParameterArray1i);
1138 
SoShaderParameterArray1i()1139 SoShaderParameterArray1i::SoShaderParameterArray1i()
1140 {
1141   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameterArray1i);
1142   SO_NODE_ADD_FIELD(value, (0));
1143 }
1144 
~SoShaderParameterArray1i()1145 SoShaderParameterArray1i::~SoShaderParameterArray1i()
1146 {
1147 }
1148 
1149 void
initClass()1150 SoShaderParameterArray1i::initClass()
1151 {
1152   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray1i,
1153                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1154 }
1155 
1156 void
updateParameter(SoGLShaderObject * shader)1157 SoShaderParameterArray1i::updateParameter(SoGLShaderObject *shader)
1158 {
1159   this->ensureParameter(shader);
1160   this->getGLShaderParameter(shader->getCacheContext())->set1iv(shader,
1161                                                                 this->value.getNum(),
1162                                                                 (const int32_t*) this->value.getValues(0),
1163                                                                 this->name.getValue().getString(),
1164                                                                 this->identifier.getValue());
1165 }
1166 
1167 /* **************************************************************************
1168  * *** SoShaderParameterArray2i ***
1169  * **************************************************************************/
1170 
1171 SO_NODE_SOURCE(SoShaderParameterArray2i);
1172 
SoShaderParameterArray2i()1173 SoShaderParameterArray2i::SoShaderParameterArray2i()
1174 {
1175   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameterArray2i);
1176   SO_NODE_ADD_FIELD(value, (0,0));
1177 }
1178 
~SoShaderParameterArray2i()1179 SoShaderParameterArray2i::~SoShaderParameterArray2i()
1180 {
1181 }
1182 
1183 void
initClass()1184 SoShaderParameterArray2i::initClass()
1185 {
1186   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray2i,
1187                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1188 }
1189 
1190 void
updateParameter(SoGLShaderObject * shader)1191 SoShaderParameterArray2i::updateParameter(SoGLShaderObject *shader)
1192 {
1193   this->ensureParameter(shader);
1194   this->getGLShaderParameter(shader->getCacheContext())->set2iv(shader,
1195                                                                 this->value.getNum(),
1196                                                                 (const int32_t*) this->value.getValues(0),
1197                                                                 this->name.getValue().getString(),
1198                                                                 this->identifier.getValue());
1199 }
1200 
1201 /* **************************************************************************
1202  * *** SoShaderParameterArray3i ***
1203  * **************************************************************************/
1204 
1205 SO_NODE_SOURCE(SoShaderParameterArray3i);
1206 
SoShaderParameterArray3i()1207 SoShaderParameterArray3i::SoShaderParameterArray3i()
1208 {
1209   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameterArray3i);
1210   SO_NODE_ADD_FIELD(value, (0,0,0));
1211 }
1212 
~SoShaderParameterArray3i()1213 SoShaderParameterArray3i::~SoShaderParameterArray3i()
1214 {
1215 }
1216 
1217 void
initClass()1218 SoShaderParameterArray3i::initClass()
1219 {
1220   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray3i,
1221                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1222 }
1223 
1224 void
updateParameter(SoGLShaderObject * shader)1225 SoShaderParameterArray3i::updateParameter(SoGLShaderObject *shader)
1226 {
1227   this->ensureParameter(shader);
1228   this->getGLShaderParameter(shader->getCacheContext())->set3iv(shader,
1229                                                                 this->value.getNum(),
1230                                                                 (const int32_t*) this->value.getValues(0),
1231                                                                 this->name.getValue().getString(),
1232                                                                 this->identifier.getValue());
1233 }
1234 
1235 /* **************************************************************************
1236  * *** SoShaderParameterArray4i ***
1237  * **************************************************************************/
1238 
1239 SO_NODE_SOURCE(SoShaderParameterArray4i);
1240 
SoShaderParameterArray4i()1241 SoShaderParameterArray4i::SoShaderParameterArray4i()
1242 {
1243   SO_NODE_INTERNAL_CONSTRUCTOR(SoShaderParameterArray4i);
1244   SO_NODE_ADD_FIELD(value, (0,0,0,0));
1245 }
1246 
~SoShaderParameterArray4i()1247 SoShaderParameterArray4i::~SoShaderParameterArray4i()
1248 {
1249 }
1250 
1251 void
initClass()1252 SoShaderParameterArray4i::initClass()
1253 {
1254   SO_NODE_INTERNAL_INIT_CLASS(SoShaderParameterArray4i,
1255                               SO_FROM_COIN_2_5|SO_FROM_INVENTOR_5_0);
1256 }
1257 
1258 void
updateParameter(SoGLShaderObject * shader)1259 SoShaderParameterArray4i::updateParameter(SoGLShaderObject *shader)
1260 {
1261   this->ensureParameter(shader);
1262   this->getGLShaderParameter(shader->getCacheContext())->set4iv(shader,
1263                                                                 this->value.getNum(),
1264                                                                 (const int32_t*) this->value.getValues(0),
1265                                                                 this->name.getValue().getString(),
1266                                                                 this->identifier.getValue());
1267 }
1268 
1269 #undef PRIVATE
1270 
1271 // *************************************************************************
1272 
1273 #ifdef COIN_TEST_SUITE
1274 
BOOST_AUTO_TEST_CASE(initialized)1275 BOOST_AUTO_TEST_CASE(initialized)
1276 {
1277   {
1278     SoShaderParameter1f * parameter1f = new SoShaderParameter1f;
1279     assert(parameter1f);
1280     parameter1f->ref();
1281     BOOST_CHECK_MESSAGE(parameter1f->getTypeId() != SoType::badType(),
1282                         "missing class initialization");
1283     parameter1f->unref();
1284   }
1285   {
1286     SoShaderParameter1i * parameter1i = new SoShaderParameter1i;
1287     assert(parameter1i);
1288     parameter1i->ref();
1289     BOOST_CHECK_MESSAGE(parameter1i->getTypeId() != SoType::badType(),
1290                         "missing class initialization");
1291     parameter1i->unref();
1292   }
1293   {
1294     SoShaderParameter2f * parameter2f = new SoShaderParameter2f;
1295     assert(parameter2f);
1296     parameter2f->ref();
1297     BOOST_CHECK_MESSAGE(parameter2f->getTypeId() != SoType::badType(),
1298                         "missing class initialization");
1299     parameter2f->unref();
1300   }
1301   {
1302     SoShaderParameter2i * parameter2i = new SoShaderParameter2i;
1303     assert(parameter2i);
1304     parameter2i->ref();
1305     BOOST_CHECK_MESSAGE(parameter2i->getTypeId() != SoType::badType(),
1306                         "missing class initialization");
1307     parameter2i->unref();
1308   }
1309   {
1310     SoShaderParameter3f * parameter3f = new SoShaderParameter3f;
1311     assert(parameter3f);
1312     parameter3f->ref();
1313     BOOST_CHECK_MESSAGE(parameter3f->getTypeId() != SoType::badType(),
1314                         "missing class initialization");
1315     parameter3f->unref();
1316   }
1317   {
1318     SoShaderParameter3i * parameter3i = new SoShaderParameter3i;
1319     assert(parameter3i);
1320     parameter3i->ref();
1321     BOOST_CHECK_MESSAGE(parameter3i->getTypeId() != SoType::badType(),
1322                         "missing class initialization");
1323     parameter3i->unref();
1324   }
1325   {
1326     SoShaderParameter4f * parameter4f = new SoShaderParameter4f;
1327     assert(parameter4f);
1328     parameter4f->ref();
1329     BOOST_CHECK_MESSAGE(parameter4f->getTypeId() != SoType::badType(),
1330                         "missing class initialization");
1331     parameter4f->unref();
1332   }
1333   {
1334     SoShaderParameter4i * parameter4i = new SoShaderParameter4i;
1335     assert(parameter4i);
1336     parameter4i->ref();
1337     BOOST_CHECK_MESSAGE(parameter4i->getTypeId() != SoType::badType(),
1338                         "missing class initialization");
1339     parameter4i->unref();
1340   }
1341 
1342   {
1343     SoShaderParameterArray1f * parametera1f = new SoShaderParameterArray1f;
1344     assert(parametera1f);
1345     parametera1f->ref();
1346     BOOST_CHECK_MESSAGE(parametera1f->getTypeId() != SoType::badType(),
1347                         "missing class initialization");
1348     parametera1f->unref();
1349   }
1350   {
1351     SoShaderParameterArray1i * parametera1i = new SoShaderParameterArray1i;
1352     assert(parametera1i);
1353     parametera1i->ref();
1354     BOOST_CHECK_MESSAGE(parametera1i->getTypeId() != SoType::badType(),
1355                         "missing class initialization");
1356     parametera1i->unref();
1357   }
1358   {
1359     SoShaderParameterArray2f * parametera2f = new SoShaderParameterArray2f;
1360     assert(parametera2f);
1361     parametera2f->ref();
1362     BOOST_CHECK_MESSAGE(parametera2f->getTypeId() != SoType::badType(),
1363                         "missing class initialization");
1364     parametera2f->unref();
1365   }
1366   {
1367     SoShaderParameterArray2i * parametera2i = new SoShaderParameterArray2i;
1368     assert(parametera2i);
1369     parametera2i->ref();
1370     BOOST_CHECK_MESSAGE(parametera2i->getTypeId() != SoType::badType(),
1371                         "missing class initialization");
1372     parametera2i->unref();
1373   }
1374   {
1375     SoShaderParameterArray3f * parametera3f = new SoShaderParameterArray3f;
1376     assert(parametera3f);
1377     parametera3f->ref();
1378     BOOST_CHECK_MESSAGE(parametera3f->getTypeId() != SoType::badType(),
1379                         "missing class initialization");
1380     parametera3f->unref();
1381   }
1382   {
1383     SoShaderParameterArray3i * parametera3i = new SoShaderParameterArray3i;
1384     assert(parametera3i);
1385     parametera3i->ref();
1386     BOOST_CHECK_MESSAGE(parametera3i->getTypeId() != SoType::badType(),
1387                         "missing class initialization");
1388     parametera3i->unref();
1389   }
1390   {
1391     SoShaderParameterArray4f * parametera4f = new SoShaderParameterArray4f;
1392     assert(parametera4f);
1393     parametera4f->ref();
1394     BOOST_CHECK_MESSAGE(parametera4f->getTypeId() != SoType::badType(),
1395                         "missing class initialization");
1396     parametera4f->unref();
1397   }
1398   {
1399     SoShaderParameterArray4i * parametera4i = new SoShaderParameterArray4i;
1400     assert(parametera4i);
1401     parametera4i->ref();
1402     BOOST_CHECK_MESSAGE(parametera4i->getTypeId() != SoType::badType(),
1403                         "missing class initialization");
1404     parametera4i->unref();
1405   }
1406 
1407   {
1408     SoShaderParameterMatrix * matrix = new SoShaderParameterMatrix;
1409     assert(matrix);
1410     matrix->ref();
1411     BOOST_CHECK_MESSAGE(matrix->getTypeId() != SoType::badType(),
1412                         "missing class initialization");
1413     matrix->unref();
1414   }
1415   {
1416     SoShaderParameterMatrixArray * matrixarray = new SoShaderParameterMatrixArray;
1417     assert(matrixarray);
1418     matrixarray->ref();
1419     BOOST_CHECK_MESSAGE(matrixarray->getTypeId() != SoType::badType(),
1420                         "missing class initialization");
1421     matrixarray->unref();
1422   }
1423 
1424   {
1425     SoShaderStateMatrixParameter * statematrix = new SoShaderStateMatrixParameter;
1426     assert(statematrix);
1427     statematrix->ref();
1428     BOOST_CHECK_MESSAGE(statematrix->getTypeId() != SoType::badType(),
1429                         "missing class initialization");
1430     statematrix->unref();
1431   }
1432 }
1433 
1434 #endif // COIN_TEST_SUITE
1435