1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
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 \*---------------------------------------------------------------------------*/
30 #include "OSGOSBShaderParameterRealElement.h"
32 #include "OSGOSBRootElement.h"
36 /*-------------------------------------------------------------------------*/
37 /* OSBShaderParameterRealElement */
38 /*-------------------------------------------------------------------------*/
40 /*! Reads the ShaderParameterReal from OpenSG 1.x and stores it's value
41 so OSBSHLChunkElement can add it as a uniform, see
42 OSBSHLChunkElement::postRead().
45 /*-------------------------------------------------------------------------*/
48 OSBElementRegistrationHelper
<OSBShaderParameterRealElement
>
49 OSBShaderParameterRealElement::_regHelper
=
50 OSBElementRegistrationHelper
<OSBShaderParameterRealElement
>(
51 "ShaderParameterReal");
53 /*-------------------------------------------------------------------------*/
56 OSBShaderParameterRealElement::OSBShaderParameterRealElement(
57 OSBRootElement
*root
) :
59 Inherited(root
, OSGOSBHeaderVersion200
),
64 /*-------------------------------------------------------------------------*/
67 OSBShaderParameterRealElement::~OSBShaderParameterRealElement(void)
71 /*-------------------------------------------------------------------------*/
75 OSBShaderParameterRealElement::read(const std::string
&typeName
)
77 OSG_OSB_LOG(("OSBShaderParameterRealElement::read: [%s]\n",
80 BinaryReadHandler
*rh
= editRoot()->getReadHandler();
85 rh
->getValue(ptrTypeId
);
86 rh
->getValue(version
);
88 OSG_OSB_LOG(("OSBShaderParameterRealElement::read: version: [%u]\n",
91 std::string fieldName
;
92 std::string fieldTypeName
;
94 PtrFieldListIt ptrFieldIt
;
96 while(readFieldHeader("", fieldName
, fieldTypeName
, fieldSize
))
98 if(fieldName
== "name")
100 _name
.copyFromBin(*rh
);
102 else if(fieldName
== "value")
104 _value
.copyFromBin(*rh
);
108 OSG_OSB_LOG(("Skipping [%d] bytes for field [%s]\n",
109 fieldSize
, fieldName
.c_str()));
114 // no container is created for this element, which means the root does
115 // not automatically insert it into the IdElemMap - do it manually
116 editRoot()->editIdElemMap().insert(
117 OSBRootElement::IdElemMap::value_type(getFCIdFile(), this));
121 OSBShaderParameterRealElement::postRead(void)
123 OSG_OSB_LOG(("OSBShaderParameterRealElement::postRead:\n"));
126 /*-------------------------------------------------------------------------*/
130 OSBShaderParameterRealElement::preWrite(FieldContainer
* const)
132 // This can not be called, ShaderParameterReal does not exist
137 OSBShaderParameterRealElement::write(void)
139 // This can not be called, ShaderParameterReal does not exist
143 /*-------------------------------------------------------------------------*/
147 OSBShaderParameterRealElement::getValue(void) const
149 return _value
.getValue();