Added handling of endian in DrawElementsUShort/UInt implementations

This commit is contained in:
Robert Osfield
2004-11-01 10:04:40 +00:00
parent 4065c551ef
commit 41823a115d
3 changed files with 21 additions and 1 deletions

View File

@@ -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.");

View File

@@ -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.");

View File

@@ -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.");