diff --git a/src/osgPlugins/osg/BinaryStreamOperator.h b/src/osgPlugins/osg/BinaryStreamOperator.h index b8f140141..7cfa1ca09 100644 --- a/src/osgPlugins/osg/BinaryStreamOperator.h +++ b/src/osgPlugins/osg/BinaryStreamOperator.h @@ -73,7 +73,7 @@ public: class BinaryInputIterator : public osgDB::InputIterator { public: - BinaryInputIterator( std::istream* istream ) : _byteSwap(0) { _in = istream; } + BinaryInputIterator( std::istream* istream, bool byteSwap ) : _byteSwap(byteSwap) { _in = istream; } virtual ~BinaryInputIterator() {} virtual bool isBinary() const { return true; } @@ -188,7 +188,7 @@ public: { readString( str ); } protected: - int _byteSwap; + bool _byteSwap; }; #endif diff --git a/src/osgPlugins/osg/ReaderWriterOSG2.cpp b/src/osgPlugins/osg/ReaderWriterOSG2.cpp index 542265e3f..990e31bba 100644 --- a/src/osgPlugins/osg/ReaderWriterOSG2.cpp +++ b/src/osgPlugins/osg/ReaderWriterOSG2.cpp @@ -26,6 +26,8 @@ using namespace osgDB; #define CATCH_EXCEPTION(s) \ if (s.getException()) return (s.getException()->getError() + " At " + s.getException()->getField()); +#define OSG_REVERSE(value) ( ((value & 0x000000ff)<<24) | ((value & 0x0000ff00)<<8) | ((value & 0x00ff0000)>>8) | ((value & 0xff000000)>>24) ) + InputIterator* readInputIterator( std::istream& fin, const Options* options ) { bool extensionIsAscii = false, extensionIsXML = false; @@ -43,8 +45,15 @@ InputIterator* readInputIterator( std::istream& fin, const Options* options ) fin.read( (char*)&headerHigh, INT_SIZE ); if ( headerLow==OSG_HEADER_LOW && headerHigh==OSG_HEADER_HIGH ) { - return new BinaryInputIterator(&fin); + OSG_INFO<<"Reading OpenSceneGraph binary file with the same endian as this computer."<