Added handling of endian in DrawElementsUShort/UInt implementations
This commit is contained in:
@@ -54,6 +54,7 @@ void DrawElementsUByte::read(DataInputStream* in){
|
||||
int size = in->readInt();
|
||||
resize(size);
|
||||
in->readCharArray((char*)&front(), size * CHARSIZE);
|
||||
|
||||
}
|
||||
else{
|
||||
throw Exception("DrawElementsUByte::read(): Expected DrawElementsUByte identification.");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Exception.h"
|
||||
#include "DrawElementsUInt.h"
|
||||
#include "PrimitiveSet.h"
|
||||
#include <osg/Endian>
|
||||
|
||||
using namespace ive;
|
||||
|
||||
@@ -36,7 +37,8 @@ void DrawElementsUInt::write(DataOutputStream* out){
|
||||
out->writeCharArray((const char*)&front(), size() * INTSIZE);
|
||||
}
|
||||
|
||||
void DrawElementsUInt::read(DataInputStream* in){
|
||||
void DrawElementsUInt::read(DataInputStream* in)
|
||||
{
|
||||
// Read DrawElementsUInt's identification.
|
||||
int id = in->peekInt();
|
||||
if(id == IVEDRAWELEMENTSUINT){
|
||||
@@ -54,6 +56,14 @@ void DrawElementsUInt::read(DataInputStream* in){
|
||||
int size = in->readInt();
|
||||
resize(size);
|
||||
in->readCharArray((char*)&front(), size * INTSIZE);
|
||||
|
||||
if (in->_byteswap)
|
||||
{
|
||||
for (int i = 0 ; i < size ; i++ )
|
||||
{
|
||||
osg::swapBytes4((char*)&((*this)[i])) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("DrawElementsUInt::read(): Expected DrawElementsUInt identification.");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Exception.h"
|
||||
#include "DrawElementsUShort.h"
|
||||
#include "PrimitiveSet.h"
|
||||
#include <osg/Endian>
|
||||
|
||||
using namespace ive;
|
||||
|
||||
@@ -54,6 +55,14 @@ void DrawElementsUShort::read(DataInputStream* in){
|
||||
int size = in->readInt();
|
||||
resize(size);
|
||||
in->readCharArray((char*)&front(), size * SHORTSIZE);
|
||||
|
||||
if (in->_byteswap)
|
||||
{
|
||||
for (int i = 0 ; i < size ; i++ )
|
||||
{
|
||||
osg::swapBytes((char *)&((*this)[i]),SHORTSIZE) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw Exception("DrawElementsUShort::read(): Expected DrawElementsUShort identification.");
|
||||
|
||||
Reference in New Issue
Block a user