1
#include <osg/VertexProgram>
2
#include <osgDB/ObjectWrapper>
3
#include <osgDB/InputStream>
4
#include <osgDB/OutputStream>
6
// _programLocalParameters
7
static bool checkLocalParameters( const osg::VertexProgram& vp )
9
return vp.getLocalParameters().size()>0;
12
static bool readLocalParameters( osgDB::InputStream& is, osg::VertexProgram& vp )
14
unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
15
for ( unsigned int i=0; i<size; ++i )
17
GLuint key; osg::Vec4d value;
19
vp.setProgramLocalParameter( key, value );
21
is >> osgDB::END_BRACKET;
25
static bool writeLocalParameters( osgDB::OutputStream& os, const osg::VertexProgram& vp )
27
const osg::VertexProgram::LocalParamList& params = vp.getLocalParameters();
28
os.writeSize(params.size()); os << osgDB::BEGIN_BRACKET << std::endl;
29
for ( osg::VertexProgram::LocalParamList::const_iterator itr=params.begin();
30
itr!=params.end(); ++itr )
32
os << itr->first << osg::Vec4d(itr->second) << std::endl;
34
os << osgDB::END_BRACKET << std::endl;
39
static bool checkMatrices( const osg::VertexProgram& vp )
41
return vp.getMatrices().size()>0;
44
static bool readMatrices( osgDB::InputStream& is, osg::VertexProgram& vp )
46
unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
47
for ( unsigned int i=0; i<size; ++i )
49
unsigned int key; osg::Matrixd value;
51
vp.setMatrix( key, value );
53
is >> osgDB::END_BRACKET;
57
static bool writeMatrices( osgDB::OutputStream& os, const osg::VertexProgram& vp )
59
const osg::VertexProgram::MatrixList& matrices = vp.getMatrices();
60
os.writeSize(matrices.size()); os << osgDB::BEGIN_BRACKET << std::endl;
61
for ( osg::VertexProgram::MatrixList::const_iterator itr=matrices.begin();
62
itr!=matrices.end(); ++itr )
64
os << (unsigned int)itr->first << osg::Matrixd(itr->second) << std::endl;
66
os << osgDB::END_BRACKET << std::endl;
70
REGISTER_OBJECT_WRAPPER( VertexProgram,
71
new osg::VertexProgram,
73
"osg::Object osg::StateAttribute osg::VertexProgram" )
75
ADD_STRING_SERIALIZER( VertexProgram, "" ); // _fragmentProgram
76
ADD_USER_SERIALIZER( LocalParameters ); // _programLocalParameters
77
ADD_USER_SERIALIZER( Matrices ); // _matrixList