~ubuntu-branches/debian/experimental/openscenegraph/experimental

« back to all changes in this revision

Viewing changes to OpenSceneGraph/src/osgWrappers/serializers/osg/VertexProgram.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Luaces
  • Date: 2011-01-29 11:36:29 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110129113629-qisrm2kdqlurc7t3
Tags: 2.9.11-1
* Removed bug-555869-ftbfs_with_binutils_gold.dpatch since upstream has
  already taken care of the issue.
* Removed bug-528229.dpatch since the pkgconfig files are now also split
  in upstream.
* Removed explicit dependency on GLU.
* Upstream no longer includes osgIntrospection (Closes: #592420).
* Disabled zip plugin as its implementation stores an embedded copy of
  zlib.
* Enabled Qt support. Thanks James Goppert.
* Enabled SVG and PDF plugins. Thanks James Goppert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <osg/VertexProgram>
 
2
#include <osgDB/ObjectWrapper>
 
3
#include <osgDB/InputStream>
 
4
#include <osgDB/OutputStream>
 
5
 
 
6
// _programLocalParameters
 
7
static bool checkLocalParameters( const osg::VertexProgram& vp )
 
8
{
 
9
    return vp.getLocalParameters().size()>0;
 
10
}
 
11
 
 
12
static bool readLocalParameters( osgDB::InputStream& is, osg::VertexProgram& vp )
 
13
{
 
14
    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
 
15
    for ( unsigned int i=0; i<size; ++i )
 
16
    {
 
17
        GLuint key; osg::Vec4d value;
 
18
        is >> key >> value;
 
19
        vp.setProgramLocalParameter( key, value );
 
20
    }
 
21
    is >> osgDB::END_BRACKET;
 
22
    return true;
 
23
}
 
24
 
 
25
static bool writeLocalParameters( osgDB::OutputStream& os, const osg::VertexProgram& vp )
 
26
{
 
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 )
 
31
    {
 
32
        os << itr->first << osg::Vec4d(itr->second) << std::endl;
 
33
    }
 
34
    os << osgDB::END_BRACKET << std::endl;
 
35
    return true;
 
36
}
 
37
 
 
38
// _matrixList
 
39
static bool checkMatrices( const osg::VertexProgram& vp )
 
40
{
 
41
    return vp.getMatrices().size()>0;
 
42
}
 
43
 
 
44
static bool readMatrices( osgDB::InputStream& is, osg::VertexProgram& vp )
 
45
{
 
46
    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
 
47
    for ( unsigned int i=0; i<size; ++i )
 
48
    {
 
49
        unsigned int key; osg::Matrixd value;
 
50
        is >> key >> value;
 
51
        vp.setMatrix( key, value );
 
52
    }
 
53
    is >> osgDB::END_BRACKET;
 
54
    return true;
 
55
}
 
56
 
 
57
static bool writeMatrices( osgDB::OutputStream& os, const osg::VertexProgram& vp )
 
58
{
 
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 )
 
63
    {
 
64
        os << (unsigned int)itr->first << osg::Matrixd(itr->second) << std::endl;
 
65
    }
 
66
    os << osgDB::END_BRACKET << std::endl;
 
67
    return true;
 
68
}
 
69
 
 
70
REGISTER_OBJECT_WRAPPER( VertexProgram,
 
71
                         new osg::VertexProgram,
 
72
                         osg::VertexProgram,
 
73
                         "osg::Object osg::StateAttribute osg::VertexProgram" )
 
74
{
 
75
    ADD_STRING_SERIALIZER( VertexProgram, "" );  // _fragmentProgram
 
76
    ADD_USER_SERIALIZER( LocalParameters );  // _programLocalParameters
 
77
    ADD_USER_SERIALIZER( Matrices );  // _matrixList
 
78
}