1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include <boost/bind.hpp>
48 #include "OSGConfig.h"
53 #include "OSGWindow.h"
55 #include "OSGGLFuncProtos.h"
57 #include "OSGDrawEnv.h"
59 #include "OSGUniformBufferObjChunk.h"
63 // Documentation for this class is emitted in the
64 // OSGUniformBufferObjChunkBase.cpp file.
65 // To modify it, please change the .fcd file (OSGUniformBufferObjChunk.fcd) and
66 // regenerate the base file.
68 /***************************************************************************\
70 \***************************************************************************/
72 typedef OSG::Window Win
;
74 UInt32
UniformBufferObjChunk::_extUniformBufferObject
= Win::invalidExtensionID
;
75 UInt32
UniformBufferObjChunk::_extVertexBufferObject
= Win::invalidExtensionID
;
77 UInt32
UniformBufferObjChunk::_funcBindBuffer
= Win::invalidFunctionID
;
78 UInt32
UniformBufferObjChunk::_funcMapBuffer
= Win::invalidFunctionID
;
79 UInt32
UniformBufferObjChunk::_funcUnmapBuffer
= Win::invalidFunctionID
;
80 UInt32
UniformBufferObjChunk::_funcBufferData
= Win::invalidFunctionID
;
81 UInt32
UniformBufferObjChunk::_funcBufferSubData
= Win::invalidFunctionID
;
82 UInt32
UniformBufferObjChunk::_funcGenBuffers
= Win::invalidFunctionID
;
83 UInt32
UniformBufferObjChunk::_funcDeleteBuffers
= Win::invalidFunctionID
;
84 UInt32
UniformBufferObjChunk::_funcGetBufferParameteriv
= Win::invalidFunctionID
;
86 UInt32
UniformBufferObjChunk::_funcBindBufferBase
= Win::invalidFunctionID
;
87 UInt32
UniformBufferObjChunk::_funcGetUniformBlockIndex
= Win::invalidFunctionID
;
88 UInt32
UniformBufferObjChunk::_funcGetActiveUniformBlockiv
= Win::invalidFunctionID
;
89 UInt32
UniformBufferObjChunk::_funcGetActiveUniformsiv
= Win::invalidFunctionID
;
90 UInt32
UniformBufferObjChunk::_funcGetUniformIndices
= Win::invalidFunctionID
;
92 /***************************************************************************\
94 \***************************************************************************/
96 void UniformBufferObjChunk::initMethod(InitPhase ePhase
)
98 Inherited::initMethod(ePhase
);
100 if(ePhase
== TypeObject::SystemPost
)
102 _extVertexBufferObject
=
103 Window::registerExtension("GL_ARB_vertex_buffer_object");
105 _funcBindBuffer
= Window::registerFunction(
106 OSG_DLSYM_UNDERSCORE
"glBindBufferARB",
107 _extVertexBufferObject
);
109 _funcMapBuffer
= Window::registerFunction(
110 OSG_DLSYM_UNDERSCORE
"glMapBufferARB",
111 _extVertexBufferObject
);
113 _funcUnmapBuffer
= Window::registerFunction(
114 OSG_DLSYM_UNDERSCORE
"glUnmapBufferARB",
115 _extVertexBufferObject
);
117 _funcBufferData
= Window::registerFunction(
118 OSG_DLSYM_UNDERSCORE
"glBufferDataARB",
119 _extVertexBufferObject
);
121 _funcBufferSubData
= Window::registerFunction(
122 OSG_DLSYM_UNDERSCORE
"glBufferSubDataARB",
123 _extVertexBufferObject
);
125 _funcDeleteBuffers
= Window::registerFunction(
126 OSG_DLSYM_UNDERSCORE
"glDeleteBuffersARB",
127 _extVertexBufferObject
);
129 _funcGenBuffers
= Window::registerFunction(
130 OSG_DLSYM_UNDERSCORE
"glGenBuffersARB",
131 _extVertexBufferObject
);
133 _funcGetBufferParameteriv
= Window::registerFunction(
134 OSG_DLSYM_UNDERSCORE
"glGetBufferParameterivARB",
135 _extVertexBufferObject
);
138 _extUniformBufferObject
=
139 Window::registerExtension("GL_ARB_uniform_buffer_object" );
141 _funcBindBufferBase
= Window::registerFunction(
142 OSG_DLSYM_UNDERSCORE
"glBindBufferBase",
143 _extUniformBufferObject
);
145 _funcGetUniformBlockIndex
= Window::registerFunction(
146 OSG_DLSYM_UNDERSCORE
"glGetUniformBlockIndex",
147 _extUniformBufferObject
);
149 _funcGetActiveUniformBlockiv
= Window::registerFunction(
150 OSG_DLSYM_UNDERSCORE
"glGetActiveUniformBlockiv",
151 _extUniformBufferObject
);
153 _funcGetActiveUniformsiv
= Window::registerFunction(
154 OSG_DLSYM_UNDERSCORE
"glGetActiveUniformsiv",
155 _extUniformBufferObject
);
157 _funcGetUniformIndices
= Window::registerFunction(
158 OSG_DLSYM_UNDERSCORE
"glGetUniformIndices",
159 _extUniformBufferObject
);
164 /***************************************************************************\
166 \***************************************************************************/
168 /*-------------------------------------------------------------------------*\
170 \*-------------------------------------------------------------------------*/
172 /*----------------------- constructors & destructors ----------------------*/
174 UniformBufferObjChunk::UniformBufferObjChunk(void) :
179 UniformBufferObjChunk::UniformBufferObjChunk(const UniformBufferObjChunk
&source
) :
184 UniformBufferObjChunk::~UniformBufferObjChunk(void)
188 /*----------------------------- class specific ----------------------------*/
190 void UniformBufferObjChunk::changed(ConstFieldMaskArg whichField
,
194 GLenum id
= _sfGLId
.getValue();
196 if((whichField
& ( UsageFieldMask
|
198 FundamentalTypesFieldMask
|
200 CardinalityFieldMask
|
203 NameToIndexFieldMask
|
204 FloatValuesFieldMask
|
205 DoubleValuesFieldMask
|
207 UIntValuesFieldMask
|
208 BoolValuesFieldMask
)) != 0)
210 Window::refreshGLObject(id
);
213 Inherited::changed(whichField
, origin
, details
);
216 /*----------------------------- onCreate --------------------------------*/
218 void UniformBufferObjChunk::onCreate(const UniformBufferObjChunk
*source
)
220 Inherited::onCreate(source
);
222 if(GlobalSystemState
== Startup
)
225 setGLId(Window::registerGLObject(
226 boost::bind(&UniformBufferObjChunk::handleGL
,
227 UniformBufferObjChunkMTUncountedPtr(this),
229 &UniformBufferObjChunk::handleDestroyGL
));
232 void UniformBufferObjChunk::onCreateAspect(const UniformBufferObjChunk
*createAspect
,
233 const UniformBufferObjChunk
*source
)
235 Inherited::onCreateAspect(createAspect
, source
);
238 void UniformBufferObjChunk::onDestroy(UInt32 uiContainerId
)
241 Window::destroyGLObject(getGLId(), 1);
243 Inherited::onDestroy(uiContainerId
);
246 /*------------------------------ Output ----------------------------------*/
248 void UniformBufferObjChunk::dump( UInt32 uiIndent
,
249 const BitVector bvFlags
) const
251 Inherited::dump(uiIndent
, bvFlags
);
253 if((bvFlags
& UsageFieldMask
) != 0)
255 indentLog(uiIndent
, PLOG
);
256 PLOG
<< "usage " << _sfUsage
.getValue() << "\n";
258 if((bvFlags
& BlockNameFieldMask
) != 0)
260 indentLog(uiIndent
, PLOG
);
261 PLOG
<< "block name " << _sfBlockName
.getValue() << "\n";
265 /*------------------------------ GL -----------------------------------------*/
267 /*! GL object handler */
268 UInt32
UniformBufferObjChunk::handleGL(DrawEnv
*pEnv
,
270 Window::GLObjectStatusE mode
,
273 Window
*pWin
= pEnv
->getWindow();
274 GLuint id
= pWin
->getGLObjectId(osgid
);
276 bool hasVBO
= pWin
->hasExtOrVersion(_extVertexBufferObject
, 0x0105, 0x0200);
280 ("UniformBufferObjChunk::handleGL: vertex buffer objects not "
281 "supported for this window!\n"));
285 bool hasUBO
= pWin
->hasExtOrVersion(_extUniformBufferObject
, 0x0300);
289 ("UniformBufferObjChunk::handleGL: uniform buffer objects not "
290 "supported for this window!\n"));
296 case Window::initialize
:
298 OSGGETGLFUNCBYID_GL3_ES( glGenBuffers
,
303 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer
,
308 OSGGETGLFUNCBYID_GL3_ES( glBufferData
,
313 OSGGETGLFUNCBYID_GL3_ES( glBindBufferBase
,
318 osgGlGenBuffers(1, &id
);
319 pWin
->setGLObjectId(osgid
, id
);
321 std::vector
<GLubyte
> buffer
= createBuffer(pEnv
);
323 std::size_t sz
= buffer
.size();
326 osgGlBindBuffer (GL_UNIFORM_BUFFER
, id
);
327 osgGlBufferData (GL_UNIFORM_BUFFER
, sz
, &buffer
[0], _sfUsage
.getValue());
328 osgGlBindBuffer (GL_UNIFORM_BUFFER
, 0);
331 glErr("UniformBufferObjChunk::handleGL initialize");
335 case Window::needrefresh
:
337 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer
,
342 OSGGETGLFUNCBYID_GL3_ES( glMapBuffer
,
347 OSGGETGLFUNCBYID_GL3_ES( glUnmapBuffer
,
352 osgGlBindBuffer(GL_UNIFORM_BUFFER
, id
);
353 GLubyte
* pBuffer
= static_cast<GLubyte
*>(
354 osgGlMapBuffer(GL_UNIFORM_BUFFER
, GL_WRITE_ONLY_ARB
));
356 std::vector
<GLubyte
> buffer
= createBuffer(pEnv
);
358 memcpy(pBuffer
, &buffer
[0], sizeof(GLubyte
) * buffer
.size());
360 osgGlUnmapBuffer(GL_UNIFORM_BUFFER
);
361 osgGlBindBuffer (GL_UNIFORM_BUFFER
, 0);
363 glErr("UniformBufferObjChunk::handleGL needrefresh");
368 SWARNING
<< "UniformBufferObjChunk(" << this << "::handleGL: Illegal mode: "
369 << mode
<< " for id " << id
<< std::endl
;
376 /*! GL object handler
379 void UniformBufferObjChunk::handleDestroyGL(DrawEnv
*pEnv
,
381 Window::GLObjectStatusE mode
)
383 Window
*pWin
= pEnv
->getWindow();
384 GLuint id
= pWin
->getGLObjectId(osgid
);
386 if(mode
== Window::destroy
)
388 OSGGETGLFUNCBYID_GL3_ES( glDeleteBuffers
,
393 osgGlDeleteBuffers(1, &id
);
394 pWin
->setGLObjectId(osgid
, 0);
396 glErr("UniformBufferObjChunk::handleDestroyGL");
398 else if(mode
== Window::finaldestroy
)
400 //SWARNING << "Last buffer user destroyed" << std::endl;
404 SWARNING
<< "UniformBufferObjChunk::handleDestroyGL: Illegal mode: "
405 << mode
<< " for id " << id
<< std::endl
;
410 /*------------------------------ tools --------------------------------------*/
412 void UniformBufferObjChunk::validate(DrawEnv
*pEnv
)
414 pEnv
->getWindow()->validateGLObject(this->getGLId(),
418 Int32
UniformBufferObjChunk::getOpenGLId(DrawEnv
*pEnv
)
420 return pEnv
->getWindow()->getGLObjectId(this->getGLId());
423 /*------------------------------ activate -----------------------------------*/
425 void UniformBufferObjChunk::activate(DrawEnv
*pEnv
, UInt32 idx
)
427 Window
*pWin
= pEnv
->getWindow();
429 pWin
->validateGLObject(getGLId(), pEnv
);
431 GLuint id
= pWin
->getGLObjectId(getGLId());
433 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer
,
438 OSGGETGLFUNCBYID_GL3_ES( glBindBufferBase
,
443 osgGlBindBuffer (GL_UNIFORM_BUFFER
, id
);
444 osgGlBindBufferBase(GL_UNIFORM_BUFFER
, idx
, id
);
446 glErr("UniformBufferObjChunk::activate");
449 /*------------------------------ deactivate ---------------------------------*/
451 void UniformBufferObjChunk::deactivate(DrawEnv
*pEnv
, UInt32 idx
)
453 Window
*pWin
= pEnv
->getWindow();
455 OSGGETGLFUNCBYID_GL3_ES( glBindBuffer
,
460 OSGGETGLFUNCBYID_GL3_ES( glBindBufferBase
,
465 osgGlBindBufferBase(GL_UNIFORM_BUFFER
, idx
, 0);
466 osgGlBindBuffer (GL_UNIFORM_BUFFER
, 0);
468 glErr("UniformBufferObjChunk::deactivate");
471 /*------------------------------ changeFrom ---------------------------------*/
473 void UniformBufferObjChunk::changeFrom(DrawEnv
*pEnv
,
477 // change from me to me?
478 // this assumes I haven't changed in the meantime.
479 // is that a valid assumption?
483 old
->deactivate(pEnv
, idx
);
484 this->activate(pEnv
, idx
);
487 /*------------------------------ buffer -------------------------------------*/
489 std::vector
<GLubyte
> UniformBufferObjChunk::createBuffer(DrawEnv
*pEnv
)
491 Window
*pWin
= pEnv
->getWindow();
493 OSGGETGLFUNCBYID_GL3_ES( glGetUniformBlockIndex
,
494 osgGlGetUniformBlockIndex
,
495 _funcGetUniformBlockIndex
,
498 OSGGETGLFUNCBYID_GL3_ES( glGetActiveUniformBlockiv
,
499 osgGlGetActiveUniformBlockiv
,
500 _funcGetActiveUniformBlockiv
,
503 OSGGETGLFUNCBYID_GL3_ES( glGetActiveUniformsiv
,
504 osgGlGetActiveUniformsiv
,
505 _funcGetActiveUniformsiv
,
508 OSGGETGLFUNCBYID_GL3_ES( glGetUniformIndices
,
509 osgGlGetUniformIndices
,
510 _funcGetUniformIndices
,
513 std::vector
<GLubyte
> buffer
;
515 GLuint index
= osgGlGetUniformBlockIndex(pEnv
->getActiveShader(), _sfBlockName
.getValue().c_str());
516 if (index
== GL_INVALID_INDEX
) {
517 SWARNING
<< "UniformBufferObjChunk::createBuffer: Invalid block index" << std::endl
;
522 osgGlGetActiveUniformBlockiv(pEnv
->getActiveShader(), index
, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS
, &num
);
524 if (SizeT(num
) != _mfIndex
.size())
526 SWARNING
<< "UniformBufferObjChunk::createBuffer: Invalid number of active uniforms in block" << std::endl
;
530 std::vector
<const GLchar
*> names
;
531 for (std::size_t i
= 0; i
< _mfNames
.size(); ++i
)
532 names
.push_back(_mfNames
[i
].c_str());
534 std::vector
<GLuint
> indices(num
);
535 osgGlGetUniformIndices(pEnv
->getActiveShader(), num
, &names
[0], &indices
[0]);
536 for (std::size_t i
= 0; i
< indices
.size(); ++i
) {
537 if (indices
[i
] == GL_INVALID_INDEX
) {
538 SWARNING
<< "UniformBufferObjChunk::createBuffer: Invalid block indices" << std::endl
;
543 std::vector
<GLint
> offsets(num
), array_strides(num
), matrix_strides(num
);
545 osgGlGetActiveUniformsiv(pEnv
->getActiveShader(), num
, &indices
[0], GL_UNIFORM_OFFSET
, &offsets
[0]);
546 osgGlGetActiveUniformsiv(pEnv
->getActiveShader(), num
, &indices
[0], GL_UNIFORM_ARRAY_STRIDE
, &array_strides
[0]);
547 osgGlGetActiveUniformsiv(pEnv
->getActiveShader(), num
, &indices
[0], GL_UNIFORM_MATRIX_STRIDE
, &matrix_strides
[0]);
550 osgGlGetActiveUniformBlockiv(pEnv
->getActiveShader(), index
, GL_UNIFORM_BLOCK_DATA_SIZE
, &size
);
554 for (GLint i
= 0; i
< num
; ++i
)
556 UInt32 idx
= _mfIndex
[i
];
557 FundamentalTypes fType
= static_cast<FundamentalTypes
>(_mfFundamentalTypes
[i
]);
558 MainType mType
= static_cast<MainType
> (_mfMainTypes
[i
]);
559 UInt32 card
= _mfCardinality
[i
];
619 GLint offset
= offsets
[i
];
620 GLint array_stride
= array_strides
[i
];
621 GLint matrix_stride
= matrix_strides
[i
];
623 for (UInt32 j
= 0; j
< card
; ++j
)
625 GLint offset_
= offset
;
626 for (UInt8 k
= 0; k
< columns
; ++k
)
628 for (UInt8 l
= 0; l
< rows
; ++l
)
630 UInt32 idx_
= idx
+ j
* rows
* columns
+ k
* rows
+ l
;
633 reinterpret_cast<Real32
*>(&buffer
[0] + offset
)[l
] = _mfFloatValues
[idx_
];
636 reinterpret_cast<Real64
*>(&buffer
[0] + offset
)[l
] = _mfDoubleValues
[idx_
];
639 reinterpret_cast<Int32
*>(&buffer
[0] + offset
)[l
] = _mfIntValues
[idx_
];
642 reinterpret_cast<UInt32
*>(&buffer
[0] + offset
)[l
] = _mfUIntValues
[idx_
];
645 reinterpret_cast<Int32
*>(&buffer
[0] + offset
)[l
] = _mfBoolValues
[idx_
];
649 offset
+= matrix_stride
;
651 offset
= offset_
+ array_stride
;
658 /*------------------------------ add-interface ------------------------------*/
660 UInt32
UniformBufferObjChunk::addFloat(const std::string
& name
, UInt32 cardinality
)
662 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
663 editMField(MainTypesFieldMask
, _mfMainTypes
);
664 editMField(CardinalityFieldMask
, _mfCardinality
);
665 editMField(IndexFieldMask
, _mfIndex
);
666 editMField(NamesFieldMask
, _mfNames
);
667 editMField(FloatValuesFieldMask
, _mfFloatValues
);
668 editSField(NameToIndexFieldMask
);
670 _mfFundamentalTypes
.push_back(FLOAT_T
);
671 _mfMainTypes
.push_back(SIMPLE_T
);
672 _mfCardinality
.push_back(cardinality
);
673 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
674 _mfNames
.push_back(name
);
676 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
678 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
680 for (UInt32 i
= 0; i
< cardinality
; ++i
)
681 _mfFloatValues
.push_back(0.f
);
683 OSG_ASSERT(invariantOnStorageSize());
688 UInt32
UniformBufferObjChunk::addDouble(const std::string
& name
, UInt32 cardinality
)
690 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
691 editMField(MainTypesFieldMask
, _mfMainTypes
);
692 editMField(CardinalityFieldMask
, _mfCardinality
);
693 editMField(IndexFieldMask
, _mfIndex
);
694 editMField(NamesFieldMask
, _mfNames
);
695 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
696 editSField(NameToIndexFieldMask
);
698 _mfFundamentalTypes
.push_back(DOUBLE_T
);
699 _mfMainTypes
.push_back(SIMPLE_T
);
700 _mfCardinality
.push_back(cardinality
);
701 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
702 _mfNames
.push_back(name
);
704 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
706 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
708 for (UInt32 i
= 0; i
< cardinality
; ++i
)
709 _mfDoubleValues
.push_back(0.);
711 OSG_ASSERT(invariantOnStorageSize());
716 UInt32
UniformBufferObjChunk::addInt(const std::string
& name
, UInt32 cardinality
)
718 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
719 editMField(MainTypesFieldMask
, _mfMainTypes
);
720 editMField(CardinalityFieldMask
, _mfCardinality
);
721 editMField(IndexFieldMask
, _mfIndex
);
722 editMField(NamesFieldMask
, _mfNames
);
723 editMField(IntValuesFieldMask
, _mfIntValues
);
724 editSField(NameToIndexFieldMask
);
726 _mfFundamentalTypes
.push_back(INT_T
);
727 _mfMainTypes
.push_back(SIMPLE_T
);
728 _mfCardinality
.push_back(cardinality
);
729 _mfIndex
.push_back(static_cast<UInt32
>(_mfIntValues
.size()));
730 _mfNames
.push_back(name
);
732 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
734 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
736 for (UInt32 i
= 0; i
< cardinality
; ++i
)
737 _mfIntValues
.push_back(0);
739 OSG_ASSERT(invariantOnStorageSize());
744 UInt32
UniformBufferObjChunk::addUInt(const std::string
& name
, UInt32 cardinality
)
746 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
747 editMField(MainTypesFieldMask
, _mfMainTypes
);
748 editMField(CardinalityFieldMask
, _mfCardinality
);
749 editMField(IndexFieldMask
, _mfIndex
);
750 editMField(NamesFieldMask
, _mfNames
);
751 editMField(UIntValuesFieldMask
, _mfUIntValues
);
752 editSField(NameToIndexFieldMask
);
754 _mfFundamentalTypes
.push_back(UINT_T
);
755 _mfMainTypes
.push_back(SIMPLE_T
);
756 _mfCardinality
.push_back(cardinality
);
757 _mfIndex
.push_back(static_cast<UInt32
>(_mfUIntValues
.size()));
758 _mfNames
.push_back(name
);
760 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
762 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
764 for (UInt32 i
= 0; i
< cardinality
; ++i
)
765 _mfUIntValues
.push_back(0);
767 OSG_ASSERT(invariantOnStorageSize());
772 UInt32
UniformBufferObjChunk::addBool(const std::string
& name
, UInt32 cardinality
)
774 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
775 editMField(MainTypesFieldMask
, _mfMainTypes
);
776 editMField(CardinalityFieldMask
, _mfCardinality
);
777 editMField(IndexFieldMask
, _mfIndex
);
778 editMField(NamesFieldMask
, _mfNames
);
779 editMField(BoolValuesFieldMask
, _mfBoolValues
);
780 editSField(NameToIndexFieldMask
);
782 _mfFundamentalTypes
.push_back(BOOL_T
);
783 _mfMainTypes
.push_back(SIMPLE_T
);
784 _mfCardinality
.push_back(cardinality
);
785 _mfIndex
.push_back(static_cast<UInt32
>(_mfBoolValues
.size()));
786 _mfNames
.push_back(name
);
788 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
790 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
792 for (UInt32 i
= 0; i
< cardinality
; ++i
)
793 _mfBoolValues
.push_back(static_cast<UInt8
>(false));
795 OSG_ASSERT(invariantOnStorageSize());
800 UInt32
UniformBufferObjChunk::addVec2(const std::string
& name
, UInt32 cardinality
)
802 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
803 editMField(MainTypesFieldMask
, _mfMainTypes
);
804 editMField(CardinalityFieldMask
, _mfCardinality
);
805 editMField(IndexFieldMask
, _mfIndex
);
806 editMField(NamesFieldMask
, _mfNames
);
807 editMField(FloatValuesFieldMask
, _mfFloatValues
);
808 editSField(NameToIndexFieldMask
);
810 _mfFundamentalTypes
.push_back(FLOAT_T
);
811 _mfMainTypes
.push_back(VEC2_T
);
812 _mfCardinality
.push_back(cardinality
);
813 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
814 _mfNames
.push_back(name
);
816 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
818 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
822 for (UInt32 i
= 0; i
< cardinality
; ++i
)
823 for (UInt8 j
= 0; j
< rows
; ++j
)
824 _mfFloatValues
.push_back(0.f
);
826 OSG_ASSERT(invariantOnStorageSize());
831 UInt32
UniformBufferObjChunk::addVec3(const std::string
& name
, UInt32 cardinality
)
833 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
834 editMField(MainTypesFieldMask
, _mfMainTypes
);
835 editMField(CardinalityFieldMask
, _mfCardinality
);
836 editMField(IndexFieldMask
, _mfIndex
);
837 editMField(NamesFieldMask
, _mfNames
);
838 editMField(FloatValuesFieldMask
, _mfFloatValues
);
839 editSField(NameToIndexFieldMask
);
841 _mfFundamentalTypes
.push_back(FLOAT_T
);
842 _mfMainTypes
.push_back(VEC3_T
);
843 _mfCardinality
.push_back(cardinality
);
844 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
845 _mfNames
.push_back(name
);
847 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
849 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
853 for (UInt32 i
= 0; i
< cardinality
; ++i
)
854 for (UInt8 j
= 0; j
< rows
; ++j
)
855 _mfFloatValues
.push_back(0.f
);
857 OSG_ASSERT(invariantOnStorageSize());
862 UInt32
UniformBufferObjChunk::addVec4(const std::string
& name
, UInt32 cardinality
)
864 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
865 editMField(MainTypesFieldMask
, _mfMainTypes
);
866 editMField(CardinalityFieldMask
, _mfCardinality
);
867 editMField(IndexFieldMask
, _mfIndex
);
868 editMField(NamesFieldMask
, _mfNames
);
869 editMField(FloatValuesFieldMask
, _mfFloatValues
);
870 editSField(NameToIndexFieldMask
);
872 _mfFundamentalTypes
.push_back(FLOAT_T
);
873 _mfMainTypes
.push_back(VEC4_T
);
874 _mfCardinality
.push_back(cardinality
);
875 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
876 _mfNames
.push_back(name
);
878 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
880 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
884 for (UInt32 i
= 0; i
< cardinality
; ++i
)
885 for (UInt8 j
= 0; j
< rows
; ++j
)
886 _mfFloatValues
.push_back(0.f
);
888 OSG_ASSERT(invariantOnStorageSize());
893 UInt32
UniformBufferObjChunk::addDVec2(const std::string
& name
, UInt32 cardinality
)
895 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
896 editMField(MainTypesFieldMask
, _mfMainTypes
);
897 editMField(CardinalityFieldMask
, _mfCardinality
);
898 editMField(IndexFieldMask
, _mfIndex
);
899 editMField(NamesFieldMask
, _mfNames
);
900 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
901 editSField(NameToIndexFieldMask
);
903 _mfFundamentalTypes
.push_back(DOUBLE_T
);
904 _mfMainTypes
.push_back(VEC2_T
);
905 _mfCardinality
.push_back(cardinality
);
906 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
907 _mfNames
.push_back(name
);
909 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
911 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
915 for (UInt32 i
= 0; i
< cardinality
; ++i
)
916 for (UInt8 j
= 0; j
< rows
; ++j
)
917 _mfDoubleValues
.push_back(0.);
919 OSG_ASSERT(invariantOnStorageSize());
924 UInt32
UniformBufferObjChunk::addDVec3(const std::string
& name
, UInt32 cardinality
)
926 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
927 editMField(MainTypesFieldMask
, _mfMainTypes
);
928 editMField(CardinalityFieldMask
, _mfCardinality
);
929 editMField(IndexFieldMask
, _mfIndex
);
930 editMField(NamesFieldMask
, _mfNames
);
931 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
932 editSField(NameToIndexFieldMask
);
934 _mfFundamentalTypes
.push_back(DOUBLE_T
);
935 _mfMainTypes
.push_back(VEC3_T
);
936 _mfCardinality
.push_back(cardinality
);
937 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
938 _mfNames
.push_back(name
);
940 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
942 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
946 for (UInt32 i
= 0; i
< cardinality
; ++i
)
947 for (UInt8 j
= 0; j
< rows
; ++j
)
948 _mfDoubleValues
.push_back(0.);
950 OSG_ASSERT(invariantOnStorageSize());
955 UInt32
UniformBufferObjChunk::addDVec4(const std::string
& name
, UInt32 cardinality
)
957 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
958 editMField(MainTypesFieldMask
, _mfMainTypes
);
959 editMField(CardinalityFieldMask
, _mfCardinality
);
960 editMField(IndexFieldMask
, _mfIndex
);
961 editMField(NamesFieldMask
, _mfNames
);
962 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
963 editSField(NameToIndexFieldMask
);
965 _mfFundamentalTypes
.push_back(DOUBLE_T
);
966 _mfMainTypes
.push_back(VEC4_T
);
967 _mfCardinality
.push_back(cardinality
);
968 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
969 _mfNames
.push_back(name
);
971 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
973 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
977 for (UInt32 i
= 0; i
< cardinality
; ++i
)
978 for (UInt8 j
= 0; j
< rows
; ++j
)
979 _mfDoubleValues
.push_back(0.);
981 OSG_ASSERT(invariantOnStorageSize());
986 UInt32
UniformBufferObjChunk::addIVec2(const std::string
& name
, UInt32 cardinality
)
988 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
989 editMField(MainTypesFieldMask
, _mfMainTypes
);
990 editMField(CardinalityFieldMask
, _mfCardinality
);
991 editMField(IndexFieldMask
, _mfIndex
);
992 editMField(NamesFieldMask
, _mfNames
);
993 editMField(IntValuesFieldMask
, _mfIntValues
);
994 editSField(NameToIndexFieldMask
);
996 _mfFundamentalTypes
.push_back(INT_T
);
997 _mfMainTypes
.push_back(VEC2_T
);
998 _mfCardinality
.push_back(cardinality
);
999 _mfIndex
.push_back(static_cast<UInt32
>(_mfIntValues
.size()));
1000 _mfNames
.push_back(name
);
1002 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1004 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1008 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1009 for (UInt8 j
= 0; j
< rows
; ++j
)
1010 _mfIntValues
.push_back(0);
1012 OSG_ASSERT(invariantOnStorageSize());
1017 UInt32
UniformBufferObjChunk::addIVec3(const std::string
& name
, UInt32 cardinality
)
1019 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1020 editMField(MainTypesFieldMask
, _mfMainTypes
);
1021 editMField(CardinalityFieldMask
, _mfCardinality
);
1022 editMField(IndexFieldMask
, _mfIndex
);
1023 editMField(NamesFieldMask
, _mfNames
);
1024 editMField(IntValuesFieldMask
, _mfIntValues
);
1025 editSField(NameToIndexFieldMask
);
1027 _mfFundamentalTypes
.push_back(INT_T
);
1028 _mfMainTypes
.push_back(VEC3_T
);
1029 _mfCardinality
.push_back(cardinality
);
1030 _mfIndex
.push_back(static_cast<UInt32
>(_mfIntValues
.size()));
1031 _mfNames
.push_back(name
);
1033 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1035 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1039 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1040 for (UInt8 j
= 0; j
< rows
; ++j
)
1041 _mfIntValues
.push_back(0);
1043 OSG_ASSERT(invariantOnStorageSize());
1048 UInt32
UniformBufferObjChunk::addIVec4(const std::string
& name
, UInt32 cardinality
)
1050 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1051 editMField(MainTypesFieldMask
, _mfMainTypes
);
1052 editMField(CardinalityFieldMask
, _mfCardinality
);
1053 editMField(IndexFieldMask
, _mfIndex
);
1054 editMField(NamesFieldMask
, _mfNames
);
1055 editMField(IntValuesFieldMask
, _mfIntValues
);
1056 editSField(NameToIndexFieldMask
);
1058 _mfFundamentalTypes
.push_back(INT_T
);
1059 _mfMainTypes
.push_back(VEC4_T
);
1060 _mfCardinality
.push_back(cardinality
);
1061 _mfIndex
.push_back(static_cast<UInt32
>(_mfIntValues
.size()));
1062 _mfNames
.push_back(name
);
1064 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1066 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1070 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1071 for (UInt8 j
= 0; j
< rows
; ++j
)
1072 _mfIntValues
.push_back(0);
1074 OSG_ASSERT(invariantOnStorageSize());
1079 UInt32
UniformBufferObjChunk::addUVec2(const std::string
& name
, UInt32 cardinality
)
1081 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1082 editMField(MainTypesFieldMask
, _mfMainTypes
);
1083 editMField(CardinalityFieldMask
, _mfCardinality
);
1084 editMField(IndexFieldMask
, _mfIndex
);
1085 editMField(NamesFieldMask
, _mfNames
);
1086 editMField(UIntValuesFieldMask
, _mfUIntValues
);
1087 editSField(NameToIndexFieldMask
);
1089 _mfFundamentalTypes
.push_back(UINT_T
);
1090 _mfMainTypes
.push_back(VEC2_T
);
1091 _mfCardinality
.push_back(cardinality
);
1092 _mfIndex
.push_back(static_cast<UInt32
>(_mfUIntValues
.size()));
1093 _mfNames
.push_back(name
);
1095 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1097 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1101 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1102 for (UInt8 j
= 0; j
< rows
; ++j
)
1103 _mfUIntValues
.push_back(0);
1105 OSG_ASSERT(invariantOnStorageSize());
1110 UInt32
UniformBufferObjChunk::addUVec3(const std::string
& name
, UInt32 cardinality
)
1112 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1113 editMField(MainTypesFieldMask
, _mfMainTypes
);
1114 editMField(CardinalityFieldMask
, _mfCardinality
);
1115 editMField(IndexFieldMask
, _mfIndex
);
1116 editMField(NamesFieldMask
, _mfNames
);
1117 editMField(UIntValuesFieldMask
, _mfUIntValues
);
1118 editSField(NameToIndexFieldMask
);
1120 _mfFundamentalTypes
.push_back(UINT_T
);
1121 _mfMainTypes
.push_back(VEC3_T
);
1122 _mfCardinality
.push_back(cardinality
);
1123 _mfIndex
.push_back(static_cast<UInt32
>(_mfUIntValues
.size()));
1124 _mfNames
.push_back(name
);
1126 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1128 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1132 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1133 for (UInt8 j
= 0; j
< rows
; ++j
)
1134 _mfUIntValues
.push_back(0);
1136 OSG_ASSERT(invariantOnStorageSize());
1141 UInt32
UniformBufferObjChunk::addUVec4(const std::string
& name
, UInt32 cardinality
)
1143 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1144 editMField(MainTypesFieldMask
, _mfMainTypes
);
1145 editMField(CardinalityFieldMask
, _mfCardinality
);
1146 editMField(IndexFieldMask
, _mfIndex
);
1147 editMField(NamesFieldMask
, _mfNames
);
1148 editMField(UIntValuesFieldMask
, _mfUIntValues
);
1149 editSField(NameToIndexFieldMask
);
1151 _mfFundamentalTypes
.push_back(UINT_T
);
1152 _mfMainTypes
.push_back(VEC4_T
);
1153 _mfCardinality
.push_back(cardinality
);
1154 _mfIndex
.push_back(static_cast<UInt32
>(_mfUIntValues
.size()));
1155 _mfNames
.push_back(name
);
1157 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1159 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1163 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1164 for (UInt8 j
= 0; j
< rows
; ++j
)
1165 _mfUIntValues
.push_back(0);
1167 OSG_ASSERT(invariantOnStorageSize());
1172 UInt32
UniformBufferObjChunk::addBVec2(const std::string
& name
, UInt32 cardinality
)
1174 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1175 editMField(MainTypesFieldMask
, _mfMainTypes
);
1176 editMField(CardinalityFieldMask
, _mfCardinality
);
1177 editMField(IndexFieldMask
, _mfIndex
);
1178 editMField(NamesFieldMask
, _mfNames
);
1179 editMField(BoolValuesFieldMask
, _mfBoolValues
);
1180 editSField(NameToIndexFieldMask
);
1182 _mfFundamentalTypes
.push_back(BOOL_T
);
1183 _mfMainTypes
.push_back(VEC2_T
);
1184 _mfCardinality
.push_back(cardinality
);
1185 _mfIndex
.push_back(static_cast<UInt32
>(_mfBoolValues
.size()));
1186 _mfNames
.push_back(name
);
1188 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1190 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1194 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1195 for (UInt8 j
= 0; j
< rows
; ++j
)
1196 _mfBoolValues
.push_back(static_cast<UInt8
>(false));
1198 OSG_ASSERT(invariantOnStorageSize());
1203 UInt32
UniformBufferObjChunk::addBVec3(const std::string
& name
, UInt32 cardinality
)
1205 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1206 editMField(MainTypesFieldMask
, _mfMainTypes
);
1207 editMField(CardinalityFieldMask
, _mfCardinality
);
1208 editMField(IndexFieldMask
, _mfIndex
);
1209 editMField(NamesFieldMask
, _mfNames
);
1210 editMField(BoolValuesFieldMask
, _mfBoolValues
);
1211 editSField(NameToIndexFieldMask
);
1213 _mfFundamentalTypes
.push_back(BOOL_T
);
1214 _mfMainTypes
.push_back(VEC3_T
);
1215 _mfCardinality
.push_back(cardinality
);
1216 _mfIndex
.push_back(static_cast<UInt32
>(_mfBoolValues
.size()));
1217 _mfNames
.push_back(name
);
1219 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1221 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1225 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1226 for (UInt8 j
= 0; j
< rows
; ++j
)
1227 _mfBoolValues
.push_back(static_cast<UInt8
>(false));
1229 OSG_ASSERT(invariantOnStorageSize());
1234 UInt32
UniformBufferObjChunk::addBVec4(const std::string
& name
, UInt32 cardinality
)
1236 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1237 editMField(MainTypesFieldMask
, _mfMainTypes
);
1238 editMField(CardinalityFieldMask
, _mfCardinality
);
1239 editMField(IndexFieldMask
, _mfIndex
);
1240 editMField(NamesFieldMask
, _mfNames
);
1241 editMField(BoolValuesFieldMask
, _mfBoolValues
);
1242 editSField(NameToIndexFieldMask
);
1244 _mfFundamentalTypes
.push_back(BOOL_T
);
1245 _mfMainTypes
.push_back(VEC4_T
);
1246 _mfCardinality
.push_back(cardinality
);
1247 _mfIndex
.push_back(static_cast<UInt32
>(_mfBoolValues
.size()));
1248 _mfNames
.push_back(name
);
1250 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1252 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1256 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1257 for (UInt8 j
= 0; j
< rows
; ++j
)
1258 _mfBoolValues
.push_back(static_cast<UInt8
>(false));
1260 OSG_ASSERT(invariantOnStorageSize());
1265 UInt32
UniformBufferObjChunk::addMat2(const std::string
& name
, UInt32 cardinality
)
1267 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1268 editMField(MainTypesFieldMask
, _mfMainTypes
);
1269 editMField(CardinalityFieldMask
, _mfCardinality
);
1270 editMField(IndexFieldMask
, _mfIndex
);
1271 editMField(NamesFieldMask
, _mfNames
);
1272 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1273 editSField(NameToIndexFieldMask
);
1275 _mfFundamentalTypes
.push_back(FLOAT_T
);
1276 _mfMainTypes
.push_back(MAT2_T
);
1277 _mfCardinality
.push_back(cardinality
);
1278 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1279 _mfNames
.push_back(name
);
1281 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1283 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1288 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1289 for (UInt8 j
= 0; j
< columns
; ++j
)
1290 for (UInt8 k
= 0; k
< rows
; ++k
)
1291 _mfFloatValues
.push_back(0.f
);
1293 OSG_ASSERT(invariantOnStorageSize());
1298 UInt32
UniformBufferObjChunk::addMat3(const std::string
& name
, UInt32 cardinality
)
1300 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1301 editMField(MainTypesFieldMask
, _mfMainTypes
);
1302 editMField(CardinalityFieldMask
, _mfCardinality
);
1303 editMField(IndexFieldMask
, _mfIndex
);
1304 editMField(NamesFieldMask
, _mfNames
);
1305 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1306 editSField(NameToIndexFieldMask
);
1308 _mfFundamentalTypes
.push_back(FLOAT_T
);
1309 _mfMainTypes
.push_back(MAT3_T
);
1310 _mfCardinality
.push_back(cardinality
);
1311 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1312 _mfNames
.push_back(name
);
1314 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1316 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1321 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1322 for (UInt8 j
= 0; j
< columns
; ++j
)
1323 for (UInt8 k
= 0; k
< rows
; ++k
)
1324 _mfFloatValues
.push_back(0.f
);
1326 OSG_ASSERT(invariantOnStorageSize());
1331 UInt32
UniformBufferObjChunk::addMat4(const std::string
& name
, UInt32 cardinality
)
1333 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1334 editMField(MainTypesFieldMask
, _mfMainTypes
);
1335 editMField(CardinalityFieldMask
, _mfCardinality
);
1336 editMField(IndexFieldMask
, _mfIndex
);
1337 editMField(NamesFieldMask
, _mfNames
);
1338 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1339 editSField(NameToIndexFieldMask
);
1341 _mfFundamentalTypes
.push_back(FLOAT_T
);
1342 _mfMainTypes
.push_back(MAT4_T
);
1343 _mfCardinality
.push_back(cardinality
);
1344 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1345 _mfNames
.push_back(name
);
1347 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1349 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1354 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1355 for (UInt8 j
= 0; j
< columns
; ++j
)
1356 for (UInt8 k
= 0; k
< rows
; ++k
)
1357 _mfFloatValues
.push_back(0.f
);
1359 OSG_ASSERT(invariantOnStorageSize());
1364 UInt32
UniformBufferObjChunk::addDMat2(const std::string
& name
, UInt32 cardinality
)
1366 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1367 editMField(MainTypesFieldMask
, _mfMainTypes
);
1368 editMField(CardinalityFieldMask
, _mfCardinality
);
1369 editMField(IndexFieldMask
, _mfIndex
);
1370 editMField(NamesFieldMask
, _mfNames
);
1371 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1372 editSField(NameToIndexFieldMask
);
1374 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1375 _mfMainTypes
.push_back(MAT2_T
);
1376 _mfCardinality
.push_back(cardinality
);
1377 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1378 _mfNames
.push_back(name
);
1380 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1382 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1387 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1388 for (UInt8 j
= 0; j
< columns
; ++j
)
1389 for (UInt8 k
= 0; k
< rows
; ++k
)
1390 _mfDoubleValues
.push_back(0.f
);
1392 OSG_ASSERT(invariantOnStorageSize());
1397 UInt32
UniformBufferObjChunk::addDMat3(const std::string
& name
, UInt32 cardinality
)
1399 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1400 editMField(MainTypesFieldMask
, _mfMainTypes
);
1401 editMField(CardinalityFieldMask
, _mfCardinality
);
1402 editMField(IndexFieldMask
, _mfIndex
);
1403 editMField(NamesFieldMask
, _mfNames
);
1404 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1405 editSField(NameToIndexFieldMask
);
1407 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1408 _mfMainTypes
.push_back(MAT3_T
);
1409 _mfCardinality
.push_back(cardinality
);
1410 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1411 _mfNames
.push_back(name
);
1413 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1415 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1420 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1421 for (UInt8 j
= 0; j
< columns
; ++j
)
1422 for (UInt8 k
= 0; k
< rows
; ++k
)
1423 _mfDoubleValues
.push_back(0.f
);
1425 OSG_ASSERT(invariantOnStorageSize());
1430 UInt32
UniformBufferObjChunk::addDMat4(const std::string
& name
, UInt32 cardinality
)
1432 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1433 editMField(MainTypesFieldMask
, _mfMainTypes
);
1434 editMField(CardinalityFieldMask
, _mfCardinality
);
1435 editMField(IndexFieldMask
, _mfIndex
);
1436 editMField(NamesFieldMask
, _mfNames
);
1437 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1438 editSField(NameToIndexFieldMask
);
1440 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1441 _mfMainTypes
.push_back(MAT4_T
);
1442 _mfCardinality
.push_back(cardinality
);
1443 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1444 _mfNames
.push_back(name
);
1446 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1448 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1453 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1454 for (UInt8 j
= 0; j
< columns
; ++j
)
1455 for (UInt8 k
= 0; k
< rows
; ++k
)
1456 _mfDoubleValues
.push_back(0.f
);
1458 OSG_ASSERT(invariantOnStorageSize());
1463 UInt32
UniformBufferObjChunk::addMat2x3(const std::string
& name
, UInt32 cardinality
)
1465 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1466 editMField(MainTypesFieldMask
, _mfMainTypes
);
1467 editMField(CardinalityFieldMask
, _mfCardinality
);
1468 editMField(IndexFieldMask
, _mfIndex
);
1469 editMField(NamesFieldMask
, _mfNames
);
1470 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1471 editSField(NameToIndexFieldMask
);
1473 _mfFundamentalTypes
.push_back(FLOAT_T
);
1474 _mfMainTypes
.push_back(MAT2X3_T
);
1475 _mfCardinality
.push_back(cardinality
);
1476 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1477 _mfNames
.push_back(name
);
1479 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1481 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1486 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1487 for (UInt8 j
= 0; j
< columns
; ++j
)
1488 for (UInt8 k
= 0; k
< rows
; ++k
)
1489 _mfFloatValues
.push_back(0.f
);
1491 OSG_ASSERT(invariantOnStorageSize());
1496 UInt32
UniformBufferObjChunk::addMat3x2(const std::string
& name
, UInt32 cardinality
)
1498 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1499 editMField(MainTypesFieldMask
, _mfMainTypes
);
1500 editMField(CardinalityFieldMask
, _mfCardinality
);
1501 editMField(IndexFieldMask
, _mfIndex
);
1502 editMField(NamesFieldMask
, _mfNames
);
1503 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1504 editSField(NameToIndexFieldMask
);
1506 _mfFundamentalTypes
.push_back(FLOAT_T
);
1507 _mfMainTypes
.push_back(MAT3X2_T
);
1508 _mfCardinality
.push_back(cardinality
);
1509 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1510 _mfNames
.push_back(name
);
1512 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1514 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1519 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1520 for (UInt8 j
= 0; j
< columns
; ++j
)
1521 for (UInt8 k
= 0; k
< rows
; ++k
)
1522 _mfFloatValues
.push_back(0.f
);
1523 OSG_ASSERT(invariantOnStorageSize());
1528 UInt32
UniformBufferObjChunk::addMat2x4(const std::string
& name
, UInt32 cardinality
)
1530 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1531 editMField(MainTypesFieldMask
, _mfMainTypes
);
1532 editMField(CardinalityFieldMask
, _mfCardinality
);
1533 editMField(IndexFieldMask
, _mfIndex
);
1534 editMField(NamesFieldMask
, _mfNames
);
1535 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1536 editSField(NameToIndexFieldMask
);
1538 _mfFundamentalTypes
.push_back(FLOAT_T
);
1539 _mfMainTypes
.push_back(MAT2X4_T
);
1540 _mfCardinality
.push_back(cardinality
);
1541 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1542 _mfNames
.push_back(name
);
1544 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1546 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1551 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1552 for (UInt8 j
= 0; j
< columns
; ++j
)
1553 for (UInt8 k
= 0; k
< rows
; ++k
)
1554 _mfFloatValues
.push_back(0.f
);
1556 OSG_ASSERT(invariantOnStorageSize());
1561 UInt32
UniformBufferObjChunk::addMat4x2(const std::string
& name
, UInt32 cardinality
)
1563 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1564 editMField(MainTypesFieldMask
, _mfMainTypes
);
1565 editMField(CardinalityFieldMask
, _mfCardinality
);
1566 editMField(IndexFieldMask
, _mfIndex
);
1567 editMField(NamesFieldMask
, _mfNames
);
1568 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1569 editSField(NameToIndexFieldMask
);
1571 _mfFundamentalTypes
.push_back(FLOAT_T
);
1572 _mfMainTypes
.push_back(MAT4X2_T
);
1573 _mfCardinality
.push_back(cardinality
);
1574 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1575 _mfNames
.push_back(name
);
1577 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1579 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1584 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1585 for (UInt8 j
= 0; j
< columns
; ++j
)
1586 for (UInt8 k
= 0; k
< rows
; ++k
)
1587 _mfFloatValues
.push_back(0.f
);
1589 OSG_ASSERT(invariantOnStorageSize());
1594 UInt32
UniformBufferObjChunk::addMat3x4(const std::string
& name
, UInt32 cardinality
)
1596 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1597 editMField(MainTypesFieldMask
, _mfMainTypes
);
1598 editMField(CardinalityFieldMask
, _mfCardinality
);
1599 editMField(IndexFieldMask
, _mfIndex
);
1600 editMField(NamesFieldMask
, _mfNames
);
1601 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1602 editSField(NameToIndexFieldMask
);
1604 _mfFundamentalTypes
.push_back(FLOAT_T
);
1605 _mfMainTypes
.push_back(MAT3X4_T
);
1606 _mfCardinality
.push_back(cardinality
);
1607 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1608 _mfNames
.push_back(name
);
1610 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1612 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1617 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1618 for (UInt8 j
= 0; j
< columns
; ++j
)
1619 for (UInt8 k
= 0; k
< rows
; ++k
)
1620 _mfFloatValues
.push_back(0.f
);
1622 OSG_ASSERT(invariantOnStorageSize());
1627 UInt32
UniformBufferObjChunk::addMat4x3(const std::string
& name
, UInt32 cardinality
)
1629 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1630 editMField(MainTypesFieldMask
, _mfMainTypes
);
1631 editMField(CardinalityFieldMask
, _mfCardinality
);
1632 editMField(IndexFieldMask
, _mfIndex
);
1633 editMField(NamesFieldMask
, _mfNames
);
1634 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1635 editSField(NameToIndexFieldMask
);
1637 _mfFundamentalTypes
.push_back(FLOAT_T
);
1638 _mfMainTypes
.push_back(MAT4X3_T
);
1639 _mfCardinality
.push_back(cardinality
);
1640 _mfIndex
.push_back(static_cast<UInt32
>(_mfFloatValues
.size()));
1641 _mfNames
.push_back(name
);
1643 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1645 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1650 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1651 for (UInt8 j
= 0; j
< columns
; ++j
)
1652 for (UInt8 k
= 0; k
< rows
; ++k
)
1653 _mfFloatValues
.push_back(0.f
);
1655 OSG_ASSERT(invariantOnStorageSize());
1660 UInt32
UniformBufferObjChunk::addDMat2x3(const std::string
& name
, UInt32 cardinality
)
1662 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1663 editMField(MainTypesFieldMask
, _mfMainTypes
);
1664 editMField(CardinalityFieldMask
, _mfCardinality
);
1665 editMField(IndexFieldMask
, _mfIndex
);
1666 editMField(NamesFieldMask
, _mfNames
);
1667 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1668 editSField(NameToIndexFieldMask
);
1670 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1671 _mfMainTypes
.push_back(MAT2X3_T
);
1672 _mfCardinality
.push_back(cardinality
);
1673 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1674 _mfNames
.push_back(name
);
1676 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1678 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1683 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1684 for (UInt8 j
= 0; j
< columns
; ++j
)
1685 for (UInt8 k
= 0; k
< rows
; ++k
)
1686 _mfDoubleValues
.push_back(0.f
);
1688 OSG_ASSERT(invariantOnStorageSize());
1693 UInt32
UniformBufferObjChunk::addDMat3x2(const std::string
& name
, UInt32 cardinality
)
1695 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1696 editMField(MainTypesFieldMask
, _mfMainTypes
);
1697 editMField(CardinalityFieldMask
, _mfCardinality
);
1698 editMField(IndexFieldMask
, _mfIndex
);
1699 editMField(NamesFieldMask
, _mfNames
);
1700 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1701 editSField(NameToIndexFieldMask
);
1703 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1704 _mfMainTypes
.push_back(MAT3X2_T
);
1705 _mfCardinality
.push_back(cardinality
);
1706 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1707 _mfNames
.push_back(name
);
1709 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1711 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1716 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1717 for (UInt8 j
= 0; j
< columns
; ++j
)
1718 for (UInt8 k
= 0; k
< rows
; ++k
)
1719 _mfDoubleValues
.push_back(0.f
);
1721 OSG_ASSERT(invariantOnStorageSize());
1726 UInt32
UniformBufferObjChunk::addDMat2x4(const std::string
& name
, UInt32 cardinality
)
1728 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1729 editMField(MainTypesFieldMask
, _mfMainTypes
);
1730 editMField(CardinalityFieldMask
, _mfCardinality
);
1731 editMField(IndexFieldMask
, _mfIndex
);
1732 editMField(NamesFieldMask
, _mfNames
);
1733 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1734 editSField(NameToIndexFieldMask
);
1736 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1737 _mfMainTypes
.push_back(MAT2X4_T
);
1738 _mfCardinality
.push_back(cardinality
);
1739 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1740 _mfNames
.push_back(name
);
1742 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1744 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1749 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1750 for (UInt8 j
= 0; j
< columns
; ++j
)
1751 for (UInt8 k
= 0; k
< rows
; ++k
)
1752 _mfDoubleValues
.push_back(0.f
);
1754 OSG_ASSERT(invariantOnStorageSize());
1759 UInt32
UniformBufferObjChunk::addDMat4x2(const std::string
& name
, UInt32 cardinality
)
1761 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1762 editMField(MainTypesFieldMask
, _mfMainTypes
);
1763 editMField(CardinalityFieldMask
, _mfCardinality
);
1764 editMField(IndexFieldMask
, _mfIndex
);
1765 editMField(NamesFieldMask
, _mfNames
);
1766 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1767 editSField(NameToIndexFieldMask
);
1769 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1770 _mfMainTypes
.push_back(MAT4X2_T
);
1771 _mfCardinality
.push_back(cardinality
);
1772 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1773 _mfNames
.push_back(name
);
1775 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1777 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1782 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1783 for (UInt8 j
= 0; j
< columns
; ++j
)
1784 for (UInt8 k
= 0; k
< rows
; ++k
)
1785 _mfDoubleValues
.push_back(0.f
);
1787 OSG_ASSERT(invariantOnStorageSize());
1792 UInt32
UniformBufferObjChunk::addDMat3x4(const std::string
& name
, UInt32 cardinality
)
1794 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1795 editMField(MainTypesFieldMask
, _mfMainTypes
);
1796 editMField(CardinalityFieldMask
, _mfCardinality
);
1797 editMField(IndexFieldMask
, _mfIndex
);
1798 editMField(NamesFieldMask
, _mfNames
);
1799 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1800 editSField(NameToIndexFieldMask
);
1802 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1803 _mfMainTypes
.push_back(MAT3X4_T
);
1804 _mfCardinality
.push_back(cardinality
);
1805 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1806 _mfNames
.push_back(name
);
1808 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1810 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1815 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1816 for (UInt8 j
= 0; j
< columns
; ++j
)
1817 for (UInt8 k
= 0; k
< rows
; ++k
)
1818 _mfDoubleValues
.push_back(0.f
);
1820 OSG_ASSERT(invariantOnStorageSize());
1825 UInt32
UniformBufferObjChunk::addDMat4x3(const std::string
& name
, UInt32 cardinality
)
1827 editMField(FundamentalTypesFieldMask
, _mfFundamentalTypes
);
1828 editMField(MainTypesFieldMask
, _mfMainTypes
);
1829 editMField(CardinalityFieldMask
, _mfCardinality
);
1830 editMField(IndexFieldMask
, _mfIndex
);
1831 editMField(NamesFieldMask
, _mfNames
);
1832 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1833 editSField(NameToIndexFieldMask
);
1835 _mfFundamentalTypes
.push_back(DOUBLE_T
);
1836 _mfMainTypes
.push_back(MAT4X3_T
);
1837 _mfCardinality
.push_back(cardinality
);
1838 _mfIndex
.push_back(static_cast<UInt32
>(_mfDoubleValues
.size()));
1839 _mfNames
.push_back(name
);
1841 UInt32 index
= static_cast<UInt32
>(_mfIndex
.size()) - 1;
1843 _sfNameToIndex
.getValue().insert(StringToUInt32Map::value_type(name
, index
));
1848 for (UInt32 i
= 0; i
< cardinality
; ++i
)
1849 for (UInt8 j
= 0; j
< columns
; ++j
)
1850 for (UInt8 k
= 0; k
< rows
; ++k
)
1851 _mfDoubleValues
.push_back(0.f
);
1853 OSG_ASSERT(invariantOnStorageSize());
1858 /*------------------------------ set-interface I ----------------------------*/
1860 void UniformBufferObjChunk::setFloat(UInt32 handle
, Real32 value
, UInt32 array_idx
)
1862 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1864 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1865 _mfFloatValues
[_mfIndex
[handle
] + array_idx
] = value
;
1868 void UniformBufferObjChunk::setDouble(UInt32 handle
, Real64 value
, UInt32 array_idx
)
1870 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1872 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1873 _mfDoubleValues
[_mfIndex
[handle
] + array_idx
] = value
;
1876 void UniformBufferObjChunk::setInt(UInt32 handle
, Int32 value
, UInt32 array_idx
)
1878 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1880 editMField(IntValuesFieldMask
, _mfIntValues
);
1881 _mfIntValues
[_mfIndex
[handle
] + array_idx
] = value
;
1884 void UniformBufferObjChunk::setUInt(UInt32 handle
, UInt32 value
, UInt32 array_idx
)
1886 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1888 editMField(UIntValuesFieldMask
, _mfUIntValues
);
1889 _mfUIntValues
[_mfIndex
[handle
] + array_idx
] = value
;
1892 void UniformBufferObjChunk::setBool(UInt32 handle
, bool value
, UInt32 array_idx
)
1894 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1896 editMField(BoolValuesFieldMask
, _mfBoolValues
);
1897 _mfBoolValues
[_mfIndex
[handle
] + array_idx
] = static_cast<UInt8
>(value
);
1900 void UniformBufferObjChunk::setVec2(UInt32 handle
, const Vec2f
& value
, UInt32 array_idx
)
1902 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1904 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1907 for (int i
= 0; i
< size
; ++i
)
1908 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1911 void UniformBufferObjChunk::setVec2(UInt32 handle
, const Pnt2f
& value
, UInt32 array_idx
)
1913 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1915 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1918 for (int i
= 0; i
< size
; ++i
)
1919 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1922 void UniformBufferObjChunk::setVec3(UInt32 handle
, const Vec3f
& value
, UInt32 array_idx
)
1924 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1926 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1929 for (int i
= 0; i
< size
; ++i
)
1930 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1933 void UniformBufferObjChunk::setVec3(UInt32 handle
, const Pnt3f
& value
, UInt32 array_idx
)
1935 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1937 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1940 for (int i
= 0; i
< size
; ++i
)
1941 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1944 void UniformBufferObjChunk::setVec3(UInt32 handle
, const Color3f
& value
, UInt32 array_idx
)
1946 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1948 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1951 for (int i
= 0; i
< size
; ++i
)
1952 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1955 void UniformBufferObjChunk::setVec4(UInt32 handle
, const Vec4f
& value
, UInt32 array_idx
)
1957 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1959 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1962 for (int i
= 0; i
< size
; ++i
)
1963 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1966 void UniformBufferObjChunk::setVec4(UInt32 handle
, const Pnt4f
& value
, UInt32 array_idx
)
1968 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1970 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1973 for (int i
= 0; i
< size
; ++i
)
1974 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1977 void UniformBufferObjChunk::setVec4(UInt32 handle
, const Color4f
& value
, UInt32 array_idx
)
1979 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1981 editMField(FloatValuesFieldMask
, _mfFloatValues
);
1984 for (int i
= 0; i
< size
; ++i
)
1985 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1988 void UniformBufferObjChunk::setDVec2(UInt32 handle
, const Vec2d
& value
, UInt32 array_idx
)
1990 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
1992 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
1995 for (int i
= 0; i
< size
; ++i
)
1996 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
1999 void UniformBufferObjChunk::setDVec2(UInt32 handle
, const Pnt2d
& value
, UInt32 array_idx
)
2001 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2003 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2006 for (int i
= 0; i
< size
; ++i
)
2007 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2010 void UniformBufferObjChunk::setDVec3(UInt32 handle
, const Vec3d
& value
, UInt32 array_idx
)
2012 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2014 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2017 for (int i
= 0; i
< size
; ++i
)
2018 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2021 void UniformBufferObjChunk::setDVec3(UInt32 handle
, const Pnt3d
& value
, UInt32 array_idx
)
2023 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2025 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2028 for (int i
= 0; i
< size
; ++i
)
2029 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2032 void UniformBufferObjChunk::setDVec4(UInt32 handle
, const Vec4d
& value
, UInt32 array_idx
)
2034 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2036 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2039 for (int i
= 0; i
< size
; ++i
)
2040 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2043 void UniformBufferObjChunk::setDVec4(UInt32 handle
, const Pnt4d
& value
, UInt32 array_idx
)
2045 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2047 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2050 for (int i
= 0; i
< size
; ++i
)
2051 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2054 void UniformBufferObjChunk::setIVec2(UInt32 handle
, const Vec2i
& value
, UInt32 array_idx
)
2056 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2058 editMField(IntValuesFieldMask
, _mfIntValues
);
2061 for (int i
= 0; i
< size
; ++i
)
2062 _mfIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2065 void UniformBufferObjChunk::setIVec2(UInt32 handle
, const Pnt2i
& value
, UInt32 array_idx
)
2067 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2069 editMField(IntValuesFieldMask
, _mfIntValues
);
2072 for (int i
= 0; i
< size
; ++i
)
2073 _mfIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2076 void UniformBufferObjChunk::setIVec3(UInt32 handle
, const Vec3i
& value
, UInt32 array_idx
)
2078 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2080 editMField(IntValuesFieldMask
, _mfIntValues
);
2083 for (int i
= 0; i
< size
; ++i
)
2084 _mfIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2087 void UniformBufferObjChunk::setIVec3(UInt32 handle, const Pnt3i& value, UInt32 array_idx)
2089 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2091 editMField(IntValuesFieldMask, _mfIntValues);
2094 for (int i = 0; i < size; ++i)
2095 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2098 void UniformBufferObjChunk::setIVec4(UInt32 handle
, const Vec4i
& value
, UInt32 array_idx
)
2100 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2102 editMField(IntValuesFieldMask
, _mfIntValues
);
2105 for (int i
= 0; i
< size
; ++i
)
2106 _mfIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2109 void UniformBufferObjChunk::setIVec4(UInt32 handle, const Pnt4i& value, UInt32 array_idx)
2111 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2113 editMField(IntValuesFieldMask, _mfIntValues);
2116 for (int i = 0; i < size; ++i)
2117 _mfIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2120 void UniformBufferObjChunk::setUVec2(UInt32 handle
, const Vec2u
& value
, UInt32 array_idx
)
2122 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2124 editMField(UIntValuesFieldMask
, _mfUIntValues
);
2127 for (int i
= 0; i
< size
; ++i
)
2128 _mfUIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2131 void UniformBufferObjChunk::setUVec2(UInt32 handle, const Pnt2u& value, UInt32 array_idx)
2133 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2135 editMField(UIntValuesFieldMask, _mfUIntValues);
2138 for (int i = 0; i < size; ++i)
2139 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2142 void UniformBufferObjChunk::setUVec3(UInt32 handle
, const Vec3u
& value
, UInt32 array_idx
)
2144 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2146 editMField(UIntValuesFieldMask
, _mfUIntValues
);
2149 for (int i
= 0; i
< size
; ++i
)
2150 _mfUIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2153 void UniformBufferObjChunk::setUVec3(UInt32 handle, const Pnt3u& value, UInt32 array_idx)
2155 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2157 editMField(UIntValuesFieldMask, _mfUIntValues);
2160 for (int i = 0; i < size; ++i)
2161 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2164 void UniformBufferObjChunk::setUVec4(UInt32 handle
, const Vec4u
& value
, UInt32 array_idx
)
2166 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2168 editMField(UIntValuesFieldMask
, _mfUIntValues
);
2171 for (int i
= 0; i
< size
; ++i
)
2172 _mfUIntValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = value
[i
];
2175 void UniformBufferObjChunk::setUVec4(UInt32 handle, const Pnt4u& value, UInt32 array_idx)
2177 OSG_ASSERT(array_idx < _mfCardinality[handle]);
2179 editMField(UIntValuesFieldMask, _mfUIntValues);
2182 for (int i = 0; i < size; ++i)
2183 _mfUIntValues[_mfIndex[handle] + (array_idx * size) + i] = value[i];
2186 void UniformBufferObjChunk::setBVec2(UInt32 handle
, const Vec2b
& value
, UInt32 array_idx
)
2188 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2190 editMField(BoolValuesFieldMask
, _mfBoolValues
);
2193 for (int i
= 0; i
< size
; ++i
)
2194 _mfBoolValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = static_cast<UInt8
>(value
[i
]);
2197 void UniformBufferObjChunk::setBVec2(UInt32 handle
, const Pnt2b
& value
, UInt32 array_idx
)
2199 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2201 editMField(BoolValuesFieldMask
, _mfBoolValues
);
2204 for (int i
= 0; i
< size
; ++i
)
2205 _mfBoolValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = static_cast<UInt8
>(value
[i
]);
2208 void UniformBufferObjChunk::setBVec3(UInt32 handle
, const Vec3b
& value
, UInt32 array_idx
)
2210 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2212 editMField(BoolValuesFieldMask
, _mfBoolValues
);
2215 for (int i
= 0; i
< size
; ++i
)
2216 _mfBoolValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = static_cast<UInt8
>(value
[i
]);
2219 void UniformBufferObjChunk::setBVec3(UInt32 handle
, const Pnt3b
& value
, UInt32 array_idx
)
2221 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2223 editMField(BoolValuesFieldMask
, _mfBoolValues
);
2226 for (int i
= 0; i
< size
; ++i
)
2227 _mfBoolValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = static_cast<UInt8
>(value
[i
]);
2230 void UniformBufferObjChunk::setBVec4(UInt32 handle
, const Vec4b
& value
, UInt32 array_idx
)
2232 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2234 editMField(BoolValuesFieldMask
, _mfBoolValues
);
2237 for (int i
= 0; i
< size
; ++i
)
2238 _mfBoolValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = static_cast<UInt8
>(value
[i
]);
2241 void UniformBufferObjChunk::setBVec4(UInt32 handle
, const Pnt4b
& value
, UInt32 array_idx
)
2243 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2245 editMField(BoolValuesFieldMask
, _mfBoolValues
);
2248 for (int i
= 0; i
< size
; ++i
)
2249 _mfBoolValues
[_mfIndex
[handle
] + (array_idx
* size
) + i
] = static_cast<UInt8
>(value
[i
]);
2252 void UniformBufferObjChunk::setMat2(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2254 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2256 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2261 for (int i
= 0; i
< columns
; ++i
) {
2262 const Vec4f
& v
= value
[i
];
2263 for (int j
= 0; j
< rows
; ++j
) {
2264 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2269 void UniformBufferObjChunk::setMat3(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2271 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2273 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2278 for (int i
= 0; i
< columns
; ++i
) {
2279 const Vec4f
& v
= value
[i
];
2280 for (int j
= 0; j
< rows
; ++j
) {
2281 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2286 void UniformBufferObjChunk::setMat4(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2288 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2290 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2295 for (int i
= 0; i
< columns
; ++i
) {
2296 const Vec4f
& v
= value
[i
];
2297 for (int j
= 0; j
< rows
; ++j
) {
2298 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2303 void UniformBufferObjChunk::setDMat2(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2305 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2307 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2312 for (int i
= 0; i
< columns
; ++i
) {
2313 const Vec4d
& v
= value
[i
];
2314 for (int j
= 0; j
< rows
; ++j
) {
2315 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2320 void UniformBufferObjChunk::setDMat3(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2322 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2324 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2329 for (int i
= 0; i
< columns
; ++i
) {
2330 const Vec4d
& v
= value
[i
];
2331 for (int j
= 0; j
< rows
; ++j
) {
2332 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2337 void UniformBufferObjChunk::setDMat4(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2339 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2341 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2346 for (int i
= 0; i
< columns
; ++i
) {
2347 const Vec4d
& v
= value
[i
];
2348 for (int j
= 0; j
< rows
; ++j
) {
2349 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2354 void UniformBufferObjChunk::setMat2x3(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2356 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2358 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2363 for (int i
= 0; i
< columns
; ++i
) {
2364 const Vec4f
& v
= value
[i
];
2365 for (int j
= 0; j
< rows
; ++j
) {
2366 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2371 void UniformBufferObjChunk::setMat3x2(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2373 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2375 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2380 for (int i
= 0; i
< columns
; ++i
) {
2381 const Vec4f
& v
= value
[i
];
2382 for (int j
= 0; j
< rows
; ++j
) {
2383 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2388 void UniformBufferObjChunk::setMat2x4(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2390 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2392 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2397 for (int i
= 0; i
< columns
; ++i
) {
2398 const Vec4f
& v
= value
[i
];
2399 for (int j
= 0; j
< rows
; ++j
) {
2400 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2405 void UniformBufferObjChunk::setMat4x2(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2407 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2409 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2414 for (int i
= 0; i
< columns
; ++i
) {
2415 const Vec4f
& v
= value
[i
];
2416 for (int j
= 0; j
< rows
; ++j
) {
2417 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2422 void UniformBufferObjChunk::setMat3x4(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2424 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2426 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2431 for (int i
= 0; i
< columns
; ++i
) {
2432 const Vec4f
& v
= value
[i
];
2433 for (int j
= 0; j
< rows
; ++j
) {
2434 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2439 void UniformBufferObjChunk::setMat4x3(UInt32 handle
, const Matrix4f
& value
, UInt32 array_idx
)
2441 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2443 editMField(FloatValuesFieldMask
, _mfFloatValues
);
2448 for (int i
= 0; i
< columns
; ++i
) {
2449 const Vec4f
& v
= value
[i
];
2450 for (int j
= 0; j
< rows
; ++j
) {
2451 _mfFloatValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2456 void UniformBufferObjChunk::setDMat2x3(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2458 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2460 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2465 for (int i
= 0; i
< columns
; ++i
) {
2466 const Vec4d
& v
= value
[i
];
2467 for (int j
= 0; j
< rows
; ++j
) {
2468 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2473 void UniformBufferObjChunk::setDMat3x2(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2475 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2477 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2482 for (int i
= 0; i
< columns
; ++i
) {
2483 const Vec4d
& v
= value
[i
];
2484 for (int j
= 0; j
< rows
; ++j
) {
2485 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2490 void UniformBufferObjChunk::setDMat2x4(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2492 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2494 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2499 for (int i
= 0; i
< columns
; ++i
) {
2500 const Vec4d
& v
= value
[i
];
2501 for (int j
= 0; j
< rows
; ++j
) {
2502 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2507 void UniformBufferObjChunk::setDMat4x2(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2509 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2511 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2516 for (int i
= 0; i
< columns
; ++i
) {
2517 const Vec4d
& v
= value
[i
];
2518 for (int j
= 0; j
< rows
; ++j
) {
2519 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2524 void UniformBufferObjChunk::setDMat3x4(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2526 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2528 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2533 for (int i
= 0; i
< columns
; ++i
) {
2534 const Vec4d
& v
= value
[i
];
2535 for (int j
= 0; j
< rows
; ++j
) {
2536 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2541 void UniformBufferObjChunk::setDMat4x3(UInt32 handle
, const Matrix4d
& value
, UInt32 array_idx
)
2543 OSG_ASSERT(array_idx
< _mfCardinality
[handle
]);
2545 editMField(DoubleValuesFieldMask
, _mfDoubleValues
);
2550 for (int i
= 0; i
< columns
; ++i
) {
2551 const Vec4d
& v
= value
[i
];
2552 for (int j
= 0; j
< rows
; ++j
) {
2553 _mfDoubleValues
[_mfIndex
[handle
] + (array_idx
* rows
* columns
) + (j
+ rows
* i
)] = v
[j
];
2558 /*------------------------------ set-interface II ---------------------------*/
2560 void UniformBufferObjChunk::setFloat(const std::string
& name
, Real32 value
, UInt32 array_idx
)
2562 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2563 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2564 setFloat(iter
->second
, value
, array_idx
);
2567 void UniformBufferObjChunk::setDouble(const std::string
& name
, Real64 value
, UInt32 array_idx
)
2569 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2570 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2571 setDouble(iter
->second
, value
, array_idx
);
2574 void UniformBufferObjChunk::setInt(const std::string
& name
, Int32 value
, UInt32 array_idx
)
2576 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2577 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2578 setInt(iter
->second
, value
, array_idx
);
2581 void UniformBufferObjChunk::setUInt(const std::string
& name
, UInt32 value
, UInt32 array_idx
)
2583 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2584 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2585 setUInt(iter
->second
, value
, array_idx
);
2588 void UniformBufferObjChunk::setBool(const std::string
& name
, bool value
, UInt32 array_idx
)
2590 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2591 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2592 setBool(iter
->second
, value
, array_idx
);
2595 void UniformBufferObjChunk::setVec2(const std::string
& name
, const Vec2f
& value
, UInt32 array_idx
)
2597 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2598 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2599 setVec2(iter
->second
, value
, array_idx
);
2602 void UniformBufferObjChunk::setVec2(const std::string
& name
, const Pnt2f
& value
, UInt32 array_idx
)
2604 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2605 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2606 setVec2(iter
->second
, value
, array_idx
);
2609 void UniformBufferObjChunk::setVec3(const std::string
& name
, const Vec3f
& value
, UInt32 array_idx
)
2611 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2612 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2613 setVec3(iter
->second
, value
, array_idx
);
2616 void UniformBufferObjChunk::setVec3(const std::string
& name
, const Pnt3f
& value
, UInt32 array_idx
)
2618 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2619 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2620 setVec3(iter
->second
, value
, array_idx
);
2623 void UniformBufferObjChunk::setVec3(const std::string
& name
, const Color3f
& value
, UInt32 array_idx
)
2625 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2626 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2627 setVec3(iter
->second
, value
, array_idx
);
2630 void UniformBufferObjChunk::setVec4(const std::string
& name
, const Vec4f
& value
, UInt32 array_idx
)
2632 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2633 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2634 setVec4(iter
->second
, value
, array_idx
);
2637 void UniformBufferObjChunk::setVec4(const std::string
& name
, const Pnt4f
& value
, UInt32 array_idx
)
2639 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2640 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2641 setVec4(iter
->second
, value
, array_idx
);
2644 void UniformBufferObjChunk::setVec4(const std::string
& name
, const Color4f
& value
, UInt32 array_idx
)
2646 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2647 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2648 setVec4(iter
->second
, value
, array_idx
);
2651 void UniformBufferObjChunk::setDVec2(const std::string
& name
, const Vec2d
& value
, UInt32 array_idx
)
2653 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2654 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2655 setDVec2(iter
->second
, value
, array_idx
);
2658 void UniformBufferObjChunk::setDVec2(const std::string
& name
, const Pnt2d
& value
, UInt32 array_idx
)
2660 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2661 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2662 setDVec2(iter
->second
, value
, array_idx
);
2665 void UniformBufferObjChunk::setDVec3(const std::string
& name
, const Vec3d
& value
, UInt32 array_idx
)
2667 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2668 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2669 setDVec3(iter
->second
, value
, array_idx
);
2672 void UniformBufferObjChunk::setDVec3(const std::string
& name
, const Pnt3d
& value
, UInt32 array_idx
)
2674 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2675 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2676 setDVec3(iter
->second
, value
, array_idx
);
2679 void UniformBufferObjChunk::setDVec4(const std::string
& name
, const Vec4d
& value
, UInt32 array_idx
)
2681 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2682 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2683 setDVec4(iter
->second
, value
, array_idx
);
2686 void UniformBufferObjChunk::setDVec4(const std::string
& name
, const Pnt4d
& value
, UInt32 array_idx
)
2688 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2689 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2690 setDVec4(iter
->second
, value
, array_idx
);
2693 void UniformBufferObjChunk::setIVec2(const std::string
& name
, const Vec2i
& value
, UInt32 array_idx
)
2695 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2696 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2697 setIVec2(iter
->second
, value
, array_idx
);
2700 void UniformBufferObjChunk::setIVec2(const std::string
& name
, const Pnt2i
& value
, UInt32 array_idx
)
2702 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2703 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2704 setIVec2(iter
->second
, value
, array_idx
);
2707 void UniformBufferObjChunk::setIVec3(const std::string
& name
, const Vec3i
& value
, UInt32 array_idx
)
2709 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2710 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2711 setIVec3(iter
->second
, value
, array_idx
);
2714 void UniformBufferObjChunk::setIVec3(const std::string& name, const Pnt3i& value, UInt32 array_idx)
2716 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2717 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2718 setIVec3(iter->second, value, array_idx);
2721 void UniformBufferObjChunk::setIVec4(const std::string
& name
, const Vec4i
& value
, UInt32 array_idx
)
2723 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2724 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2725 setIVec4(iter
->second
, value
, array_idx
);
2728 void UniformBufferObjChunk::setIVec4(const std::string& name, const Pnt4i& value, UInt32 array_idx)
2730 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2731 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2732 setIVec4(iter->second, value, array_idx);
2735 void UniformBufferObjChunk::setUVec2(const std::string
& name
, const Vec2u
& value
, UInt32 array_idx
)
2737 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2738 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2739 setUVec2(iter
->second
, value
, array_idx
);
2742 void UniformBufferObjChunk::setUVec2(const std::string& name, const Pnt2u& value, UInt32 array_idx)
2744 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2745 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2746 setUVec2(iter->second, value, array_idx);
2749 void UniformBufferObjChunk::setUVec3(const std::string
& name
, const Vec3u
& value
, UInt32 array_idx
)
2751 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2752 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2753 setUVec3(iter
->second
, value
, array_idx
);
2756 void UniformBufferObjChunk::setUVec3(const std::string& name, const Pnt3u& value, UInt32 array_idx)
2758 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2759 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2760 setUVec3(iter->second, value, array_idx);
2763 void UniformBufferObjChunk::setUVec4(const std::string
& name
, const Vec4u
& value
, UInt32 array_idx
)
2765 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2766 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2767 setUVec4(iter
->second
, value
, array_idx
);
2770 void UniformBufferObjChunk::setUVec4(const std::string& name, const Pnt4u& value, UInt32 array_idx)
2772 StringToUInt32Map::const_iterator iter = _sfNameToIndex.getValue().find(name);
2773 OSG_ASSERT(iter != _sfNameToIndex.getValue().end());
2774 setUVec4(iter->second, value, array_idx);
2777 void UniformBufferObjChunk::setBVec2(const std::string
& name
, const Vec2b
& value
, UInt32 array_idx
)
2779 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2780 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2781 setBVec2(iter
->second
, value
, array_idx
);
2784 void UniformBufferObjChunk::setBVec2(const std::string
& name
, const Pnt2b
& value
, UInt32 array_idx
)
2786 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2787 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2788 setBVec2(iter
->second
, value
, array_idx
);
2791 void UniformBufferObjChunk::setBVec3(const std::string
& name
, const Vec3b
& value
, UInt32 array_idx
)
2793 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2794 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2795 setBVec3(iter
->second
, value
, array_idx
);
2798 void UniformBufferObjChunk::setBVec3(const std::string
& name
, const Pnt3b
& value
, UInt32 array_idx
)
2800 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2801 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2802 setBVec3(iter
->second
, value
, array_idx
);
2805 void UniformBufferObjChunk::setBVec4(const std::string
& name
, const Vec4b
& value
, UInt32 array_idx
)
2807 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2808 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2809 setBVec4(iter
->second
, value
, array_idx
);
2812 void UniformBufferObjChunk::setBVec4(const std::string
& name
, const Pnt4b
& value
, UInt32 array_idx
)
2814 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2815 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2816 setBVec4(iter
->second
, value
, array_idx
);
2819 void UniformBufferObjChunk::setMat2(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2821 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2822 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2823 setMat2(iter
->second
, value
, array_idx
);
2826 void UniformBufferObjChunk::setMat3(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2828 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2829 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2830 setMat3(iter
->second
, value
, array_idx
);
2833 void UniformBufferObjChunk::setMat4(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2835 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2836 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2837 setMat4(iter
->second
, value
, array_idx
);
2840 void UniformBufferObjChunk::setDMat2(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2842 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2843 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2844 setDMat2(iter
->second
, value
, array_idx
);
2847 void UniformBufferObjChunk::setDMat3(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2849 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2850 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2851 setDMat3(iter
->second
, value
, array_idx
);
2854 void UniformBufferObjChunk::setDMat4(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2856 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2857 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2858 setDMat4(iter
->second
, value
, array_idx
);
2861 void UniformBufferObjChunk::setMat2x3(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2863 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2864 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2865 setMat2x3(iter
->second
, value
, array_idx
);
2868 void UniformBufferObjChunk::setMat3x2(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2870 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2871 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2872 setMat3x2(iter
->second
, value
, array_idx
);
2875 void UniformBufferObjChunk::setMat2x4(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2877 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2878 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2879 setMat2x4(iter
->second
, value
, array_idx
);
2882 void UniformBufferObjChunk::setMat4x2(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2884 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2885 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2886 setMat4x2(iter
->second
, value
, array_idx
);
2889 void UniformBufferObjChunk::setMat3x4(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2891 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2892 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2893 setMat3x4(iter
->second
, value
, array_idx
);
2896 void UniformBufferObjChunk::setMat4x3(const std::string
& name
, const Matrix4f
& value
, UInt32 array_idx
)
2898 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2899 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2900 setMat4x3(iter
->second
, value
, array_idx
);
2903 void UniformBufferObjChunk::setDMat2x3(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2905 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2906 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2907 setDMat2x3(iter
->second
, value
, array_idx
);
2910 void UniformBufferObjChunk::setDMat3x2(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2912 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2913 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2914 setDMat3x2(iter
->second
, value
, array_idx
);
2917 void UniformBufferObjChunk::setDMat2x4(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2919 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2920 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2921 setDMat2x4(iter
->second
, value
, array_idx
);
2924 void UniformBufferObjChunk::setDMat4x2(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2926 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2927 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2928 setDMat4x2(iter
->second
, value
, array_idx
);
2931 void UniformBufferObjChunk::setDMat3x4(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2933 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2934 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2935 setDMat3x4(iter
->second
, value
, array_idx
);
2938 void UniformBufferObjChunk::setDMat4x3(const std::string
& name
, const Matrix4d
& value
, UInt32 array_idx
)
2940 StringToUInt32Map::const_iterator iter
= _sfNameToIndex
.getValue().find(name
);
2941 OSG_ASSERT(iter
!= _sfNameToIndex
.getValue().end());
2942 setDMat4x3(iter
->second
, value
, array_idx
);
2945 /*------------------------------ Invariants ---------------------------------*/
2947 bool UniformBufferObjChunk::invariantOnStorageSize()
2949 std::size_t sz
= _mfFundamentalTypes
.size();
2950 if (sz
!= _mfMainTypes
.size() ||
2951 sz
!= _mfCardinality
.size() ||
2952 sz
!= _mfIndex
.size() ||
2953 sz
!= _mfNames
.size() ||
2954 sz
!= _sfNameToIndex
.getValue().size()