From c3108697dea79c188e5869fb04eb46e2c399cde5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 26 May 2020 13:55:48 +0200 Subject: [PATCH 1/2] Add support for showing environment variables provided by osg plugins --- include/osgDB/PluginQuery | 1 + include/osgDB/ReaderWriter | 7 +++++++ src/osgDB/PluginQuery.cpp | 15 +++++++++++++++ src/osgDB/ReaderWriter.cpp | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/include/osgDB/PluginQuery b/include/osgDB/PluginQuery index 9b1a27f64..800b587b1 100644 --- a/include/osgDB/PluginQuery +++ b/include/osgDB/PluginQuery @@ -40,6 +40,7 @@ class ReaderWriterInfo : public osg::Referenced ReaderWriter::FormatDescriptionMap protocols; ReaderWriter::FormatDescriptionMap extensions; ReaderWriter::FormatDescriptionMap options; + ReaderWriter::FormatDescriptionMap environment; ReaderWriter::Features features; protected: diff --git a/include/osgDB/ReaderWriter b/include/osgDB/ReaderWriter index 0bdffb032..4037434d0 100644 --- a/include/osgDB/ReaderWriter +++ b/include/osgDB/ReaderWriter @@ -63,6 +63,9 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object /** Return which list of file extensions supported by ReaderWriter. */ virtual const FormatDescriptionMap& supportedOptions() const { return _supportedOptions; } + /** Return which list of file environment variables supported by ReaderWriter. */ + virtual const FormatDescriptionMap& supportedEnvironment() const { return _supportedEnvironment; } + /** Return true if ReaderWriter accepts specified file extension.*/ virtual bool acceptsExtension(const std::string& /*extension*/) const; @@ -282,11 +285,15 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object * Please note, this should usually only be used internally by subclasses of ReaderWriter. */ void supportsOption(const std::string& opt, const std::string& description); + /** Specify env string as a supported environment string. */ + void supportsEnvironment(const std::string& opt, const std::string& description); + protected: FormatDescriptionMap _supportedProtocols; FormatDescriptionMap _supportedExtensions; FormatDescriptionMap _supportedOptions; + FormatDescriptionMap _supportedEnvironment; }; } diff --git a/src/osgDB/PluginQuery.cpp b/src/osgDB/PluginQuery.cpp index 8c649218e..de9fe0506 100644 --- a/src/osgDB/PluginQuery.cpp +++ b/src/osgDB/PluginQuery.cpp @@ -82,6 +82,7 @@ bool osgDB::queryPlugin(const std::string& fileName, ReaderWriterInfoList& infoL rwi->protocols = rw->supportedProtocols(); rwi->extensions = rw->supportedExtensions(); rwi->options = rw->supportedOptions(); + rwi->environment = rw->supportedEnvironment(); rwi->features = rw->supportedFeatures(); infoList.push_back(rwi.get()); @@ -153,6 +154,13 @@ bool osgDB::outputPluginDetails(std::ostream& out, const std::string& fileName) if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length(); } + for(fdm_itr = info.environment.begin(); + fdm_itr != info.environment.end(); + ++fdm_itr) + { + if (fdm_itr->first.length()>longestOptionLength) longestOptionLength = fdm_itr->first.length(); + } + unsigned int padLength = longestOptionLength+4; for(fdm_itr = info.protocols.begin(); @@ -175,6 +183,13 @@ bool osgDB::outputPluginDetails(std::ostream& out, const std::string& fileName) { out<<" options : "<first, padLength)<second<first, padLength)<second< Date: Tue, 26 May 2020 16:05:34 +0200 Subject: [PATCH 2/2] Use new method supportsEnvironment() from class ReaderWriter in client code --- src/osgPlugins/curl/ReaderWriterCURL.cpp | 11 ++++++----- src/osgPlugins/txp/ReaderWriterTXP.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/osgPlugins/curl/ReaderWriterCURL.cpp b/src/osgPlugins/curl/ReaderWriterCURL.cpp index 628da025a..ca03b638d 100644 --- a/src/osgPlugins/curl/ReaderWriterCURL.cpp +++ b/src/osgPlugins/curl/ReaderWriterCURL.cpp @@ -388,11 +388,12 @@ ReaderWriterCURL::ReaderWriterCURL() supportsExtension("curl","Pseudo file extension, used to select curl plugin."); supportsExtension("*","Passes all read files to other plugins to handle actual model loading."); - supportsOption("OSG_CURL_PROXY","Specify the http proxy."); - supportsOption("OSG_CURL_PROXYPORT","Specify the http proxy port."); - supportsOption("OSG_CURL_CONNECTTIMEOUT","Specify the connection timeout duration in seconds [default = 0 = not set]."); - supportsOption("OSG_CURL_TIMEOUT","Specify the timeout duration of the whole transfer in seconds [default = 0 = not set]."); - supportsOption("OSG_CURL_SSL_VERIFYPEER","Specify ssl verification peer [default = 1 = set]."); + + supportsEnvironment("OSG_CURL_PROXY","Specify the http proxy."); + supportsEnvironment("OSG_CURL_PROXYPORT","Specify the http proxy port."); + supportsEnvironment("OSG_CURL_CONNECTTIMEOUT","Specify the connection timeout duration in seconds [default = 0 = not set]."); + supportsEnvironment("OSG_CURL_TIMEOUT","Specify the timeout duration of the whole transfer in seconds [default = 0 = not set]."); + supportsEnvironment("OSG_CURL_SSL_VERIFYPEER","Specify ssl verification peer [default = 1 = set]."); } ReaderWriterCURL::~ReaderWriterCURL() diff --git a/src/osgPlugins/txp/ReaderWriterTXP.h b/src/osgPlugins/txp/ReaderWriterTXP.h index 406e9a2ef..7e7a8c398 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.h +++ b/src/osgPlugins/txp/ReaderWriterTXP.h @@ -57,6 +57,7 @@ public: ReaderWriterTXP() { supportsExtension("txp","Terrapage txp format"); + supportsEnvironment("OSG_TXP_DEFAULT_MAX_ANISOTROPY", "default value to use when setting up textures"); } virtual const char* className() const