diff --git a/examples/osgshaderpipeline/osgshaderpipeline.cpp b/examples/osgshaderpipeline/osgshaderpipeline.cpp index 25124524c..e52a005a5 100644 --- a/examples/osgshaderpipeline/osgshaderpipeline.cpp +++ b/examples/osgshaderpipeline/osgshaderpipeline.cpp @@ -11,6 +11,7 @@ #include #include +#include #include @@ -137,8 +138,8 @@ int main(int argc, char** argv) } ACTIVE_TEXTURE->setElement(0, true); - //TEXTURE_GEN_MODE->setElement(0, 0); - TEXTURE_GEN_MODE->setElement(0, GL_SPHERE_MAP); + TEXTURE_GEN_MODE->setElement(0, 0); + //TEXTURE_GEN_MODE->setElement(0, GL_SPHERE_MAP); TEXTURE_GEN_S->setElement(0, true); TEXTURE_GEN_T->setElement(0, true); @@ -147,8 +148,69 @@ int main(int argc, char** argv) stateset->addUniform(TEXTURE_GEN_T.get()); stateset->addUniform(TEXTURE_GEN_MODE.get()); stateset->addUniform(TEXTURE_ENV_MODE.get()); + + + for(unsigned int i=0; iaddUniform(new osg::Uniform(sstream.str().c_str(), i)); + + + // fragment shader texture defines + sstream.str(""); + sstream<<"TEXTURE_VERT_DECLARE"<setDefine(textureVertDeclareDefine, sstream.str()); + + + sstream.str(""); + sstream<<"TEXTURE_VERT_BODY"<setDefine(textureVertBodyDefine, sstream.str()); + + + // fragment shader texture defines + sstream.str(""); + sstream<<"TEXTURE_FRAG_DECLARE"<setDefine(textureFragDeclareDefine, sstream.str()); + + + sstream.str(""); + sstream<<"TEXTURE_FRAG_BODY"<setDefine(textureFragBodyDefine, sstream.str()); + + } + } + osgDB::writeObjectFile(*stateset, "stateset.osgt"); + + viewer.realize(); return viewer.run(); diff --git a/src/osgWrappers/serializers/osg/StateSet.cpp b/src/osgWrappers/serializers/osg/StateSet.cpp index 8a94d1875..58bbba2cf 100644 --- a/src/osgWrappers/serializers/osg/StateSet.cpp +++ b/src/osgWrappers/serializers/osg/StateSet.cpp @@ -270,6 +270,50 @@ static bool writeUniformList( osgDB::OutputStream& os, const osg::StateSet& ss ) return true; } +// _defineList +static bool checkDefineList( const osg::StateSet& ss ) +{ + return ss.getDefineList().size()>0; +} + +static bool readDefineList( osgDB::InputStream& is, osg::StateSet& ss ) +{ + unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET; + for ( unsigned int i=0; i> is.PROPERTY("Value"); + int overrideValue = readValue( is ); + + ss.setDefine(defineName, defineValue, overrideValue); + + } + is >> is.END_BRACKET; + return true; +} + +static bool writeDefineList( osgDB::OutputStream& os, const osg::StateSet& ss ) +{ + const osg::StateSet::DefineList& df = ss.getDefineList(); + os.writeSize(df.size()); os << os.BEGIN_BRACKET << std::endl; + for ( osg::StateSet::DefineList::const_iterator itr=df.begin(); + itr!=df.end(); ++itr ) + { + os.writeWrappedString(itr->first); + os.writeWrappedString(itr->second.first); + os << os.PROPERTY("Value"); + writeValue(os, itr->second.second); + os << std::endl; + } + os << os.END_BRACKET << std::endl; + return true; +} + REGISTER_OBJECT_WRAPPER( StateSet, new osg::StateSet, osg::StateSet, @@ -295,4 +339,9 @@ REGISTER_OBJECT_WRAPPER( StateSet, ADD_BOOL_SERIALIZER( NestRenderBins, true ); // _nestRenderBins ADD_OBJECT_SERIALIZER( UpdateCallback, osg::StateSet::Callback, NULL ); // _updateCallback ADD_OBJECT_SERIALIZER( EventCallback, osg::StateSet::Callback, NULL ); // _eventCallback + + { + UPDATE_TO_VERSION_SCOPED( 146 ) + ADD_USER_SERIALIZER( DefineList ); // _defineList + } }