|
Revision 10600, 2.3 kB
(checked in by robert, 4 years ago)
|
|
Introduced new BufferObject? design + implementation in preperation of implementing a pool system for buffer objects
|
-
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 "DrawElementsUInt.h" |
|---|
| 17 | #include "PrimitiveSet.h" |
|---|
| 18 | #include <osg/Endian> |
|---|
| 19 | |
|---|
| 20 | using namespace ive; |
|---|
| 21 | |
|---|
| 22 | void DrawElementsUInt::write(DataOutputStream* out){ |
|---|
| 23 | |
|---|
| 24 | out->writeInt(IVEDRAWELEMENTSUINT); |
|---|
| 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("DrawElementsUInt::write(): Could not cast this osg::DrawElementsUInt to an osg::PrimitiveSet."); |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | out->writeInt(size()); |
|---|
| 37 | if (size()!=0) out->writeCharArray((const char*)&front(), size() * INTSIZE); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | void DrawElementsUInt::read(DataInputStream* in) |
|---|
| 41 | { |
|---|
| 42 | |
|---|
| 43 | int id = in->peekInt(); |
|---|
| 44 | if(id == IVEDRAWELEMENTSUINT){ |
|---|
| 45 | |
|---|
| 46 | id = in->readInt(); |
|---|
| 47 | |
|---|
| 48 | osg::PrimitiveSet* prim = dynamic_cast<osg::PrimitiveSet*>(this); |
|---|
| 49 | if(prim){ |
|---|
| 50 | ((ive::PrimitiveSet*)(prim))->read(in); |
|---|
| 51 | } |
|---|
| 52 | else |
|---|
| 53 | throw Exception("DrawElementsUInt::read(): Could not cast this osg::DrawElementsUInt to an osg::PrimitiveSet."); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | int size = in->readInt(); |
|---|
| 57 | resize(size); |
|---|
| 58 | if (size!=0) in->readCharArray((char*)&front(), size * INTSIZE); |
|---|
| 59 | |
|---|
| 60 | if (in->_byteswap) |
|---|
| 61 | { |
|---|
| 62 | for (int i = 0 ; i < size ; i++ ) |
|---|
| 63 | { |
|---|
| 64 | osg::swapBytes4((char*)&((*this)[i])) ; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | } |
|---|
| 68 | else{ |
|---|
| 69 | throw Exception("DrawElementsUInt::read(): Expected DrawElementsUInt identification."); |
|---|
| 70 | } |
|---|
| 71 | } |
|---|