From a3314e35a7eb30855c96a7dcb328f8c62d04df96 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 25 Sep 2008 14:41:06 +0000 Subject: [PATCH] Added convinience methods for parse shader source files --- include/osgDB/ReadFile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/osgDB/ReadFile b/include/osgDB/ReadFile index f1c78902f..0fe1d030f 100644 --- a/include/osgDB/ReadFile +++ b/include/osgDB/ReadFile @@ -152,6 +152,30 @@ inline osg::Shader* readShaderFile(const std::string& filename) return readShaderFile(filename,Registry::instance()->getOptions()); } +/** Read an osg::Shader from file and set to specified shader type. + * Return valid osg::Shader on success, + * return NULL on failure. + * Use the Options object to control cache operations and file search paths in osgDB::Registry. + * The osgDB::Registry is used to load the appropriate ReaderWriter plugin + * for the filename extension, and this plugin then handles the request + * to read the specified file.*/ +inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& filename,const ReaderWriter::Options* options) +{ + osg::Shader* shader = readShaderFile(filename, options); + if (shader && type != osg::Shader::UNDEFINED) shader->setType(type); + return shader; +} + +/** Read an osg::Shader from file and set to specified shader type + * Return valid osg::Shader on success, + * return NULL on failure. + * The osgDB::Registry is used to load the appropriate ReaderWriter plugin + * for the filename extension, and this plugin then handles the request + * to read the specified file.*/ +inline osg::Shader* readShaderFile(osg::Shader::Type type, const std::string& filename) +{ + return readShaderFile(type, filename,Registry::instance()->getOptions()); +} /** Read an osg::Object from file. * Return an assigned osg::ref_ptr on success,