Improved the handling of endian swap of osg::Array

This commit is contained in:
Robert Osfield
2012-02-29 10:22:56 +00:00
parent 7bcf5e3b36
commit 9c5774defb
5 changed files with 54 additions and 40 deletions

View File

@@ -16,6 +16,28 @@
using namespace osgDB;
void InputIterator::readComponentArray( char* s, unsigned int numElements, unsigned int numComponentsPerElements, unsigned int componentSizeInBytes)
{
unsigned int size = numElements * numComponentsPerElements * componentSizeInBytes;
if ( size>0 )
{
readCharArray( s, size);
if (_byteSwap && componentSizeInBytes>1)
{
char* ptr = s;
for(unsigned int i=0; i<numElements; ++i)
{
for(unsigned int j=0; j<numComponentsPerElements; ++j)
{
osg::swapBytes( ptr, componentSizeInBytes );
ptr += componentSizeInBytes;
}
}
}
}
}
void InputIterator::throwException( const std::string& msg )
{
if (_inputStream) _inputStream->throwException(msg);