|
Revision 7648, 2.4 kB
(checked in by robert, 5 years ago)
|
|
From Roland Smeenk, "Attached you will find a large set of small typo fixes (mainly in the comments)."
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | #include "Exception.h" |
|---|
| 16 | #include "DrawElementsUShort.h" |
|---|
| 17 | #include "PrimitiveSet.h" |
|---|
| 18 | #include <osg/Endian> |
|---|
| 19 | |
|---|
| 20 | using namespace ive; |
|---|
| 21 | |
|---|
| 22 | void DrawElementsUShort::write(DataOutputStream* out){ |
|---|
| 23 | |
|---|
| 24 | out->writeInt(IVEDRAWELEMENTSUSHORT); |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this); |
|---|
| 28 | if(prim){ |
|---|
| 29 | ((ive::PrimitiveSet*)(prim))->write(out); |
|---|
| 30 | } |
|---|
| 31 | else |
|---|
| 32 | throw Exception("DrawElementsUShort::write(): Could not cast this osg::DrawElementsUShort to an osg::PrimitiveSet."); |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | out->writeInt(size()); |
|---|
| 37 | out->writeCharArray((const char*)&front(), size() * SHORTSIZE); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | void DrawElementsUShort::read(DataInputStream* in){ |
|---|
| 41 | |
|---|
| 42 | int id = in->peekInt(); |
|---|
| 43 | if(id == IVEDRAWELEMENTSUSHORT){ |
|---|
| 44 | |
|---|
| 45 | id = in->readInt(); |
|---|
| 46 | |
|---|
| 47 | osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this); |
|---|
| 48 | if(prim){ |
|---|
| 49 | ((ive::PrimitiveSet*)(prim))->read(in); |
|---|
| 50 | } |
|---|
| 51 | else |
|---|
| 52 | throw Exception("DrawElementsUShort::read(): Could not cast this osg::DrawElementsUShort to an osg::PrimitiveSet."); |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | int size = in->readInt(); |
|---|
| 56 | resize(size); |
|---|
| 57 | in->readCharArray((char*)&front(), size * SHORTSIZE); |
|---|
| 58 | |
|---|
| 59 | if (in->_byteswap) |
|---|
| 60 | { |
|---|
| 61 | for (int i = 0 ; i < size ; i++ ) |
|---|
| 62 | { |
|---|
| 63 | osg::swapBytes((char *)&((*this)[i]),SHORTSIZE) ; |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | else{ |
|---|
| 68 | throw Exception("DrawElementsUShort::read(): Expected DrawElementsUShort identification."); |
|---|
| 69 | } |
|---|
| 70 | } |
|---|