Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoShaderParameter.h
1 #ifndef COIN_SOSHADERPARAMETER_H
2 #define COIN_SOSHADERPARAMETER_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/nodes/SoNode.h>
37 #include <Inventor/nodes/SoSubNode.h>
38 #include <Inventor/fields/SoSFString.h>
39 #include <Inventor/fields/SoSFFloat.h>
40 #include <Inventor/fields/SoSFInt32.h>
41 #include <Inventor/fields/SoSFVec2f.h>
42 #include <Inventor/fields/SoSFVec3f.h>
43 #include <Inventor/fields/SoSFVec4f.h>
44 #include <Inventor/fields/SoMFFloat.h>
45 #include <Inventor/fields/SoMFInt32.h>
46 #include <Inventor/fields/SoMFVec2f.h>
47 #include <Inventor/fields/SoMFVec3f.h>
48 #include <Inventor/fields/SoMFVec4f.h>
49 #include <Inventor/fields/SoSFMatrix.h>
50 #include <Inventor/fields/SoMFMatrix.h>
51 #include <Inventor/fields/SoSFNode.h>
52 #include <Inventor/fields/SoSFEnum.h>
53 #include <Inventor/fields/SoSFImage.h>
54 
55 #include <Inventor/fields/SoSFVec2i32.h>
56 #include <Inventor/fields/SoSFVec3i32.h>
57 #include <Inventor/fields/SoSFVec4i32.h>
58 #include <Inventor/fields/SoMFVec2i32.h>
59 #include <Inventor/fields/SoMFVec3i32.h>
60 #include <Inventor/fields/SoMFVec4i32.h>
61 
62 class SoGLShaderParameter;
63 class SoGLShaderObject;
64 class SoState;
65 
66 // *************************************************************************
67 
68 // FIXME: split to one header file for each class? 20050120 mortene.
69 
70 /* **************************************************************************
71  * *** SoShaderParameter ***
72  * **************************************************************************/
73 
74 class COIN_DLL_API SoShaderParameter : public SoNode {
75  typedef SoNode inherited;
77 
78 public:
81 
82  SoINTERNAL public:
83  static void initClass();
84 
85 protected:
87  virtual ~SoShaderParameter();
88 };
89 
90 /* **************************************************************************
91  * *** SoUniformShaderParameter ***
92  * **************************************************************************/
93 class SoUniformShaderParameterP;
94 
95 class COIN_DLL_API SoUniformShaderParameter : public SoShaderParameter {
98 
99  SoINTERNAL public:
100  static void initClass(void);
101  virtual void updateParameter(SoGLShaderObject *shaderObject) = 0;
102 
103 protected:
105  virtual ~SoUniformShaderParameter();
106 
107  SoGLShaderParameter * getGLShaderParameter(const uint32_t cachecontext);
108  void ensureParameter(SoGLShaderObject * shader);
109 
110 private:
111  SoUniformShaderParameterP * pimpl;
112 };
113 
114 /* **************************************************************************
115  * *** SoShaderParameter1f ***
116  * **************************************************************************/
117 
118 class COIN_DLL_API SoShaderParameter1f : public SoUniformShaderParameter {
121 
122 public:
125 
126  SoINTERNAL public:
127  static void initClass();
128  virtual void updateParameter(SoGLShaderObject *shaderObject);
129 
130 protected:
131  virtual ~SoShaderParameter1f();
132 };
133 
134 /* **************************************************************************
135  * *** SoShaderParameter1i ***
136  * **************************************************************************/
137 
138 class COIN_DLL_API SoShaderParameter1i : public SoUniformShaderParameter {
141 
142 public:
145 
146  SoINTERNAL public:
147  static void initClass();
148  virtual void updateParameter(SoGLShaderObject *shaderObject);
149 
150 protected:
151  virtual ~SoShaderParameter1i();
152 };
153 
154 /* **************************************************************************
155  * *** SoShaderParameter2f ***
156  * **************************************************************************/
157 
158 class COIN_DLL_API SoShaderParameter2f : public SoUniformShaderParameter {
161 
162 public:
165 
166  SoINTERNAL public:
167  static void initClass();
168  virtual void updateParameter(SoGLShaderObject *shaderObject);
169 
170 protected:
171  virtual ~SoShaderParameter2f();
172 };
173 
174 /* **************************************************************************
175  * *** SoShaderParameter2i ***
176  * **************************************************************************/
177 
178 class COIN_DLL_API SoShaderParameter2i : public SoUniformShaderParameter {
181 
182 public:
185 
186  SoINTERNAL public:
187  static void initClass();
188  virtual void updateParameter(SoGLShaderObject *shaderObject);
189 
190 protected:
191  virtual ~SoShaderParameter2i();
192 };
193 
194 /* **************************************************************************
195  * *** SoShaderParameter3f ***
196  * **************************************************************************/
197 
198 class COIN_DLL_API SoShaderParameter3f : public SoUniformShaderParameter {
201 
202 public:
204 
206 
207  SoINTERNAL public:
208  static void initClass();
209  virtual void updateParameter(SoGLShaderObject *shaderObject);
210 
211 protected:
212  virtual ~SoShaderParameter3f();
213 };
214 
215 /* **************************************************************************
216  * *** SoShaderParameter3i ***
217  * **************************************************************************/
218 
219 class COIN_DLL_API SoShaderParameter3i : public SoUniformShaderParameter {
222 
223 public:
225 
227 
228  SoINTERNAL public:
229  static void initClass();
230  virtual void updateParameter(SoGLShaderObject *shaderObject);
231 
232 protected:
233  virtual ~SoShaderParameter3i();
234 };
235 
236 /* **************************************************************************
237  * *** SoShaderParameter4f ***
238  * **************************************************************************/
239 
240 class COIN_DLL_API SoShaderParameter4f : public SoUniformShaderParameter {
243 
244 public:
246 
248 
249  SoINTERNAL public:
250  static void initClass();
251  virtual void updateParameter(SoGLShaderObject *shaderObject);
252 
253 protected:
254  virtual ~SoShaderParameter4f();
255 };
256 
257 /* **************************************************************************
258  * *** SoShaderParameter4i ***
259  * **************************************************************************/
260 
261 class COIN_DLL_API SoShaderParameter4i : public SoUniformShaderParameter {
264 
265 public:
267 
269 
270  SoINTERNAL public:
271  static void initClass();
272  virtual void updateParameter(SoGLShaderObject *shaderObject);
273 
274 protected:
275  virtual ~SoShaderParameter4i();
276 };
277 
278 /* **************************************************************************
279  * *** SoShaderParameterArray1f ***
280  * **************************************************************************/
281 
285 
286 public:
288 
290 
291  SoINTERNAL public:
292  static void initClass();
293  virtual void updateParameter(SoGLShaderObject *shaderObject);
294 
295 protected:
296  virtual ~SoShaderParameterArray1f();
297 };
298 
299 /* **************************************************************************
300  * *** SoShaderParameterArray1i ***
301  * **************************************************************************/
302 
306 
307 public:
309 
311 
312  SoINTERNAL public:
313  static void initClass();
314  virtual void updateParameter(SoGLShaderObject *shaderObject);
315 
316 protected:
317  virtual ~SoShaderParameterArray1i();
318 };
319 
320 /* **************************************************************************
321  * *** SoShaderParameterArray2f ***
322  * **************************************************************************/
323 
327 
328 public:
330 
332 
333  SoINTERNAL public:
334  static void initClass();
335  virtual void updateParameter(SoGLShaderObject *shaderObject);
336 
337 protected:
338  virtual ~SoShaderParameterArray2f();
339 };
340 
341 /* **************************************************************************
342  * *** SoShaderParameterArray2i ***
343  * **************************************************************************/
347 
348 public:
350 
352 
353  SoINTERNAL public:
354  static void initClass();
355  virtual void updateParameter(SoGLShaderObject *shaderObject);
356 
357 protected:
358  virtual ~SoShaderParameterArray2i();
359 };
360 
361 /* **************************************************************************
362  * *** SoShaderParameterArray3f ***
363  * **************************************************************************/
364 
368 
369 public:
371 
373 
374  SoINTERNAL public:
375  static void initClass();
376  virtual void updateParameter(SoGLShaderObject *shaderObject);
377 
378 protected:
379  virtual ~SoShaderParameterArray3f();
380 };
381 
382 /* **************************************************************************
383  * *** SoShaderParameterArray3i ***
384  * **************************************************************************/
385 
389 
390 public:
392 
394 
395  SoINTERNAL public:
396  static void initClass();
397  virtual void updateParameter(SoGLShaderObject *shaderObject);
398 
399 protected:
400  virtual ~SoShaderParameterArray3i();
401 };
402 
403 /* **************************************************************************
404  * *** SoShaderParameterArray4f ***
405  * **************************************************************************/
406 
410 
411 public:
413 
415 
416  SoINTERNAL public:
417  static void initClass();
418  virtual void updateParameter(SoGLShaderObject *shaderObject);
419 
420 protected:
421  virtual ~SoShaderParameterArray4f();
422 
423 };
424 
425 /* **************************************************************************
426  * *** SoShaderParameterArray4i ***
427  * **************************************************************************/
428 
432 
433 public:
434  SoMFVec4i32 value;
435 
437 
438  SoINTERNAL public:
439  static void initClass();
440  virtual void updateParameter(SoGLShaderObject *shaderObject);
441 
442 protected:
443  virtual ~SoShaderParameterArray4i();
444 };
445 
446 /* **************************************************************************
447  * *** SoShaderParameterMatrix ***
448  * **************************************************************************/
449 
453 
454 public:
456 
458 
459  SoINTERNAL public:
460  static void initClass();
461  virtual void updateParameter(SoGLShaderObject *shaderObject);
462 
463 protected:
464  virtual ~SoShaderParameterMatrix();
465 };
466 
467 /* **************************************************************************
468  * *** SoShaderParameterMatrixArray ***
469  * **************************************************************************/
470 
474 
475 public:
477 
479 
480  SoINTERNAL public:
481  static void initClass();
482  virtual void updateParameter(SoGLShaderObject *shaderObject);
483 
484 protected:
485  virtual ~SoShaderParameterMatrixArray();
486 };
487 
488 /* **************************************************************************
489  * *** SoShaderStateMatrixParameter ***
490  * **************************************************************************/
491 
495 
496 public:
497 
498  enum MatrixType {
499  MODELVIEW,
500  PROJECTION,
501  TEXTURE,
502  MODELVIEW_PROJECTION
503  };
504 
506  IDENTITY,
507  TRANSPOSE,
508  INVERSE,
509  INVERSE_TRANSPOSE
510  };
511 
514 
516  virtual ~SoShaderStateMatrixParameter();
517 
518  static void initClass(void);
519  virtual void updateParameter(SoGLShaderObject *shaderObject);
520  virtual void updateValue(SoState *state);
521 
522 protected:
523  // Unlike in other parameter classes, here value is not a field because
524  // it is updated dynamically from the state.
525  SbMatrix value;
526 };
527 
528 #endif /* ! COIN_SOSHADERPARAMETER_H */
SoMFMatrix value
Definition: SoShaderParameter.h:476
The SoShaderParameter3f class is used to define a three-dimensional floating point value as shader pa...
Definition: SoShaderParameter.h:198
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition: SoBase.h:45
The SoShaderParameterMatrix class is used to define a matrix as shader parameter. ...
Definition: SoShaderParameter.h:450
The SoMFFloat class is a container for floating point values.
Definition: SoMFFloat.h:39
The SoShaderParameterArray4f class is used to define a four-dimensional floating point array as shade...
Definition: SoShaderParameter.h:407
The SoUniformShaderParameter class is the base class for all uniform shader variables.
Definition: SoShaderParameter.h:95
The SoMFVec2i32 class is a container for SbVec2i32 vectors.
Definition: SoMFVec2i32.h:40
#define SO_NODE_HEADER(classname)
SoMFFloat value
Definition: SoShaderParameter.h:287
The SoMFVec3i32 class is a container for SbVec3i32 vectors.
Definition: SoMFVec3i32.h:40
The SoMFVec4i32 class is a container for SbVec4i32 vectors.
Definition: SoMFVec4i32.h:40
SoSFInt32 value
Definition: SoShaderParameter.h:143
The SoShaderParameterArray2f class is used to define a two-dimensional floating point array as shader...
Definition: SoShaderParameter.h:324
The SoSFVec4f class is a container for an SbVec4f vector.
Definition: SoSFVec4f.h:40
The SoShaderParameter1i class is used to define an integer value as shader parameter.
Definition: SoShaderParameter.h:138
The SoSFVec2i32 class is a container for an SbVec2i32 vector.
Definition: SoSFVec2i32.h:40
The SoShaderParameter2i class is used to define a two-dimensional integer value as shader parameter...
Definition: SoShaderParameter.h:178
The SoSFVec3i32 class is a container for an SbVec3i32 vector.
Definition: SoSFVec3i32.h:40
The SoMFInt32 class is a container for 32-bit integer values.
Definition: SoMFInt32.h:39
SoSFVec2i32 value
Definition: SoShaderParameter.h:183
The SoSFVec4i32 class is a container for an SbVec4i32 vector.
Definition: SoSFVec4i32.h:40
The SoSFString class is a container for an SbString.
Definition: SoSFString.h:40
The SoShaderParameterArray3i class is used to define a three-dimensional integer array as shader para...
Definition: SoShaderParameter.h:386
The SoShaderParameterMatrixArray class is used to define a matrix array as shader parameter...
Definition: SoShaderParameter.h:471
The SoSFVec2f class is a container for an SbVec2f vector.
Definition: SoSFVec2f.h:40
The SoMFVec4f class is a container for SbVec4f vectors.
Definition: SoMFVec4f.h:40
SoSFVec2f value
Definition: SoShaderParameter.h:163
SoMFVec3i32 value
Definition: SoShaderParameter.h:391
The SoShaderParameter4i class is used to define a four-dimensional integer value as shader parameter...
Definition: SoShaderParameter.h:261
MatrixType
Definition: SoShaderParameter.h:498
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
SoSFInt32 identifier
Definition: SoShaderParameter.h:80
The SoShaderParameterArray1f class is used to define a floating point array as shader parameter...
Definition: SoShaderParameter.h:282
The SoSFEnum class is a container for an enum value.
Definition: SoSFEnum.h:40
SoSFString name
Definition: SoShaderParameter.h:79
SoSFVec4f value
Definition: SoShaderParameter.h:245
SoMFVec2f value
Definition: SoShaderParameter.h:329
The SoMFVec2f class is a container for SbVec2f vectors.
Definition: SoMFVec2f.h:40
SoMFVec4f value
Definition: SoShaderParameter.h:412
The SoState class manages the Coin scenegraph traversal state data.
Definition: SoState.h:44
SoMFVec2i32 value
Definition: SoShaderParameter.h:349
The SoSFInt32 class is a container for a 32-bit integer value.
Definition: SoSFInt32.h:39
The SoShaderParameter1f class is used to define a floating point value as shader parameter.
Definition: SoShaderParameter.h:118
SoSFEnum matrixTransform
Definition: SoShaderParameter.h:513
SoMFVec3f value
Definition: SoShaderParameter.h:370
The SoShaderParameter2f class is used to define a two-dimensional floating point value as shader para...
Definition: SoShaderParameter.h:158
SoMFInt32 value
Definition: SoShaderParameter.h:308
The SoShaderParameterArray3f class is used to define a three-dimensional floating point array as shad...
Definition: SoShaderParameter.h:365
The SbMatrix class is a 4x4 dimensional representation of a matrix.
Definition: SbMatrix.h:47
The SoShaderParameter4f class is used to define a four-dimensional floating point value as shader par...
Definition: SoShaderParameter.h:240
SoSFMatrix value
Definition: SoShaderParameter.h:455
The SoShaderParameter3i class is used to define a three-dimensional integer value as shader parameter...
Definition: SoShaderParameter.h:219
The SoShaderParameterArray4i class is used to define a four-dimensional integer array as shader param...
Definition: SoShaderParameter.h:429
SoSFVec3f value
Definition: SoShaderParameter.h:203
The SoMFMatrix class is a container for SbMatrix values.
Definition: SoMFMatrix.h:40
The SoSFFloat class is a container for a floating point value.
Definition: SoSFFloat.h:39
MatrixTransform
Definition: SoShaderParameter.h:505
The SoShaderParameterArray2i class is used to define a two-dimensional integer array as shader parame...
Definition: SoShaderParameter.h:344
The SoSFVec3f class is a container for an SbVec3f vector.
Definition: SoSFVec3f.h:40
SoSFEnum matrixType
Definition: SoShaderParameter.h:512
The SoShaderStateMatrixParameter class is used to define a matrix as shader parameter whose content i...
Definition: SoShaderParameter.h:492
The SoShaderParameter class is the base class for all shader parameter classes.
Definition: SoShaderParameter.h:74
The SoSFMatrix class is a container for an SbMatrix.
Definition: SoSFMatrix.h:40
SoSFFloat value
Definition: SoShaderParameter.h:123
SoSFVec3i32 value
Definition: SoShaderParameter.h:224
The SoMFVec3f class is a container for SbVec3f vectors.
Definition: SoMFVec3f.h:40
SoSFVec4i32 value
Definition: SoShaderParameter.h:266
#define SO_NODE_ABSTRACT_HEADER(classname)
virtual void updateParameter(SoGLShaderObject *shaderObject)=0
Updates the shader parameter in the OpenGL state with the content of the value field.
The SoShaderParameterArray1i class is used to define an integer array as shader parameter.
Definition: SoShaderParameter.h:303