Hi Robert,
Thanks for looking at this.
The changes don't currently work without modifying osgDB/InputStream.cpp in
some way, such as in my submission. Currently the
InputStream::readArrayImplementation is bypassing the BinaryInputIterator
methods, so its not doing the required byte swapping.
There's another related issue which I had addressed in my submission. Most
64-bit systems use 8-bytes in memory for a long. So writing or reading a 4 byte
long as defined in the osgb file format won't work - certainly not for
big-endian
systems. It needs something like this in BinaryInputIterator.h
virtual void writeLong( long l )
{
// On 64-bit systems a long may not be the same size as the file value
int32_t value=(int32_t)l;
_out->write( (char*)&value, osgDB::LONG_SIZE );
}
virtual void readLong( long& l )
{
// On 64-bit systems a long may not be the same size as the file value
int32_t value;
_in->read( (char*)&value, osgDB::LONG_SIZE );
if ( _byteSwap ) osg::swapBytes( (char*)&value, osgDB::LONG_SIZE );
l = (long)value;
}
similarily for writeULong and readULong. I'd supplied the int32_t and
unit32_t types
with some ifdef hackery in my submission. I don't think I have any models which
actually use long values - they all seem to be ints - so it's not a
problem for me,
just depends how comprehensive we want to be.
Regards
Colin McDonald
On Fri, Feb 24, 2012 at 11:43 AM, Robert Osfield
<[email protected]> wrote:
> Hi Colin and Rui,
>
> I have implemented the detection of the need for byte swapping into
> the osg plugin, using Rui's suggestion for checking for byte swapping
> of the OSG_HEADER_LOW and OSG_HEADER_HIGH values. The changes are
> listed below and checked into svn/trunk.
>
> These changes are far less extensive than Colin's original changes
> that forced a particular endian on the files which makes me feel
> rather more comfortable about them. Colin could you check that these
> changes actually work for your systems, I only have systems with the
> same endian here so I can't test the byte swapping.
>
> Cheers,
> Robert.
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org