Hi Colin,
On 24 February 2012 14:36, Colin McDonald <[email protected]> wrote:
> 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.
I've just looked into this, InputStream has a _byteSwap variable but
this is never set anywhere so will always be zero,
BinaryStreamOperator now has a _byteSwap variable as well, which is
now set by my new code but this setting isn't passed on to
InputStream. Having two variables possible doing similar things is a
bit of recipe for confusion. Passing the BinaryStreamOperator onto
the InputStream might be sufficient, but it still a bit hacky, and
there is danger of double swaps going on if were not careful with who
takes responsibility for what.
>
> 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.
I've just had a look at these changes and have merged these into
snv/trunk with tweaks where necessary. If we are casting to int
perhaps were should also be writing out INT_SIZE rather LONG_SIZE...
Robert.
Robert.
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org