static bool writeShaders( osgDB::OutputStream& os, const osg::Program& attr ) { unsigned int size = attr.getNumShaders(); os.writeSize(size); os << os.BEGIN_BRACKET << std::endl; for ( unsigned int i=0; i<size; ++i ) { os << attr.getShader(i); } os << os.END_BRACKET << std::endl; return true; }
static bool writeFeedBackVaryingsName( osgDB::OutputStream& os, const osg::Program& attr ) { unsigned int size = attr.getNumTransformFeedBackVaryings(); os.writeSize(size); os << os.BEGIN_BRACKET << std::endl; for ( unsigned int i=0; i<size; ++i ) { os << attr.getTransformFeedBackVarying(i)<< std::endl; } os << os.END_BRACKET << std::endl; return true; }
static bool writeComputeGroups( osgDB::OutputStream& os, const osg::Program& attr ) { GLint numX = 0, numY = 0, numZ = 0; attr.getComputeGroups( numX, numY, numZ ); os << numX << numY << numZ << std::endl; return true; }
static bool readComputeGroups( osgDB::InputStream& is, osg::Program& attr ) { GLint numX = 0, numY = 0, numZ = 0; is >> numX >> numY >> numZ; attr.setComputeGroups( numX, numY, numZ ); return true; }
static bool readFeedBackMode( osgDB::InputStream& is, osg::Program& attr ) { unsigned int size ; is>>size; attr.setTransformFeedBackMode(size); return true; }
static bool readShaders( osgDB::InputStream& is, osg::Program& attr ) { unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET; for ( unsigned int i=0; i<size; ++i ) { osg::Shader* shader = dynamic_cast<osg::Shader*>( is.readObject() ); if ( shader ) attr.addShader( shader ); } is >> is.END_BRACKET; return true; }
static bool readShaders( osgDB::InputStream& is, osg::Program& attr ) { unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET; for ( unsigned int i=0; i<size; ++i ) { osg::ref_ptr<osg::Shader> shader = is.readObjectOfType<osg::Shader>(); if ( shader ) attr.addShader( shader ); } is >> is.END_BRACKET; return true; }
static bool readFeedBackVaryingsName( osgDB::InputStream& is, osg::Program& attr ) { unsigned int size = is.readSize(); is >> is.BEGIN_BRACKET; for ( unsigned int i=0; i<size; ++i ) { std::string str; is>> str; attr.addTransformFeedBackVarying(str); } is >> is.END_BRACKET; return true; }
// _shaderList static bool checkShaders( const osg::Program& attr ) { return attr.getNumShaders()>0; }
// _numGroupsX/Y/Z static bool checkComputeGroups( const osg::Program& attr ) { GLint numX = 0, numY = 0, numZ = 0; attr.getComputeGroups( numX, numY, numZ ); return numX>0 && numY>0 && numZ>0; }
static bool writeFeedBackMode( osgDB::OutputStream& os, const osg::Program& attr ) { os << attr.getTransformFeedBackMode()<< std::endl; return true; }
void bindAttribute(osg::Program& program, const AttributeAlias& alias) { program.addBindAttribLocation(alias.second, alias.first); }