root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/ImageSequence.cpp @ 13058

Revision 13058, 2.7 kB (checked in by robert, 4 hours ago)

From Alberto Luaces,"the current code uses the preprocessor for generating the plugin path in
a way that when CMAKE_INSTALL_PREFIX contains something along the lines
of

/usr/x86_64-linux-gnu/

it gets substituted as

/usr/x86_64-1-gnu/

that is, the string is preprocessed again, thereby making changes to
anything that matches any defined symbol, as "linux" in this example
(https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763816).

Quoting that path directly in CMake scripts solves that problem.
"

  • Property svn:eol-style set to native
Line 
1#include <osg/ImageSequence>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6// _fileNames
7static bool checkFileNames( const osg::ImageSequence& image )
8{
9    return image.getNumImageFiles()>0;
10}
11
12static bool readFileNames( osgDB::InputStream& is, osg::ImageSequence& image )
13{
14    unsigned int files = 0; is >> files >> is.BEGIN_BRACKET;
15    for ( unsigned int i=0; i<files; ++i )
16    {
17        std::string filename; is.readWrappedString( filename );
18        image.addImageFile( filename );
19    }
20    is >> is.END_BRACKET;
21    return true;
22}
23
24static bool writeFileNames( osgDB::OutputStream& os, const osg::ImageSequence& image )
25{
26    const osg::ImageSequence::FileNames& files = image.getFileNames();
27    os.writeSize(files.size()); os << os.BEGIN_BRACKET << std::endl;
28    for ( osg::ImageSequence::FileNames::const_iterator itr=files.begin();
29          itr!=files.end(); ++itr )
30    {
31        os.writeWrappedString( *itr );
32        os << std::endl;
33    }
34    os << os.END_BRACKET << std::endl;
35    return true;
36}
37
38// _images
39static bool checkImages( const osg::ImageSequence& image )
40{
41    return image.getNumImages()>0;
42}
43
44static bool readImages( osgDB::InputStream& is, osg::ImageSequence& image )
45{
46    unsigned int images = is.readSize(); is >> is.BEGIN_BRACKET;
47    for ( unsigned int i=0; i<images; ++i )
48    {
49        osg::Image* img = dynamic_cast<osg::Image*>( is.readObject() );
50        if ( img ) image.addImage( img );
51    }
52    is >> is.END_BRACKET;
53    return true;
54}
55
56static bool writeImages( osgDB::OutputStream& os, const osg::ImageSequence& image )
57{
58    const osg::ImageSequence::Images& images = image.getImages();
59    os.writeSize(images.size()); os << os.BEGIN_BRACKET << std::endl;
60    for ( osg::ImageSequence::Images::const_iterator itr=images.begin();
61          itr!=images.end(); ++itr )
62    {
63        os.writeObject( (*itr).get() );
64    }
65    os << os.END_BRACKET << std::endl;
66    return true;
67}
68
69REGISTER_OBJECT_WRAPPER( ImageSequence,
70                         new osg::ImageSequence,
71                         osg::ImageSequence,
72                         "osg::Object osg::Image osg::ImageStream osg::ImageSequence" )
73{
74    ADD_DOUBLE_SERIALIZER( ReferenceTime, DBL_MAX );  // _referenceTime
75    ADD_DOUBLE_SERIALIZER( TimeMultiplier, 1.0 );  // _timeMultiplier
76
77    BEGIN_ENUM_SERIALIZER( Mode, PRE_LOAD_ALL_IMAGES );
78        ADD_ENUM_VALUE( PRE_LOAD_ALL_IMAGES );
79        ADD_ENUM_VALUE( PAGE_AND_RETAIN_IMAGES );
80        ADD_ENUM_VALUE( PAGE_AND_DISCARD_USED_IMAGES );
81    END_ENUM_SERIALIZER();  // _mode
82
83    ADD_DOUBLE_SERIALIZER( Length, 1.0 );  // _length
84    ADD_USER_SERIALIZER( FileNames );  // _fileNames
85    ADD_USER_SERIALIZER( Images );  // _images
86}
Note: See TracBrowser for help on using the browser.