virtual ReadResult readShader(const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(file); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; std::string fileName = osgDB::findDataFile( file, options ); if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; osgDB::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary); if(!istream) return ReadResult::FILE_NOT_HANDLED; ReadResult rr = readShader(istream, options); if(rr.validShader()) { osg::Shader* shader = rr.getShader(); shader->setFileName(file); if (shader->getType() == osg::Shader::UNDEFINED) { // set type based on filename extension, where possible if (ext == "frag") shader->setType(osg::Shader::FRAGMENT); if (ext == "vert") shader->setType(osg::Shader::VERTEX); if (ext == "geom") shader->setType(osg::Shader::GEOMETRY); if (ext == "tctrl") shader->setType(osg::Shader::TESSCONTROL); if (ext == "teval") shader->setType(osg::Shader::TESSEVALUATION); if (ext == "compute") shader->setType(osg::Shader::COMPUTE); } } return rr; }
virtual ReadResult readShader(const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(file); if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; std::string fileName = osgDB::findDataFile( file, options ); if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; std::ifstream istream(fileName.c_str(), std::ios::in | std::ios::binary); if(!istream) return ReadResult::FILE_NOT_HANDLED; ReadResult rr = readShader(istream, options); if(rr.validShader()) rr.getShader()->setFileName(file); return rr; }