root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osg/TextureCubeMap.cpp @ 10976

Revision 10976, 1.8 kB (checked in by robert, 5 years ago)

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

  • Property svn:executable set to *
Line 
1#include <osg/TextureCubeMap>
2#include <osgDB/ObjectWrapper>
3#include <osgDB/InputStream>
4#include <osgDB/OutputStream>
5
6#define FACE_IMAGE_FUNCTION( PROP, FACE ) \
7    static bool check##PROP( const osg::TextureCubeMap& tex ) { return true; } \
8    static bool read##PROP( osgDB::InputStream& is, osg::TextureCubeMap& tex ) { \
9        bool hasImage; is >> hasImage; \
10        if ( hasImage ) { \
11            is >> osgDB::BEGIN_BRACKET; tex.setImage(FACE, is.readImage()); \
12            is >> osgDB::END_BRACKET; \
13        } \
14        return true; \
15    } \
16    static bool write##PROP( osgDB::OutputStream& os, const osg::TextureCubeMap& tex ) { \
17        const osg::Image* image = tex.getImage(FACE); \
18        os << (image!=NULL); \
19        if ( image!=NULL ) { \
20            os << osgDB::BEGIN_BRACKET << std::endl << image; \
21            os << osgDB::END_BRACKET << std::endl; \
22        } \
23        return true; \
24    }
25
26FACE_IMAGE_FUNCTION( PosX, osg::TextureCubeMap::POSITIVE_X )
27FACE_IMAGE_FUNCTION( NegX, osg::TextureCubeMap::NEGATIVE_X )
28FACE_IMAGE_FUNCTION( PosY, osg::TextureCubeMap::POSITIVE_Y )
29FACE_IMAGE_FUNCTION( NegY, osg::TextureCubeMap::NEGATIVE_Y )
30FACE_IMAGE_FUNCTION( PosZ, osg::TextureCubeMap::POSITIVE_Z )
31FACE_IMAGE_FUNCTION( NegZ, osg::TextureCubeMap::NEGATIVE_Z )
32
33REGISTER_OBJECT_WRAPPER( TextureCubeMap,
34                         new osg::TextureCubeMap,
35                         osg::TextureCubeMap,
36                         "osg::Object osg::StateAttribute osg::Texture osg::TextureCubeMap" )
37{
38    ADD_USER_SERIALIZER( PosX );
39    ADD_USER_SERIALIZER( NegX );
40    ADD_USER_SERIALIZER( PosY );
41    ADD_USER_SERIALIZER( NegY );
42    ADD_USER_SERIALIZER( PosZ );
43    ADD_USER_SERIALIZER( NegZ );  // _images
44   
45    ADD_INT_SERIALIZER( TextureWidth, 0 );  // _textureWidth
46    ADD_INT_SERIALIZER( TextureHeight, 0 );  // _textureHeight
47}
Note: See TracBrowser for help on using the browser.