From Wang Rui, new native binary/ascii format infrastructure and wrappers.

From Robert Osfield, refactor of Wang Rui's original osg2 into 3 parts - parts placed into osgDB, the ReaderWriter placed into src/osg/Plugin/osg and wrappers into src/osgWrappers/serializers/osg
This commit is contained in:
Robert Osfield
2010-01-20 20:13:33 +00:00
parent 9806aebaf3
commit 219696f1ee
122 changed files with 8286 additions and 58 deletions

View File

@@ -0,0 +1,44 @@
#include <osg/Texture2DArray>
#include <osgDB/ObjectWrapper>
#include <osgDB/InputStream>
#include <osgDB/OutputStream>
static bool checkImages( const osg::Texture2DArray& tex )
{
return tex.getNumImages()>0;
}
static bool readImages( osgDB::InputStream& is, osg::Texture2DArray& tex )
{
unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET;
for ( unsigned int i=0; i<size; ++i )
{
osg::Image* image = is.readImage();
if ( image ) tex.setImage( i, image );
}
is >> osgDB::END_BRACKET;
return true;
}
static bool writeImages( osgDB::OutputStream& os, const osg::Texture2DArray& tex )
{
unsigned int size = tex.getNumImages();
os << size << osgDB::BEGIN_BRACKET << std::endl;
for ( unsigned int i=0; i<size; ++i )
{
os << tex.getImage(i);
}
os << osgDB::END_BRACKET << std::endl;
return true;
}
REGISTER_OBJECT_WRAPPER( Texture2DArray,
new osg::Texture2DArray,
osg::Texture2DArray,
"osg::Object osg::StateAttribute osg::Texture osg::Texture2DArray" )
{
ADD_USER_SERIALIZER( Images ); // _images
ADD_INT_SERIALIZER( TextureWidth, 0 ); // _textureWidth
ADD_INT_SERIALIZER( TextureHeight, 0 ); // _textureHeight
ADD_INT_SERIALIZER( TextureDepth, 0 ); // _textureDepth
}