OpenSceneGraph 3.6.5
Uniform
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 * Copyright (C) 2003-2005 3Dlabs Inc. Ltd.
3 * Copyright (C) 2008 Zebra Imaging
4 * Copyright (C) 2012 David Callu
5 *
6 * This application is open source and may be redistributed and/or modified
7 * freely and without restriction, both in commercial and non commercial
8 * applications, as long as this copyright notice is maintained.
9 *
10 * This application is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13*/
14
15/* file: include/osg/Uniform
16 * author: Mike Weiblen 2008-01-02
17*/
18
19#ifndef OSG_UNIFORM
20#define OSG_UNIFORM 1
21
22#include <osg/ref_ptr>
23#include <osg/Array>
24#include <osg/Callback>
25#include <osg/Vec2>
26#include <osg/Vec3>
27#include <osg/Vec4>
28#include <osg/Vec2d>
29#include <osg/Vec3d>
30#include <osg/Vec4d>
31#include <osg/Matrix>
32#include <osg/GLExtensions>
33
34#include <string.h> // for memset
35#include <string>
36#include <vector>
37
38
39namespace osg {
40
41// forward declare
42class NodeVisitor;
43
45// C++ classes to represent the GLSL-specific types.
46//
47// Warning :
48// OSG is Row major
49// GLSL is Column Major
50//
51// If you define an Uniform with type Uniform::FLOAT_MAT4X2 and so use a Matrix4x2 to setup your Uniform,
52// like this :
53// 1 2
54// 3 4
55// 5 6
56// 7 8
57//
58// you will get in your shader a Column Major Matrix like this :
59// 1 3 5 7
60// 2 4 6 8
61//
62// In simple term, you matrix in OSG will be a transposed matrix in GLSL
63//
64//
65// You can avoid this behaviours starting GLSL version 1.40 with uniform layout :
66//
67// <GLSL code>
68// layout(row_major) uniform matrix4x2 myVariable;
69// <GLSL code>
70//
71//
72template <typename T, unsigned int RowN, unsigned int ColN>
74{
75 public:
76 enum { col_count = ColN };
77 enum { row_count = RowN };
78 enum { value_count = ColN * RowN };
79
80 typedef T value_type;
81
82
83 public:
86
87 value_type& operator()(int row, int col) { return _mat[row][col]; }
88 value_type operator()(int row, int col) const { return _mat[row][col]; }
89
91 {
92 if( &rhs == this ) return *this;
93 set(rhs.ptr());
94 return *this;
95 }
96
97 void set(const MatrixTemplate& rhs) { set(rhs.ptr()); }
98
99 void set(value_type const * const ptr)
100 {
101 value_type* local_ptr = (value_type*)_mat;
102 for(int i=0;i<value_count;++i) local_ptr[i]=ptr[i];
103 }
104
105 value_type* ptr() { return (value_type*)_mat; }
106 const value_type* ptr() const { return (const value_type*)_mat; }
107
108 value_type& operator [] (int i) {return ptr()[i];}
109 value_type operator [] (int i) const {return ptr()[i];}
110
111 void reset() { memset(_mat, 0, sizeof( value_type ) * value_count); }
112
113 protected:
115};
116
117template <typename T>
118class Matrix2Template : public MatrixTemplate<T, 2, 2>
119{
120 public:
123
124
125 public:
127 Matrix2Template( const Matrix2Template& mat ) { set(mat.ptr()); }
129 value_type a10, value_type a11 )
130 {
131 set( a00, a01,
132 a10, a11 );
133 }
135
136 using base_class::set;
137
138 void set(value_type a00, value_type a01,
139 value_type a10, value_type a11 )
140 {
141 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01;
142 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11;
143 }
144
146 {
147 set( 1, 0,
148 0, 1 );
149 }
150};
151
152template <typename T>
153class Matrix2x3Template : public MatrixTemplate<T, 2, 3>
154{
155 public:
158
159
160 public:
162 Matrix2x3Template( const Matrix2x3Template& mat ) { set(mat.ptr()); }
164 value_type a10, value_type a11, value_type a12 )
165 {
166 set( a00, a01, a02,
167 a10, a11, a12 );
168 }
170
171 using base_class::set;
172
173 void set( value_type a00, value_type a01, value_type a02,
174 value_type a10, value_type a11, value_type a12 )
175 {
176 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01; base_class::_mat[0][2]=a02;
177 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11; base_class::_mat[1][2]=a12;
178 }
179};
180
181template <typename T>
182class Matrix2x4Template : public MatrixTemplate<T, 2, 4>
183{
184 public:
187
188
189 public:
191 Matrix2x4Template( const Matrix2x4Template& mat ) { set(mat.ptr()); }
193 value_type a10, value_type a11, value_type a12, value_type a13 )
194 {
195 set( a00, a01, a02, a03,
196 a10, a11, a12, a13 );
197 }
199
200 using base_class::set;
201
203 value_type a10, value_type a11, value_type a12, value_type a13 )
204 {
205 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01; base_class::_mat[0][2]=a02; base_class::_mat[0][3]=a03;
206 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11; base_class::_mat[1][2]=a12; base_class::_mat[1][3]=a13;
207 }
208};
209
210template <typename T>
211class Matrix3x2Template : public MatrixTemplate<T, 3, 2>
212{
213 public:
216
217 public:
219 Matrix3x2Template( const Matrix3x2Template& mat ) { set(mat.ptr()); }
221 value_type a10, value_type a11,
222 value_type a20, value_type a21 )
223 {
224 set( a00, a01,
225 a10, a11,
226 a20, a21 );
227 }
229
230 using base_class::set;
231
232 void set( value_type a00, value_type a01,
233 value_type a10, value_type a11,
234 value_type a20, value_type a21 )
235 {
236 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01;
237 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11;
238 base_class::_mat[2][0]=a20; base_class::_mat[2][1]=a21;
239 }
240};
241
242template <typename T>
243class Matrix3Template : public MatrixTemplate<T, 3, 3>
244{
245 public:
248
249 public:
251 Matrix3Template( const Matrix3Template& mat ) { set(mat.ptr()); }
253 value_type a10, value_type a11, value_type a12,
254 value_type a20, value_type a21, value_type a22 )
255 {
256 set( a00, a01, a02,
257 a10, a11, a12,
258 a20, a21, a22 );
259 }
261
262 using base_class::set;
263
264 void set( value_type a00, value_type a01, value_type a02,
265 value_type a10, value_type a11, value_type a12,
266 value_type a20, value_type a21, value_type a22 )
267 {
268 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01; base_class::_mat[0][2]=a02;
269 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11; base_class::_mat[1][2]=a12;
270 base_class::_mat[2][0]=a20; base_class::_mat[2][1]=a21; base_class::_mat[2][2]=a22;
271 }
272
274 {
275 set( 1, 0, 0,
276 0, 1, 0,
277 0, 0, 1 );
278 }
279};
280
281template <typename T>
282class Matrix3x4Template : public MatrixTemplate<T, 3, 4>
283{
284 public:
287
288 public:
290 Matrix3x4Template( const Matrix3x4Template& mat ) { set(mat.ptr()); }
292 value_type a10, value_type a11, value_type a12, value_type a13,
293 value_type a20, value_type a21, value_type a22, value_type a23 )
294 {
295 set( a00, a01, a02, a03,
296 a10, a11, a12, a13,
297 a20, a21, a22, a23 );
298 }
300
301 using base_class::set;
302
304 value_type a10, value_type a11, value_type a12, value_type a13,
305 value_type a20, value_type a21, value_type a22, value_type a23 )
306 {
307 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01; base_class::_mat[0][2]=a02; base_class::_mat[0][3]=a03;
308 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11; base_class::_mat[1][2]=a12; base_class::_mat[1][3]=a13;
309 base_class::_mat[2][0]=a20; base_class::_mat[2][1]=a21; base_class::_mat[2][2]=a22; base_class::_mat[2][3]=a23;
310 }
311};
312
313template <typename T>
314class Matrix4x2Template : public MatrixTemplate<T, 4, 2>
315{
316 public:
319
320 public:
322 Matrix4x2Template( const Matrix4x2Template& mat ) { set(mat.ptr()); }
324 value_type a10, value_type a11,
325 value_type a20, value_type a21,
326 value_type a30, value_type a31 )
327 {
328 set( a00, a01,
329 a10, a11,
330 a20, a21,
331 a30, a31 );
332 }
334
335 using base_class::set;
336
337 void set( value_type a00, value_type a01,
338 value_type a10, value_type a11,
339 value_type a20, value_type a21,
340 value_type a30, value_type a31 )
341 {
342 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01;
343 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11;
344 base_class::_mat[2][0]=a20; base_class::_mat[2][1]=a21;
345 base_class::_mat[3][0]=a30; base_class::_mat[3][1]=a31;
346 }
347};
348
349template <typename T>
350class Matrix4x3Template : public MatrixTemplate<T, 4, 3>
351{
352 public:
355
356 public:
358 Matrix4x3Template( const Matrix4x3Template& mat ) { set(mat.ptr()); }
360 value_type a10, value_type a11, value_type a12,
361 value_type a20, value_type a21, value_type a22,
362 value_type a30, value_type a31, value_type a32 )
363 {
364 set( a00, a01, a02,
365 a10, a11, a12,
366 a20, a21, a22,
367 a30, a31, a32 );
368 }
370
371 using base_class::set;
372
373 void set( value_type a00, value_type a01, value_type a02,
374 value_type a10, value_type a11, value_type a12,
375 value_type a20, value_type a21, value_type a22,
376 value_type a30, value_type a31, value_type a32 )
377 {
378 base_class::_mat[0][0]=a00; base_class::_mat[0][1]=a01; base_class::_mat[0][2]=a02;
379 base_class::_mat[1][0]=a10; base_class::_mat[1][1]=a11; base_class::_mat[1][2]=a12;
380 base_class::_mat[2][0]=a20; base_class::_mat[2][1]=a21; base_class::_mat[2][2]=a22;
381 base_class::_mat[3][0]=a30; base_class::_mat[3][1]=a31; base_class::_mat[3][2]=a32;
382 }
383};
384
388
392
395
396
400
404
407
408
409
411
414{
415 public:
416 enum Type {
417 FLOAT = GL_FLOAT,
421
422 DOUBLE = GL_DOUBLE,
426
427 INT = GL_INT,
431
432 UNSIGNED_INT = GL_UNSIGNED_INT,
436
441
444
454
464
483
495
507
519
531
543
545 };
546
547 public:
548
550 Uniform( Type type, const std::string& name, int numElements=1 );
551
553 Uniform(const Uniform& rhs, const CopyOp& copyop=CopyOp::SHALLOW_COPY);
554
556
559 virtual Uniform* asUniform() { return this; }
560
563 virtual const Uniform* asUniform() const { return this; }
564
565
567 bool setType( Type t );
568
570 Type getType() const { return _type; }
571
573 virtual void setName( const std::string& name );
574
576 void setNumElements( unsigned int numElements );
577
579 unsigned int getNumElements() const { return _numElements; }
580
583 unsigned int getInternalArrayNumElements() const;
584
586 static const char* getTypename( Type t );
587
589 static int getTypeNumComponents( Type t );
590
592 static Uniform::Type getTypeId( const std::string& tname );
593
595 static Type getGlApiType( Type t );
596
598 static GLenum getInternalArrayType( Type t );
599
601 static unsigned int getNameID(const std::string& name);
602
604 explicit Uniform( const char* name, float f );
605 explicit Uniform( const char* name, double d );
606 explicit Uniform( const char* name, int i );
607 explicit Uniform( const char* name, unsigned int ui );
608 explicit Uniform( const char* name, bool b );
609 explicit Uniform( const char* name, unsigned long long ull);
610 explicit Uniform( const char* name, long long ll );
611 Uniform( const char* name, const osg::Vec2& v2 );
612 Uniform( const char* name, const osg::Vec3& v3 );
613 Uniform( const char* name, const osg::Vec4& v4 );
614 Uniform( const char* name, const osg::Vec2d& v2 );
615 Uniform( const char* name, const osg::Vec3d& v3 );
616 Uniform( const char* name, const osg::Vec4d& v4 );
617 Uniform( const char* name, const osg::Matrix2& m2 );
618 Uniform( const char* name, const osg::Matrix3& m3 );
619 Uniform( const char* name, const osg::Matrixf& m4 );
620 Uniform( const char* name, const osg::Matrix2x3& m2x3 );
621 Uniform( const char* name, const osg::Matrix2x4& m2x4 );
622 Uniform( const char* name, const osg::Matrix3x2& m3x2 );
623 Uniform( const char* name, const osg::Matrix3x4& m3x4 );
624 Uniform( const char* name, const osg::Matrix4x2& m4x2 );
625 Uniform( const char* name, const osg::Matrix4x3& m4x3 );
626 Uniform( const char* name, const osg::Matrix2d& m2 );
627 Uniform( const char* name, const osg::Matrix3d& m3 );
628 Uniform( const char* name, const osg::Matrixd& m4 );
629 Uniform( const char* name, const osg::Matrix2x3d& m2x3 );
630 Uniform( const char* name, const osg::Matrix2x4d& m2x4 );
631 Uniform( const char* name, const osg::Matrix3x2d& m3x2 );
632 Uniform( const char* name, const osg::Matrix3x4d& m3x4 );
633 Uniform( const char* name, const osg::Matrix4x2d& m4x2 );
634 Uniform( const char* name, const osg::Matrix4x3d& m4x3 );
635 Uniform( const char* name, int i0, int i1 );
636 Uniform( const char* name, int i0, int i1, int i2 );
637 Uniform( const char* name, int i0, int i1, int i2, int i3 );
638 Uniform( const char* name, unsigned int ui0, unsigned int ui1 );
639 Uniform( const char* name, unsigned int ui0, unsigned int ui1, unsigned int ui2 );
640 Uniform( const char* name, unsigned int ui0, unsigned int ui1, unsigned int ui2, unsigned int ui3 );
641 Uniform( const char* name, bool b0, bool b1 );
642 Uniform( const char* name, bool b0, bool b1, bool b2 );
643 Uniform( const char* name, bool b0, bool b1, bool b2, bool b3 );
644
646 virtual int compare(const Uniform& rhs) const;
647 virtual int compareData(const Uniform& rhs) const;
648
649 bool operator < (const Uniform& rhs) const { return compare(rhs)<0; }
650 bool operator == (const Uniform& rhs) const { return compare(rhs)==0; }
651 bool operator != (const Uniform& rhs) const { return compare(rhs)!=0; }
652
653 void copyData( const Uniform& rhs );
654
655
657 typedef std::vector<StateSet*> ParentList;
658
660 inline const ParentList& getParents() const { return _parents; }
661
664 inline ParentList getParents() { return _parents; }
665
666 inline StateSet* getParent(unsigned int i) { return _parents[i]; }
672 inline const StateSet* getParent(unsigned int i) const { return _parents[i]; }
673
678 inline unsigned int getNumParents() const { return static_cast<unsigned int>(_parents.size()); }
679
680
682 bool set( float f );
683 bool set( double d );
684 bool set( int i );
685 bool set( unsigned int ui );
686 bool set( bool b );
687 bool set( unsigned long long ull );
688 bool set( long long ll );
689 bool set( const osg::Vec2& v2 );
690 bool set( const osg::Vec3& v3 );
691 bool set( const osg::Vec4& v4 );
692 bool set( const osg::Vec2d& v2 );
693 bool set( const osg::Vec3d& v3 );
694 bool set( const osg::Vec4d& v4 );
695 bool set( const osg::Matrix2& m2 );
696 bool set( const osg::Matrix3& m3 );
697 bool set( const osg::Matrixf& m4 );
698 bool set( const osg::Matrix2x3& m2x3 );
699 bool set( const osg::Matrix2x4& m2x4 );
700 bool set( const osg::Matrix3x2& m3x2 );
701 bool set( const osg::Matrix3x4& m3x4 );
702 bool set( const osg::Matrix4x2& m4x2 );
703 bool set( const osg::Matrix4x3& m4x3 );
704 bool set( const osg::Matrix2d& m2 );
705 bool set( const osg::Matrix3d& m3 );
706 bool set( const osg::Matrixd& m4 );
707 bool set( const osg::Matrix2x3d& m2x3 );
708 bool set( const osg::Matrix2x4d& m2x4 );
709 bool set( const osg::Matrix3x2d& m3x2 );
710 bool set( const osg::Matrix3x4d& m3x4 );
711 bool set( const osg::Matrix4x2d& m4x2 );
712 bool set( const osg::Matrix4x3d& m4x3 );
713 bool set( int i0, int i1 );
714 bool set( int i0, int i1, int i2 );
715 bool set( int i0, int i1, int i2, int i3 );
716 bool set( unsigned int ui0, unsigned int ui1 );
717 bool set( unsigned int ui0, unsigned int ui1, unsigned int ui2 );
718 bool set( unsigned int ui0, unsigned int ui1, unsigned int ui2, unsigned int ui3 );
719 bool set( bool b0, bool b1 );
720 bool set( bool b0, bool b1, bool b2 );
721 bool set( bool b0, bool b1, bool b2, bool b3 );
722
724 bool get( float& f ) const;
725 bool get( double& d ) const;
726 bool get( int& i ) const;
727 bool get( unsigned int& ui ) const;
728 bool get( bool& b ) const;
729 bool get( unsigned long long & ull ) const;
730 bool get( long long& ll ) const;
731 bool get( osg::Vec2& v2 ) const;
732 bool get( osg::Vec3& v3 ) const;
733 bool get( osg::Vec4& v4 ) const;
734 bool get( osg::Vec2d& v2 ) const;
735 bool get( osg::Vec3d& v3 ) const;
736 bool get( osg::Vec4d& v4 ) const;
737 bool get( osg::Matrix2& m2 ) const;
738 bool get( osg::Matrix3& m3 ) const;
739 bool get( osg::Matrixf& m4 ) const;
740 bool get( osg::Matrix2x3& m2x3 ) const;
741 bool get( osg::Matrix2x4& m2x4 ) const;
742 bool get( osg::Matrix3x2& m3x2 ) const;
743 bool get( osg::Matrix3x4& m3x4 ) const;
744 bool get( osg::Matrix4x2& m4x2 ) const;
745 bool get( osg::Matrix4x3& m4x3 ) const;
746 bool get( osg::Matrix2d& m2 ) const;
747 bool get( osg::Matrix3d& m3 ) const;
748 bool get( osg::Matrixd& m4 ) const;
749 bool get( osg::Matrix2x3d& m2x3 ) const;
750 bool get( osg::Matrix2x4d& m2x4 ) const;
751 bool get( osg::Matrix3x2d& m3x2 ) const;
752 bool get( osg::Matrix3x4d& m3x4 ) const;
753 bool get( osg::Matrix4x2d& m4x2 ) const;
754 bool get( osg::Matrix4x3d& m4x3 ) const;
755 bool get( int& i0, int& i1 ) const;
756 bool get( int& i0, int& i1, int& i2 ) const;
757 bool get( int& i0, int& i1, int& i2, int& i3 ) const;
758 bool get( unsigned int& ui0, unsigned int& ui1 ) const;
759 bool get( unsigned int& ui0, unsigned int& ui1, unsigned int& ui2 ) const;
760 bool get( unsigned int& ui0, unsigned int& ui1, unsigned int& ui2, unsigned int& ui3 ) const;
761 bool get( bool& b0, bool& b1 ) const;
762 bool get( bool& b0, bool& b1, bool& b2 ) const;
763 bool get( bool& b0, bool& b1, bool& b2, bool& b3 ) const;
764
766 bool setElement( unsigned int index, float f );
767 bool setElement( unsigned int index, double d );
768 bool setElement( unsigned int index, int i );
769 bool setElement( unsigned int index, unsigned int ui );
770 bool setElement( unsigned int index, bool b );
771 bool setElement( unsigned int index, unsigned long long ull );
772 bool setElement( unsigned int index, long long ll );
773 bool setElement( unsigned int index, const osg::Vec2& v2 );
774 bool setElement( unsigned int index, const osg::Vec3& v3 );
775 bool setElement( unsigned int index, const osg::Vec4& v4 );
776 bool setElement( unsigned int index, const osg::Vec2d& v2 );
777 bool setElement( unsigned int index, const osg::Vec3d& v3 );
778 bool setElement( unsigned int index, const osg::Vec4d& v4 );
779 bool setElement( unsigned int index, const osg::Matrix2& m2 );
780 bool setElement( unsigned int index, const osg::Matrix3& m3 );
781 bool setElement( unsigned int index, const osg::Matrixf& m4 );
782 bool setElement( unsigned int index, const osg::Matrix2x3& m2x3 );
783 bool setElement( unsigned int index, const osg::Matrix2x4& m2x4 );
784 bool setElement( unsigned int index, const osg::Matrix3x2& m3x2 );
785 bool setElement( unsigned int index, const osg::Matrix3x4& m3x4 );
786 bool setElement( unsigned int index, const osg::Matrix4x2& m4x2 );
787 bool setElement( unsigned int index, const osg::Matrix4x3& m4x3 );
788 bool setElement( unsigned int index, const osg::Matrix2d& m2 );
789 bool setElement( unsigned int index, const osg::Matrix3d& m3 );
790 bool setElement( unsigned int index, const osg::Matrixd& m4 );
791 bool setElement( unsigned int index, const osg::Matrix2x3d& m2x3 );
792 bool setElement( unsigned int index, const osg::Matrix2x4d& m2x4 );
793 bool setElement( unsigned int index, const osg::Matrix3x2d& m3x2 );
794 bool setElement( unsigned int index, const osg::Matrix3x4d& m3x4 );
795 bool setElement( unsigned int index, const osg::Matrix4x2d& m4x2 );
796 bool setElement( unsigned int index, const osg::Matrix4x3d& m4x3 );
797 bool setElement( unsigned int index, int i0, int i1 );
798 bool setElement( unsigned int index, int i0, int i1, int i2 );
799 bool setElement( unsigned int index, int i0, int i1, int i2, int i3 );
800 bool setElement( unsigned int index, unsigned int ui0, unsigned int ui1 );
801 bool setElement( unsigned int index, unsigned int ui0, unsigned int ui1, unsigned int ui2 );
802 bool setElement( unsigned int index, unsigned int ui0, unsigned int ui1, unsigned int ui2, unsigned int ui3 );
803 bool setElement( unsigned int index, bool b0, bool b1 );
804 bool setElement( unsigned int index, bool b0, bool b1, bool b2 );
805 bool setElement( unsigned int index, bool b0, bool b1, bool b2, bool b3 );
806
808 bool getElement( unsigned int index, float& f ) const;
809 bool getElement( unsigned int index, double& d ) const;
810 bool getElement( unsigned int index, int& i ) const;
811 bool getElement( unsigned int index, unsigned int& ui ) const;
812 bool getElement( unsigned int index, bool& b ) const;
813 bool getElement( unsigned int index, unsigned long long & ull ) const;
814 bool getElement( unsigned int index, long long& ll ) const;
815 bool getElement( unsigned int index, osg::Vec2& v2 ) const;
816 bool getElement( unsigned int index, osg::Vec3& v3 ) const;
817 bool getElement( unsigned int index, osg::Vec4& v4 ) const;
818 bool getElement( unsigned int index, osg::Vec2d& v2 ) const;
819 bool getElement( unsigned int index, osg::Vec3d& v3 ) const;
820 bool getElement( unsigned int index, osg::Vec4d& v4 ) const;
821 bool getElement( unsigned int index, osg::Matrix2& m2 ) const;
822 bool getElement( unsigned int index, osg::Matrix3& m3 ) const;
823 bool getElement( unsigned int index, osg::Matrixf& m4 ) const;
824 bool getElement( unsigned int index, osg::Matrix2x3& m2x3 ) const;
825 bool getElement( unsigned int index, osg::Matrix2x4& m2x4 ) const;
826 bool getElement( unsigned int index, osg::Matrix3x2& m3x2 ) const;
827 bool getElement( unsigned int index, osg::Matrix3x4& m3x4 ) const;
828 bool getElement( unsigned int index, osg::Matrix4x2& m4x2 ) const;
829 bool getElement( unsigned int index, osg::Matrix4x3& m4x3 ) const;
830 bool getElement( unsigned int index, osg::Matrix2d& m2 ) const;
831 bool getElement( unsigned int index, osg::Matrix3d& m3 ) const;
832 bool getElement( unsigned int index, osg::Matrixd& m4 ) const;
833 bool getElement( unsigned int index, osg::Matrix2x3d& m2x3 ) const;
834 bool getElement( unsigned int index, osg::Matrix2x4d& m2x4 ) const;
835 bool getElement( unsigned int index, osg::Matrix3x2d& m3x2 ) const;
836 bool getElement( unsigned int index, osg::Matrix3x4d& m3x4 ) const;
837 bool getElement( unsigned int index, osg::Matrix4x2d& m4x2 ) const;
838 bool getElement( unsigned int index, osg::Matrix4x3d& m4x3 ) const;
839 bool getElement( unsigned int index, int& i0, int& i1 ) const;
840 bool getElement( unsigned int index, int& i0, int& i1, int& i2 ) const;
841 bool getElement( unsigned int index, int& i0, int& i1, int& i2, int& i3 ) const;
842 bool getElement( unsigned int index, unsigned int& ui0, unsigned int& ui1 ) const;
843 bool getElement( unsigned int index, unsigned int& ui0, unsigned int& ui1, unsigned int& ui2 ) const;
844 bool getElement( unsigned int index, unsigned int& ui0, unsigned int& ui1, unsigned int& ui2, unsigned int& ui3 ) const;
845 bool getElement( unsigned int index, bool& b0, bool& b1 ) const;
846 bool getElement( unsigned int index, bool& b0, bool& b1, bool& b2 ) const;
847 bool getElement( unsigned int index, bool& b0, bool& b1, bool& b2, bool& b3 ) const;
848
849
852
853
856
859
861 const UniformCallback* getUpdateCallback() const { return _updateCallback.get(); }
862
865
868
870 const UniformCallback* getEventCallback() const { return _eventCallback.get(); }
871
875 inline void dirty() { ++_modifiedCount; }
876
878 bool setArray( FloatArray* array );
879 bool setArray( DoubleArray* array );
880 bool setArray( IntArray* array );
881 bool setArray( UIntArray* array );
882 bool setArray( UInt64Array* array );
883 bool setArray( Int64Array* array );
886 const FloatArray* getFloatArray() const { return _floatArray.get(); }
887
890 const DoubleArray* getDoubleArray() const { return _doubleArray.get(); }
891
893 IntArray* getIntArray() { return _intArray.get(); }
894 const IntArray* getIntArray() const { return _intArray.get(); }
895
897 UIntArray* getUIntArray() { return _uintArray.get(); }
898 const UIntArray* getUIntArray() const { return _uintArray.get(); }
899
902 const UInt64Array* getUInt64Array() const { return _uint64Array.get(); }
903
906 const Int64Array* getInt64Array() const { return _int64Array.get(); }
907
908 inline void setModifiedCount(unsigned int mc) { _modifiedCount = mc; }
909 inline unsigned int getModifiedCount() const { return _modifiedCount; }
910
912 unsigned int getNameID() const;
913
914 void apply(const GLExtensions* ext, GLint location) const;
915
916
917 protected:
918
919 virtual ~Uniform();
920 Uniform& operator=(const Uniform&) { return *this; }
921
922 bool isCompatibleType( Type t ) const;
923 // for backward compatibility only
924 // see getElement(index, osg::Matrixd &)
925 // see setElement(index, osg::Matrixd &)
926 bool isCompatibleType( Type t1, Type t2 ) const;
927 bool isScalar() const { return _numElements==1; }
929
932
934 friend class osg::StateSet;
935
937 unsigned int _numElements;
938 unsigned int _nameID;
939
940
941 // The internal data for osg::Uniforms are stored as an array of
942 // getInternalArrayType() of length getInternalArrayNumElements().
949
952
953 unsigned int _modifiedCount;
954};
955
956}
957
958#endif
#define GL_DOUBLE_MAT2x3
Definition GLDefines:339
#define GL_IMAGE_2D_RECT
Definition GLDefines:362
#define GL_INT_VEC3
Definition GLDefines:104
#define GL_FLOAT_MAT3x4
Definition GLDefines:160
#define GL_DOUBLE_MAT4x2
Definition GLDefines:343
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY
Definition GLDefines:380
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
Definition GLDefines:391
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY
Definition GLDefines:387
#define GL_BOOL_VEC3
Definition GLDefines:108
#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT
Definition GLDefines:41
#define GL_UNSIGNED_INT_IMAGE_CUBE
Definition GLDefines:385
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY
Definition GLDefines:436
#define GL_INT_IMAGE_2D_ARRAY
Definition GLDefines:377
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
Definition GLDefines:389
#define GL_SAMPLER_2D
Definition GLDefines:134
#define GL_INT_IMAGE_2D_MULTISAMPLE
Definition GLDefines:379
#define GL_BOOL_VEC4
Definition GLDefines:109
#define GL_INT_SAMPLER_2D_MULTISAMPLE
Definition GLDefines:350
#define GL_DOUBLE_VEC3
Definition GLDefines:334
#define GL_SAMPLER_CUBE_MAP_ARRAY
Definition GLDefines:434
#define GL_DOUBLE_MAT2x4
Definition GLDefines:340
#define GL_UNSIGNED_INT_IMAGE_BUFFER
Definition GLDefines:386
#define GL_UNSIGNED_INT_SAMPLER_3D_EXT
Definition GLDefines:276
#define GL_IMAGE_CUBE
Definition GLDefines:363
#define GL_IMAGE_1D_ARRAY
Definition GLDefines:365
#define GL_SAMPLER_1D
Definition GLDefines:139
#define GL_INT_VEC2
Definition GLDefines:103
#define GL_UNSIGNED_INT_VEC4_EXT
Definition GLDefines:265
#define GL_IMAGE_2D_ARRAY
Definition GLDefines:366
#define GL_FLOAT_MAT2x3
Definition GLDefines:157
#define GL_IMAGE_2D_MULTISAMPLE
Definition GLDefines:368
#define GL_DOUBLE_VEC4
Definition GLDefines:335
#define GL_UNSIGNED_INT_IMAGE_1D
Definition GLDefines:381
#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT
Definition GLDefines:278
#define GL_FLOAT_VEC3
Definition GLDefines:101
#define GL_IMAGE_BUFFER
Definition GLDefines:364
#define GL_UNSIGNED_INT_SAMPLER_2D_EXT
Definition GLDefines:275
#define GL_DOUBLE_MAT3x2
Definition GLDefines:341
#define GL_INT_SAMPLER_CUBE_EXT
Definition GLDefines:269
#define GL_IMAGE_3D
Definition GLDefines:361
#define GL_BOOL_VEC2
Definition GLDefines:107
#define GL_DOUBLE_VEC2
Definition GLDefines:333
#define GL_BOOL
Definition GLDefines:106
#define GL_SAMPLER_1D_SHADOW
Definition GLDefines:146
#define GL_UNSIGNED_INT_IMAGE_2D_RECT
Definition GLDefines:384
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT
Definition GLDefines:280
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
Definition GLDefines:351
#define GL_SAMPLER_BUFFER_EXT
Definition GLDefines:259
#define GL_DOUBLE_MAT3
Definition GLDefines:337
#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition GLDefines:352
#define GL_SAMPLER_2D_RECT_SHADOW
Definition GLDefines:396
#define GL_FLOAT_MAT3
Definition GLDefines:111
#define GL_SAMPLER_2D_RECT
Definition GLDefines:395
#define GL_INT_IMAGE_CUBE_MAP_ARRAY
Definition GLDefines:378
#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition GLDefines:353
#define GL_FLOAT_VEC4
Definition GLDefines:102
#define GL_INT_IMAGE_CUBE
Definition GLDefines:374
#define GL_INT_IMAGE_1D_ARRAY
Definition GLDefines:376
#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT
Definition GLDefines:281
#define GL_FLOAT_MAT4x2
Definition GLDefines:161
#define GL_UNSIGNED_INT_VEC3_EXT
Definition GLDefines:264
#define GL_INT_SAMPLER_1D_ARRAY_EXT
Definition GLDefines:271
#define GL_INT_SAMPLER_3D_EXT
Definition GLDefines:268
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE
Definition GLDefines:390
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition GLDefines:354
#define GL_INT_IMAGE_3D
Definition GLDefines:372
#define GL_INT_SAMPLER_2D_RECT_EXT
Definition GLDefines:270
#define GL_DOUBLE_MAT4x3
Definition GLDefines:344
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY
Definition GLDefines:437
#define GL_IMAGE_2D
Definition GLDefines:360
#define GL_INT64_ARB
Definition GLDefines:561
#define GL_UNSIGNED_INT_IMAGE_2D
Definition GLDefines:382
#define GL_INT_IMAGE_BUFFER
Definition GLDefines:375
#define GL_INT_SAMPLER_1D_EXT
Definition GLDefines:266
#define GL_SAMPLER_2D_MULTISAMPLE
Definition GLDefines:349
#define GL_INT_IMAGE_2D_RECT
Definition GLDefines:373
#define GL_FLOAT_MAT3x2
Definition GLDefines:159
#define GL_INT_SAMPLER_BUFFER_EXT
Definition GLDefines:273
#define GL_FLOAT_MAT2
Definition GLDefines:110
#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT
Definition GLDefines:277
#define GL_UNSIGNED_INT_VEC2_EXT
Definition GLDefines:263
#define GL_FLOAT_MAT2x4
Definition GLDefines:158
#define GL_INT_IMAGE_1D
Definition GLDefines:370
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY
Definition GLDefines:388
#define GL_SAMPLER_2D_ARRAY_EXT
Definition GLDefines:39
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW
Definition GLDefines:435
#define GL_UNSIGNED_INT_IMAGE_3D
Definition GLDefines:383
#define GL_DOUBLE_MAT3x4
Definition GLDefines:342
#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT
Definition GLDefines:40
#define GL_SAMPLER_3D
Definition GLDefines:142
#define GL_INT_SAMPLER_2D_ARRAY_EXT
Definition GLDefines:272
#define GL_DOUBLE_MAT4
Definition GLDefines:338
#define GL_SAMPLER_2D_SHADOW
Definition GLDefines:147
#define GL_FLOAT_VEC2
Definition GLDefines:100
#define GL_INT_IMAGE_2D
Definition GLDefines:371
#define GL_INT_VEC4
Definition GLDefines:105
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT
Definition GLDefines:279
#define GL_UNSIGNED_INT64_ARB
Definition GLDefines:562
#define GL_DOUBLE_MAT2
Definition GLDefines:336
#define GL_INT_SAMPLER_2D_EXT
Definition GLDefines:267
#define GL_SAMPLER_CUBE
Definition GLDefines:135
#define GL_SAMPLER_1D_ARRAY_EXT
Definition GLDefines:38
#define GL_FLOAT_MAT4
Definition GLDefines:112
#define GL_UNSIGNED_INT_SAMPLER_1D_EXT
Definition GLDefines:274
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY
Definition GLDefines:369
#define GL_SAMPLER_CUBE_SHADOW_EXT
Definition GLDefines:262
#define GL_FLOAT_MAT4x3
Definition GLDefines:162
#define GL_IMAGE_1D
Definition GLDefines:359
#define GL_IMAGE_CUBE_MAP_ARRAY
Definition GLDefines:367
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
TemplateIndexArray< GLuint, Array::UIntArrayType, 1, GL_UNSIGNED_INT > UIntArray
Definition Array:419
Matrix3x2Template< float > Matrix3x2
Definition Uniform:389
Matrix2Template< float > Matrix2
Definition Uniform:385
Matrix2x4Template< double > Matrix2x4d
Definition Uniform:399
Vec2f Vec2
Definition Vec2:21
Matrix2Template< double > Matrix2d
Definition Uniform:397
Matrix3Template< double > Matrix3d
Definition Uniform:402
Vec3f Vec3
Definition Vec3:21
TemplateArray< GLfloat, Array::FloatArrayType, 1, GL_FLOAT > FloatArray
Definition Array:421
Matrix2x4Template< float > Matrix2x4
Definition Uniform:387
Matrix4x3Template< double > Matrix4x3d
Definition Uniform:406
Matrix2x3Template< float > Matrix2x3
Definition Uniform:386
TemplateArray< GLdouble, Array::DoubleArrayType, 1, GL_DOUBLE > DoubleArray
Definition Array:422
Matrix3x2Template< double > Matrix3x2d
Definition Uniform:401
Matrix4x3Template< float > Matrix4x3
Definition Uniform:394
Matrix3x4Template< float > Matrix3x4
Definition Uniform:391
Matrix2x3Template< double > Matrix2x3d
Definition Uniform:398
Matrix4x2Template< double > Matrix4x2d
Definition Uniform:405
Vec4f Vec4
Definition Vec4:21
Matrix3Template< float > Matrix3
Definition Uniform:390
TemplateIndexArray< GLuint64, Array::UInt64ArrayType, 1, GL_UNSIGNED_INT64_ARB > UInt64Array
Definition Array:461
Matrix3x4Template< double > Matrix3x4d
Definition Uniform:403
Matrix4x2Template< float > Matrix4x2
Definition Uniform:393
TemplateIndexArray< GLint64, Array::Int64ArrayType, 1, GL_INT64_ARB > Int64Array
Definition Array:462
TemplateIndexArray< GLint, Array::IntArrayType, 1, GL_INT > IntArray
Definition Array:415
Deprecated.
Definition Callback:271
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Main GLExtensions class for managing OpenGL extensions per graphics context.
Definition GLExtensions:160
Definition Matrixd:27
Definition Matrixf:27
Object()
Construct an object.
Definition Object:69
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Stores a set of modes and attributes which represent a set of OpenGL state.
Definition StateSet:46
value_type * ptr()
Definition Uniform:105
const value_type * ptr() const
Definition Uniform:106
value_type & operator[](int i)
Definition Uniform:108
@ value_count
Definition Uniform:78
@ col_count
Definition Uniform:76
~MatrixTemplate()
Definition Uniform:85
T value_type
Definition Uniform:80
MatrixTemplate()
Definition Uniform:84
value_type operator()(int row, int col) const
Definition Uniform:88
MatrixTemplate & operator=(const MatrixTemplate &rhs)
Definition Uniform:90
void reset()
Definition Uniform:111
@ row_count
Definition Uniform:77
void set(const MatrixTemplate &rhs)
Definition Uniform:97
value_type _mat[row_count][col_count]
Definition Uniform:114
value_type & operator()(int row, int col)
Definition Uniform:87
void set(value_type const *const ptr)
Definition Uniform:99
Definition Uniform:119
~Matrix2Template()
Definition Uniform:134
Matrix2Template()
Definition Uniform:126
MatrixTemplate< T, 2, 2 > base_class
Definition Uniform:121
void makeIdentity()
Definition Uniform:145
base_class::value_type value_type
Definition Uniform:122
void set(value_type a00, value_type a01, value_type a10, value_type a11)
Definition Uniform:138
Matrix2Template(value_type a00, value_type a01, value_type a10, value_type a11)
Definition Uniform:128
Matrix2Template(const Matrix2Template &mat)
Definition Uniform:127
Definition Uniform:154
Matrix2x3Template(value_type a00, value_type a01, value_type a02, value_type a10, value_type a11, value_type a12)
Definition Uniform:163
Matrix2x3Template(const Matrix2x3Template &mat)
Definition Uniform:162
~Matrix2x3Template()
Definition Uniform:169
base_class::value_type value_type
Definition Uniform:157
Matrix2x3Template()
Definition Uniform:161
MatrixTemplate< T, 2, 3 > base_class
Definition Uniform:156
void set(value_type a00, value_type a01, value_type a02, value_type a10, value_type a11, value_type a12)
Definition Uniform:173
Definition Uniform:183
base_class::value_type value_type
Definition Uniform:186
Matrix2x4Template(const Matrix2x4Template &mat)
Definition Uniform:191
Matrix2x4Template(value_type a00, value_type a01, value_type a02, value_type a03, value_type a10, value_type a11, value_type a12, value_type a13)
Definition Uniform:192
~Matrix2x4Template()
Definition Uniform:198
void set(value_type a00, value_type a01, value_type a02, value_type a03, value_type a10, value_type a11, value_type a12, value_type a13)
Definition Uniform:202
MatrixTemplate< T, 2, 4 > base_class
Definition Uniform:185
Matrix2x4Template()
Definition Uniform:190
Definition Uniform:212
Matrix3x2Template(value_type a00, value_type a01, value_type a10, value_type a11, value_type a20, value_type a21)
Definition Uniform:220
Matrix3x2Template(const Matrix3x2Template &mat)
Definition Uniform:219
void set(value_type a00, value_type a01, value_type a10, value_type a11, value_type a20, value_type a21)
Definition Uniform:232
MatrixTemplate< T, 3, 2 > base_class
Definition Uniform:214
~Matrix3x2Template()
Definition Uniform:228
Matrix3x2Template()
Definition Uniform:218
base_class::value_type value_type
Definition Uniform:215
Definition Uniform:244
base_class::value_type value_type
Definition Uniform:247
Matrix3Template()
Definition Uniform:250
void makeIdentity()
Definition Uniform:273
void set(value_type a00, value_type a01, value_type a02, value_type a10, value_type a11, value_type a12, value_type a20, value_type a21, value_type a22)
Definition Uniform:264
~Matrix3Template()
Definition Uniform:260
MatrixTemplate< T, 3, 3 > base_class
Definition Uniform:246
Matrix3Template(const Matrix3Template &mat)
Definition Uniform:251
Matrix3Template(value_type a00, value_type a01, value_type a02, value_type a10, value_type a11, value_type a12, value_type a20, value_type a21, value_type a22)
Definition Uniform:252
Definition Uniform:283
Matrix3x4Template(const Matrix3x4Template &mat)
Definition Uniform:290
MatrixTemplate< T, 3, 4 > base_class
Definition Uniform:285
void set(value_type a00, value_type a01, value_type a02, value_type a03, value_type a10, value_type a11, value_type a12, value_type a13, value_type a20, value_type a21, value_type a22, value_type a23)
Definition Uniform:303
~Matrix3x4Template()
Definition Uniform:299
base_class::value_type value_type
Definition Uniform:286
Matrix3x4Template(value_type a00, value_type a01, value_type a02, value_type a03, value_type a10, value_type a11, value_type a12, value_type a13, value_type a20, value_type a21, value_type a22, value_type a23)
Definition Uniform:291
Matrix3x4Template()
Definition Uniform:289
Definition Uniform:315
Matrix4x2Template(const Matrix4x2Template &mat)
Definition Uniform:322
void set(value_type a00, value_type a01, value_type a10, value_type a11, value_type a20, value_type a21, value_type a30, value_type a31)
Definition Uniform:337
MatrixTemplate< T, 4, 2 > base_class
Definition Uniform:317
Matrix4x2Template()
Definition Uniform:321
Matrix4x2Template(value_type a00, value_type a01, value_type a10, value_type a11, value_type a20, value_type a21, value_type a30, value_type a31)
Definition Uniform:323
~Matrix4x2Template()
Definition Uniform:333
base_class::value_type value_type
Definition Uniform:318
Definition Uniform:351
MatrixTemplate< T, 4, 3 > base_class
Definition Uniform:353
base_class::value_type value_type
Definition Uniform:354
void set(value_type a00, value_type a01, value_type a02, value_type a10, value_type a11, value_type a12, value_type a20, value_type a21, value_type a22, value_type a30, value_type a31, value_type a32)
Definition Uniform:373
Matrix4x3Template(const Matrix4x3Template &mat)
Definition Uniform:358
~Matrix4x3Template()
Definition Uniform:369
Matrix4x3Template(value_type a00, value_type a01, value_type a02, value_type a10, value_type a11, value_type a12, value_type a20, value_type a21, value_type a22, value_type a30, value_type a31, value_type a32)
Definition Uniform:359
Matrix4x3Template()
Definition Uniform:357
Uniform(const char *name, int i)
bool setElement(unsigned int index, unsigned int ui0, unsigned int ui1, unsigned int ui2, unsigned int ui3)
bool setElement(unsigned int index, const osg::Vec2d &v2)
Uniform(const char *name, const osg::Matrix4x2d &m4x2)
bool setArray(DoubleArray *array)
const UniformCallback * getEventCallback() const
Get the const EventCallback.
Definition Uniform:870
Type _type
Definition Uniform:936
Uniform(const char *name, unsigned long long ull)
Uniform(const char *name, const osg::Vec4d &v4)
bool set(unsigned int ui0, unsigned int ui1, unsigned int ui2)
UniformCallback * getEventCallback()
Get the non const EventCallback.
Definition Uniform:867
bool set(const osg::Vec3d &v3)
IntArray * getIntArray()
Get the internal data array for an int osg::Uniform.
Definition Uniform:893
bool getElement(unsigned int index, osg::Matrix4x2 &m4x2) const
void setNumElements(unsigned int numElements)
Set the length of a uniform, ensuring it is only set once (1==scalar)
Uniform(const char *name, bool b)
virtual void setName(const std::string &name)
Set the name of the glUniform, ensuring it is only set once.
Uniform(const char *name, const osg::Matrixf &m4)
bool set(const osg::Vec3 &v3)
bool getElement(unsigned int index, osg::Matrix2x4d &m2x4) const
std::vector< StateSet * > ParentList
A vector of osg::StateSet pointers which is used to store the parent(s) of this Uniform,...
Definition Uniform:657
ref_ptr< UniformCallback > _updateCallback
Definition Uniform:950
bool set(const osg::Matrix4x2d &m4x2)
void setModifiedCount(unsigned int mc)
Definition Uniform:908
bool getElement(unsigned int index, osg::Vec3d &v3) const
bool isCompatibleType(Type t1, Type t2) const
bool get(unsigned int &ui0, unsigned int &ui1) const
ref_ptr< UIntArray > _uintArray
Definition Uniform:946
Uniform(const char *name, const osg::Vec3 &v3)
ref_ptr< Int64Array > _int64Array
Definition Uniform:947
bool set(bool b0, bool b1, bool b2, bool b3)
const DoubleArray * getDoubleArray() const
Definition Uniform:890
static unsigned int getNameID(const std::string &name)
Return the number that the name maps to uniquely.
bool getElement(unsigned int index, osg::Vec2d &v2) const
bool set(const osg::Matrix4x3 &m4x3)
bool get(osg::Matrix4x3d &m4x3) const
void dirty()
Increment the modified count on the Uniform so Programs watching it know it update themselves.
Definition Uniform:875
bool getElement(unsigned int index, osg::Matrix2x3d &m2x3) const
bool set(const osg::Vec2 &v2)
bool set(const osg::Matrix2d &m2)
void setEventCallback(UniformCallback *ec)
Set the EventCallback which allows users to attach customize the updating of an object during the Eve...
bool setElement(unsigned int index, const osg::Matrix2x3d &m2x3)
bool setElement(unsigned int index, int i0, int i1, int i2, int i3)
bool get(osg::Matrix2x4d &m2x4) const
bool get(osg::Matrix4x2d &m4x2) const
static int getTypeNumComponents(Type t)
Return the number of components for a GLSL type.
UIntArray * getUIntArray()
Get the internal data array for an unsigned int osg::Uniform.
Definition Uniform:897
bool getElement(unsigned int index, osg::Matrixd &m4) const
bool get(osg::Matrix3 &m3) const
bool set(unsigned long long ull)
virtual Uniform * asUniform()
Convert 'this' into a Uniform pointer if Object is a Uniform, otherwise return 0.
Definition Uniform:559
bool get(osg::Matrix4x2 &m4x2) const
bool getElement(unsigned int index, osg::Matrix3d &m3) const
Uniform(const char *name, const osg::Matrix2x4d &m2x4)
bool get(osg::Matrix3d &m3) const
bool set(int i0, int i1, int i2)
bool setElement(unsigned int index, const osg::Matrix2x3 &m2x3)
void allocateDataArray()
Type getType() const
Get the type of glUniform as enum.
Definition Uniform:570
ref_ptr< IntArray > _intArray
Definition Uniform:945
Uniform(const char *name, unsigned int ui0, unsigned int ui1)
bool set(const osg::Matrix4x3d &m4x3)
META_Object(osg, Uniform)
bool getElement(unsigned int index, osg::Matrix3x2d &m3x2) const
bool get(osg::Matrixd &m4) const
bool setElement(unsigned int index, const osg::Matrix3x4d &m3x4)
bool setElement(unsigned int index, int i)
bool set(const osg::Matrixd &m4)
bool getElement(unsigned int index, osg::Vec4 &v4) const
bool get(osg::Vec3 &v3) const
bool get(int &i0, int &i1, int &i2) const
Uniform(const char *name, const osg::Matrix4x3d &m4x3)
UniformCallback * getUpdateCallback()
Get the non const UpdateCallback.
Definition Uniform:858
Uniform(const char *name, const osg::Matrix3x2d &m3x2)
bool getElement(unsigned int index, unsigned int &ui0, unsigned int &ui1, unsigned int &ui2) const
bool setElement(unsigned int index, unsigned long long ull)
bool get(osg::Matrix3x4 &m3x4) const
bool get(osg::Matrix4x3 &m4x3) const
bool set(const osg::Matrix3 &m3)
bool get(osg::Matrix2 &m2) const
bool get(osg::Vec2 &v2) const
Uniform(const char *name, const osg::Matrix2 &m2)
bool setElement(unsigned int index, unsigned int ui0, unsigned int ui1)
bool get(bool &b0, bool &b1, bool &b2, bool &b3) const
Type
Definition Uniform:416
@ UNSIGNED_INT_IMAGE_2D_MULTISAMPLE
Definition Uniform:541
@ UNSIGNED_INT_IMAGE_BUFFER
Definition Uniform:537
@ FLOAT_MAT3x2
Definition Uniform:450
@ FLOAT_MAT4x2
Definition Uniform:452
@ SAMPLER_3D
Definition Uniform:467
@ SAMPLER_2D_RECT_SHADOW
Definition Uniform:482
@ UNSIGNED_INT_VEC3
Definition Uniform:434
@ UNSIGNED_INT_IMAGE_1D_ARRAY
Definition Uniform:538
@ DOUBLE_MAT4
Definition Uniform:457
@ INT_IMAGE_2D_ARRAY
Definition Uniform:527
@ SAMPLER_1D_ARRAY
Definition Uniform:471
@ INT_SAMPLER_CUBE
Definition Uniform:487
@ INT_VEC2
Definition Uniform:428
@ INT_IMAGE_2D_MULTISAMPLE
Definition Uniform:529
@ SAMPLER_2D_RECT
Definition Uniform:481
@ DOUBLE_MAT2x3
Definition Uniform:458
@ UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY
Definition Uniform:502
@ IMAGE_CUBE
Definition Uniform:512
@ IMAGE_2D_RECT
Definition Uniform:511
@ INT_IMAGE_2D
Definition Uniform:521
@ DOUBLE_MAT3x4
Definition Uniform:461
@ INT_SAMPLER_2D_ARRAY
Definition Uniform:489
@ IMAGE_1D
Definition Uniform:508
@ UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
Definition Uniform:542
@ DOUBLE_VEC3
Definition Uniform:424
@ INT_VEC4
Definition Uniform:430
@ SAMPLER_2D
Definition Uniform:466
@ SAMPLER_2D_MULTISAMPLE_ARRAY
Definition Uniform:477
@ UNSIGNED_INT_SAMPLER_BUFFER
Definition Uniform:505
@ INT_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition Uniform:492
@ IMAGE_2D_MULTISAMPLE
Definition Uniform:517
@ INT_IMAGE_2D_RECT
Definition Uniform:523
@ FLOAT_MAT4
Definition Uniform:447
@ UNDEFINED
Definition Uniform:544
@ UNSIGNED_INT_SAMPLER_CUBE
Definition Uniform:499
@ UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
Definition Uniform:503
@ INT_SAMPLER_2D_RECT
Definition Uniform:494
@ UNSIGNED_INT_IMAGE_2D
Definition Uniform:533
@ UNSIGNED_INT_SAMPLER_2D_ARRAY
Definition Uniform:501
@ FLOAT_MAT3
Definition Uniform:446
@ INT_IMAGE_3D
Definition Uniform:522
@ SAMPLER_1D_ARRAY_SHADOW
Definition Uniform:474
@ INT64
Definition Uniform:442
@ DOUBLE_MAT2
Definition Uniform:455
@ UNSIGNED_INT64
Definition Uniform:443
@ UNSIGNED_INT_SAMPLER_1D_ARRAY
Definition Uniform:500
@ IMAGE_2D_MULTISAMPLE_ARRAY
Definition Uniform:518
@ SAMPLER_1D
Definition Uniform:465
@ FLOAT_VEC2
Definition Uniform:418
@ INT_IMAGE_CUBE
Definition Uniform:524
@ UNSIGNED_INT
Definition Uniform:432
@ UNSIGNED_INT_VEC2
Definition Uniform:433
@ SAMPLER_BUFFER
Definition Uniform:480
@ INT_IMAGE_CUBE_MAP_ARRAY
Definition Uniform:528
@ IMAGE_2D
Definition Uniform:509
@ INT_SAMPLER_2D_MULTISAMPLE
Definition Uniform:491
@ FLOAT_MAT3x4
Definition Uniform:451
@ INT_SAMPLER_3D
Definition Uniform:486
@ UNSIGNED_INT_IMAGE_CUBE
Definition Uniform:536
@ IMAGE_2D_ARRAY
Definition Uniform:515
@ UNSIGNED_INT_IMAGE_3D
Definition Uniform:534
@ DOUBLE_MAT4x2
Definition Uniform:462
@ FLOAT_MAT2
Definition Uniform:445
@ SAMPLER_2D_ARRAY_SHADOW
Definition Uniform:475
@ UNSIGNED_INT_IMAGE_1D
Definition Uniform:532
@ IMAGE_1D_ARRAY
Definition Uniform:514
@ INT_SAMPLER_1D
Definition Uniform:484
@ SAMPLER_2D_MULTISAMPLE
Definition Uniform:476
@ SAMPLER_1D_SHADOW
Definition Uniform:469
@ BOOL_VEC4
Definition Uniform:440
@ INT_VEC3
Definition Uniform:429
@ INT_SAMPLER_BUFFER
Definition Uniform:493
@ FLOAT_VEC3
Definition Uniform:419
@ FLOAT
Definition Uniform:417
@ FLOAT_MAT4x3
Definition Uniform:453
@ UNSIGNED_INT_SAMPLER_3D
Definition Uniform:498
@ DOUBLE_MAT2x4
Definition Uniform:459
@ UNSIGNED_INT_SAMPLER_2D
Definition Uniform:497
@ IMAGE_3D
Definition Uniform:510
@ DOUBLE_VEC2
Definition Uniform:423
@ INT_IMAGE_2D_MULTISAMPLE_ARRAY
Definition Uniform:530
@ FLOAT_MAT2x4
Definition Uniform:449
@ INT_SAMPLER_CUBE_MAP_ARRAY
Definition Uniform:490
@ BOOL_VEC3
Definition Uniform:439
@ INT_IMAGE_BUFFER
Definition Uniform:525
@ SAMPLER_CUBE
Definition Uniform:468
@ SAMPLER_2D_ARRAY
Definition Uniform:472
@ SAMPLER_CUBE_SHADOW
Definition Uniform:478
@ SAMPLER_CUBE_MAP_ARRAY_SHADOW
Definition Uniform:479
@ INT
Definition Uniform:427
@ DOUBLE_VEC4
Definition Uniform:425
@ IMAGE_CUBE_MAP_ARRAY
Definition Uniform:516
@ SAMPLER_CUBE_MAP_ARRAY
Definition Uniform:473
@ INT_IMAGE_1D
Definition Uniform:520
@ IMAGE_BUFFER
Definition Uniform:513
@ DOUBLE_MAT4x3
Definition Uniform:463
@ BOOL
Definition Uniform:437
@ UNSIGNED_INT_SAMPLER_1D
Definition Uniform:496
@ INT_SAMPLER_2D
Definition Uniform:485
@ FLOAT_MAT2x3
Definition Uniform:448
@ DOUBLE
Definition Uniform:422
@ UNSIGNED_INT_SAMPLER_2D_RECT
Definition Uniform:506
@ INT_SAMPLER_1D_ARRAY
Definition Uniform:488
@ UNSIGNED_INT_IMAGE_2D_RECT
Definition Uniform:535
@ UNSIGNED_INT_IMAGE_2D_ARRAY
Definition Uniform:539
@ SAMPLER_2D_SHADOW
Definition Uniform:470
@ BOOL_VEC2
Definition Uniform:438
@ INT_IMAGE_1D_ARRAY
Definition Uniform:526
@ DOUBLE_MAT3
Definition Uniform:456
@ UNSIGNED_INT_VEC4
Definition Uniform:435
@ UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
Definition Uniform:504
@ DOUBLE_MAT3x2
Definition Uniform:460
@ FLOAT_VEC4
Definition Uniform:420
@ UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY
Definition Uniform:540
Uniform(const char *name, const osg::Matrix3x4d &m3x4)
bool setElement(unsigned int index, const osg::Matrix2d &m2)
bool get(int &i0, int &i1) const
unsigned int getNumParents() const
Get the number of parents of this Uniform.
Definition Uniform:678
ref_ptr< DoubleArray > _doubleArray
Definition Uniform:944
bool get(bool &b0, bool &b1, bool &b2) const
bool set(unsigned int ui)
Uniform(const char *name, unsigned int ui0, unsigned int ui1, unsigned int ui2)
Uniform(const char *name, bool b0, bool b1, bool b2, bool b3)
bool get(osg::Matrix2x3 &m2x3) const
bool set(bool b0, bool b1)
bool setElement(unsigned int index, const osg::Matrix4x3 &m4x3)
UInt64Array * getUInt64Array()
Get the internal data array for an unsigned int osg::Uniform.
Definition Uniform:901
Uniform(const char *name, const osg::Matrix2x4 &m2x4)
bool getElement(unsigned int index, osg::Matrix2x4 &m2x4) const
const Int64Array * getInt64Array() const
Definition Uniform:906
bool set(const osg::Matrix2x4 &m2x4)
bool getElement(unsigned int index, long long &ll) const
bool get(long long &ll) const
bool getElement(unsigned int index, int &i0, int &i1) const
bool set(bool b)
Uniform(const char *name, float f)
convenient scalar (non-array) constructors w/ assignment
bool set(const osg::Vec2d &v2)
bool getElement(unsigned int index, unsigned int &ui0, unsigned int &ui1, unsigned int &ui2, unsigned int &ui3) const
UniformCallback Callback
provide typedef for backwards compatibility to OSG-3.2 and other previous versions.
Definition Uniform:851
const UInt64Array * getUInt64Array() const
Definition Uniform:902
bool setElement(unsigned int index, const osg::Matrix3d &m3)
bool set(int i0, int i1, int i2, int i3)
Uniform(const char *name, unsigned int ui)
friend class osg::StateSet
Definition Uniform:934
bool setElement(unsigned int index, bool b0, bool b1, bool b2)
bool get(osg::Vec2d &v2) const
bool get(float &f) const
convenient scalar (non-array) value query
const ParentList & getParents() const
Get the parent list of this Uniform.
Definition Uniform:660
bool get(unsigned long long &ull) const
ref_ptr< UniformCallback > _eventCallback
Definition Uniform:951
Uniform & operator=(const Uniform &)
Definition Uniform:920
bool setElement(unsigned int index, const osg::Matrix2x4 &m2x4)
bool getElement(unsigned int index, osg::Matrix3x4d &m3x4) const
bool set(unsigned int ui0, unsigned int ui1, unsigned int ui2, unsigned int ui3)
bool set(unsigned int ui0, unsigned int ui1)
Uniform(const char *name, int i0, int i1, int i2)
bool setElement(unsigned int index, const osg::Matrix4x2 &m4x2)
Uniform(const char *name, const osg::Matrix3d &m3)
static Type getGlApiType(Type t)
Return the GL API type corresponding to a GLSL type.
bool setElement(unsigned int index, bool b0, bool b1, bool b2, bool b3)
const UniformCallback * getUpdateCallback() const
Get the const UpdateCallback.
Definition Uniform:861
bool set(float f)
convenient scalar (non-array) value assignment
virtual const Uniform * asUniform() const
convert 'const this' into a const Uniform pointer if Object is a Uniform, otherwise return 0.
Definition Uniform:563
bool set(const osg::Vec4d &v4)
bool getElement(unsigned int index, unsigned long long &ull) const
Uniform(const char *name, const osg::Matrix3x4 &m3x4)
bool setElement(unsigned int index, const osg::Matrix3x2 &m3x2)
StateSet * getParent(unsigned int i)
Definition Uniform:666
bool getElement(unsigned int index, osg::Matrix2x3 &m2x3) const
bool setElement(unsigned int index, unsigned int ui)
void apply(const GLExtensions *ext, GLint location) const
Uniform(const char *name, const osg::Matrix2d &m2)
Uniform(const char *name, int i0, int i1)
bool setElement(unsigned int index, const osg::Vec4 &v4)
void addParent(osg::StateSet *object)
void setUpdateCallback(UniformCallback *uc)
Set the UpdateCallback which allows users to attach customize the updating of an object during the up...
bool setElement(unsigned int index, const osg::Matrix4x3d &m4x3)
bool setElement(unsigned int index, const osg::Matrix4x2d &m4x2)
bool set(const osg::Matrix3x2 &m3x2)
bool getElement(unsigned int index, int &i0, int &i1, int &i2) const
bool getElement(unsigned int index, int &i) const
bool setElement(unsigned int index, const osg::Vec3d &v3)
bool setElement(unsigned int index, const osg::Vec4d &v4)
bool setElement(unsigned int index, int i0, int i1)
bool setElement(unsigned int index, float f)
value assignment for array uniforms
bool getElement(unsigned int index, unsigned int &ui) const
bool get(osg::Matrix2x3d &m2x3) const
bool set(const osg::Matrixf &m4)
bool getElement(unsigned int index, double &d) const
bool get(bool &b0, bool &b1) const
bool setArray(UIntArray *array)
const IntArray * getIntArray() const
Definition Uniform:894
bool getElement(unsigned int index, osg::Matrix2d &m2) const
bool set(const osg::Matrix2x3d &m2x3)
bool get(osg::Vec4d &v4) const
bool get(osg::Matrixf &m4) const
Uniform(const char *name, unsigned int ui0, unsigned int ui1, unsigned int ui2, unsigned int ui3)
Uniform(const char *name, const osg::Matrix4x2 &m4x2)
ParentList _parents
Definition Uniform:933
Int64Array * getInt64Array()
Get the internal data array for an unsigned int osg::Uniform.
Definition Uniform:905
bool setElement(unsigned int index, unsigned int ui0, unsigned int ui1, unsigned int ui2)
bool get(osg::Matrix3x4d &m3x4) const
unsigned int getNameID() const
Get the number that the Uniform's name maps to uniquely.
bool get(unsigned int &ui0, unsigned int &ui1, unsigned int &ui2) const
bool setElement(unsigned int index, const osg::Matrixf &m4)
bool set(const osg::Matrix2 &m2)
bool setElement(unsigned int index, const osg::Matrix3 &m3)
Uniform(const char *name, bool b0, bool b1)
Uniform(const char *name, const osg::Vec2d &v2)
bool setArray(IntArray *array)
Uniform(const char *name, const osg::Vec3d &v3)
bool getElement(unsigned int index, osg::Matrix3x4 &m3x4) const
unsigned int getModifiedCount() const
Definition Uniform:909
Uniform(Type type, const std::string &name, int numElements=1)
bool get(unsigned int &ui) const
bool setArray(Int64Array *array)
static const char * getTypename(Type t)
Return the name of a Type enum as string.
bool getElement(unsigned int index, bool &b) const
ref_ptr< FloatArray > _floatArray
Definition Uniform:943
void removeParent(osg::StateSet *object)
bool getElement(unsigned int index, bool &b0, bool &b1, bool &b2, bool &b3) const
static GLenum getInternalArrayType(Type t)
Return the internal data array type corresponding to a GLSL type.
bool setArray(UInt64Array *array)
bool set(const osg::Matrix3x2d &m3x2)
Uniform(const char *name, double d)
FloatArray * getFloatArray()
Get the internal data array for a float osg::Uniform.
Definition Uniform:885
Uniform(const char *name, const osg::Matrix3 &m3)
static Uniform::Type getTypeId(const std::string &tname)
Return the Type enum of a Uniform typename string.
unsigned int _numElements
Definition Uniform:937
bool getElement(unsigned int index, int &i0, int &i1, int &i2, int &i3) const
bool setElement(unsigned int index, const osg::Matrix3x4 &m3x4)
bool set(const osg::Matrix3x4 &m3x4)
const StateSet * getParent(unsigned int i) const
Get a single const parent of this Uniform.
Definition Uniform:672
DoubleArray * getDoubleArray()
Get the internal data array for a double osg::Uniform.
Definition Uniform:889
bool get(int &i) const
ParentList getParents()
Get the a copy of parent list of node.
Definition Uniform:664
bool set(const osg::Matrix2x4d &m2x4)
bool isScalar() const
Definition Uniform:927
bool get(int &i0, int &i1, int &i2, int &i3) const
bool getElement(unsigned int index, osg::Matrix4x3d &m4x3) const
virtual int compareData(const Uniform &rhs) const
bool set(const osg::Matrix2x3 &m2x3)
unsigned int _modifiedCount
Definition Uniform:953
bool set(const osg::Matrix4x2 &m4x2)
bool setElement(unsigned int index, const osg::Matrixd &m4)
unsigned int getInternalArrayNumElements() const
Get the number of elements required for the internal data array.
Uniform(const char *name, const osg::Vec4 &v4)
bool setElement(unsigned int index, const osg::Matrix2x4d &m2x4)
bool set(long long ll)
bool setElement(unsigned int index, bool b0, bool b1)
bool getElement(unsigned int index, osg::Vec4d &v4) const
bool setType(Type t)
Set the type of glUniform, ensuring it is only set once.
bool getElement(unsigned int index, osg::Matrix2 &m2) const
void copyData(const Uniform &rhs)
Uniform(const char *name, int i0, int i1, int i2, int i3)
bool getElement(unsigned int index, bool &b0, bool &b1, bool &b2) const
bool set(int i0, int i1)
bool get(osg::Matrix3x2d &m3x2) const
bool get(osg::Matrix2d &m2) const
bool get(osg::Vec3d &v3) const
bool getElement(unsigned int index, osg::Matrix4x2d &m4x2) const
Uniform(const Uniform &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
const FloatArray * getFloatArray() const
Definition Uniform:886
bool set(const osg::Matrix3x4d &m3x4)
ref_ptr< UInt64Array > _uint64Array
Definition Uniform:948
bool getElement(unsigned int index, osg::Vec3 &v3) const
bool setElement(unsigned int index, const osg::Matrix2 &m2)
bool getElement(unsigned int index, osg::Matrix3 &m3) const
Uniform(const char *name, const osg::Matrix2x3d &m2x3)
bool getElement(unsigned int index, osg::Vec2 &v2) const
unsigned int getNumElements() const
Get the number of GLSL elements of the osg::Uniform (1==scalar)
Definition Uniform:579
Uniform(const char *name, long long ll)
bool setElement(unsigned int index, double d)
Uniform(const char *name, const osg::Matrix3x2 &m3x2)
bool setElement(unsigned int index, const osg::Vec2 &v2)
virtual ~Uniform()
virtual int compare(const Uniform &rhs) const
return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
bool getElement(unsigned int index, osg::Matrix3x2 &m3x2) const
bool getElement(unsigned int index, osg::Matrixf &m4) const
Uniform(const char *name, const osg::Matrixd &m4)
unsigned int _nameID
Definition Uniform:938
bool get(osg::Matrix3x2 &m3x2) const
bool isCompatibleType(Type t) const
bool set(double d)
bool getElement(unsigned int index, unsigned int &ui0, unsigned int &ui1) const
bool set(const osg::Vec4 &v4)
bool getElement(unsigned int index, bool &b0, bool &b1) const
bool get(double &d) const
Uniform(const char *name, const osg::Vec2 &v2)
Uniform(const char *name, const osg::Matrix4x3 &m4x3)
bool get(osg::Matrix2x4 &m2x4) const
bool setElement(unsigned int index, long long ll)
bool getElement(unsigned int index, float &f) const
value query for array uniforms
Uniform(const char *name, bool b0, bool b1, bool b2)
Uniform(const char *name, const osg::Matrix2x3 &m2x3)
bool set(bool b0, bool b1, bool b2)
bool get(osg::Vec4 &v4) const
bool setElement(unsigned int index, int i0, int i1, int i2)
bool set(const osg::Matrix3d &m3)
bool setElement(unsigned int index, const osg::Vec3 &v3)
bool get(unsigned int &ui0, unsigned int &ui1, unsigned int &ui2, unsigned int &ui3) const
bool getElement(unsigned int index, osg::Matrix4x3 &m4x3) const
bool setElement(unsigned int index, bool b)
bool setArray(FloatArray *array)
Set the internal data array for a osg::Uniform.
bool get(bool &b) const
const UIntArray * getUIntArray() const
Definition Uniform:898
bool set(int i)
bool setElement(unsigned int index, const osg::Matrix3x2d &m3x2)
General purpose double pair, uses include representation of texture coordinates.
Definition Vec2d:29
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
General purpose double quad.
Definition Vec4d:29
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.