Added DisplaySettings::KeystoneHint flag that can be set via --keystone-on and --keystone-off command line parameters, and the OSG_KEYSTONE env var

This commit is contained in:
Robert Osfield 2013-05-10 17:59:07 +00:00
parent 5dd07e4d1c
commit 9402efe38e
3 changed files with 69 additions and 0 deletions

View File

@ -93,6 +93,11 @@ int main( int argc, char **argv )
osgViewer::Keystone::loadKeystoneFiles(ds); osgViewer::Keystone::loadKeystoneFiles(ds);
if (!ds->getKeystoneHint())
{
OSG_NOTICE<<"Keystone disabled"<<std::endl;
}
if (ds->getStereo()) if (ds->getStereo())
{ {
viewer.setUpViewForStereo(ds); viewer.setUpViewForStereo(ds);

View File

@ -285,6 +285,9 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
unsigned int getGLContextProfileMask() const { return _glContextProfileMask; } unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
bool getKeystoneHint() const { return _keystoneHint; }
typedef std::vector<std::string> FileNames; typedef std::vector<std::string> FileNames;
void setKeystoneFileNames(const FileNames& filenames) { _keystoneFileNames = filenames; } void setKeystoneFileNames(const FileNames& filenames) { _keystoneFileNames = filenames; }
FileNames& getKeystoneFileNames() { return _keystoneFileNames; } FileNames& getKeystoneFileNames() { return _keystoneFileNames; }
@ -363,6 +366,7 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
SwapMethod _swapMethod; SwapMethod _swapMethod;
bool _keystoneHint;
FileNames _keystoneFileNames; FileNames _keystoneFileNames;
Objects _keystones; Objects _keystones;

View File

@ -96,6 +96,10 @@ void DisplaySettings::setDisplaySettings(const DisplaySettings& vs)
_glContextFlags = vs._glContextFlags; _glContextFlags = vs._glContextFlags;
_glContextProfileMask = vs._glContextProfileMask; _glContextProfileMask = vs._glContextProfileMask;
_swapMethod = vs._swapMethod; _swapMethod = vs._swapMethod;
_keystoneHint = vs._keystoneHint;
_keystoneFileNames = vs._keystoneFileNames;
_keystones = vs._keystones;
} }
void DisplaySettings::merge(const DisplaySettings& vs) void DisplaySettings::merge(const DisplaySettings& vs)
@ -131,6 +135,28 @@ void DisplaySettings::merge(const DisplaySettings& vs)
// merge swap method to higher value // merge swap method to higher value
if( vs._swapMethod > _swapMethod ) if( vs._swapMethod > _swapMethod )
_swapMethod = vs._swapMethod; _swapMethod = vs._swapMethod;
_keystoneHint = _keystoneHint | vs._keystoneHint;
// insert any unique filenames into the local list
for(FileNames::const_iterator itr = vs._keystoneFileNames.begin();
itr != vs._keystoneFileNames.end();
++itr)
{
const std::string& filename = *itr;
FileNames::iterator found_itr = std::find(_keystoneFileNames.begin(), _keystoneFileNames.end(), filename);
if (found_itr == _keystoneFileNames.end()) _keystoneFileNames.push_back(filename);
}
// insert unique Keystone object into local list
for(Objects::const_iterator itr = vs._keystones.begin();
itr != vs._keystones.end();
++itr)
{
const osg::Object* object = itr->get();
Objects::iterator found_itr = std::find(_keystones.begin(), _keystones.end(), object);
if (found_itr == _keystones.end()) _keystones.push_back(const_cast<osg::Object*>(object));
}
} }
void DisplaySettings::setDefaults() void DisplaySettings::setDefaults()
@ -187,6 +213,8 @@ void DisplaySettings::setDefaults()
_glContextProfileMask = 0; _glContextProfileMask = 0;
_swapMethod = SWAP_DEFAULT; _swapMethod = SWAP_DEFAULT;
_keystoneHint = false;
} }
void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num) void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num)
@ -293,6 +321,9 @@ static ApplicationUsageProxy DisplaySetting_e27(ApplicationUsage::ENVIRONMENTAL_
"OSG_SWAP_METHOD <method>", "OSG_SWAP_METHOD <method>",
"DEFAULT | EXCHANGE | COPY | UNDEFINED. Select preferred swap method."); "DEFAULT | EXCHANGE | COPY | UNDEFINED. Select preferred swap method.");
static ApplicationUsageProxy DisplaySetting_e28(ApplicationUsage::ENVIRONMENTAL_VARIABLE, static ApplicationUsageProxy DisplaySetting_e28(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
"OSG_KEYSTONE ON | OFF",
"Specify the hint to whether the viewer should set up keystone correction.");
static ApplicationUsageProxy DisplaySetting_e29(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
"OSG_KEYSTONE_FILES <filename>[:filename]..", "OSG_KEYSTONE_FILES <filename>[:filename]..",
"Specify filenames of keystone parameter files. Under Windows use ; to deliminate files, otherwise use :"); "Specify filenames of keystone parameter files. Under Windows use ; to deliminate files, otherwise use :");
@ -589,6 +620,20 @@ void DisplaySettings::readEnvironmentalVariables()
} }
if( (ptr = getenv("OSG_KEYSTONE")) != 0)
{
if (strcmp(ptr,"OFF")==0)
{
_keystoneHint = false;
}
else
if (strcmp(ptr,"ON")==0)
{
_keystoneHint = true;
}
}
if ((ptr = getenv("OSG_KEYSTONE_FILES")) != 0) if ((ptr = getenv("OSG_KEYSTONE_FILES")) != 0)
{ {
#if defined(WIN32) && !defined(__CYGWIN__) #if defined(WIN32) && !defined(__CYGWIN__)
@ -638,6 +683,9 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
arguments.getApplicationUsage()->addCommandLineOption("--gl-flags <mask>","Set the hint of which GL flags projfile mask to use when creating graphics contexts."); arguments.getApplicationUsage()->addCommandLineOption("--gl-flags <mask>","Set the hint of which GL flags projfile mask to use when creating graphics contexts.");
arguments.getApplicationUsage()->addCommandLineOption("--gl-profile-mask <mask>","Set the hint of which GL context profile mask to use when creating graphics contexts."); arguments.getApplicationUsage()->addCommandLineOption("--gl-profile-mask <mask>","Set the hint of which GL context profile mask to use when creating graphics contexts.");
arguments.getApplicationUsage()->addCommandLineOption("--swap-method <method>","DEFAULT | EXCHANGE | COPY | UNDEFINED. Select preferred swap method."); arguments.getApplicationUsage()->addCommandLineOption("--swap-method <method>","DEFAULT | EXCHANGE | COPY | UNDEFINED. Select preferred swap method.");
arguments.getApplicationUsage()->addCommandLineOption("--keystone <filename>","Specify a keystone file to be used by the viewer for keystone correction.");
arguments.getApplicationUsage()->addCommandLineOption("--keystone-on","Set the keystone hint to true to tell the viewer to do keystone correction.");
arguments.getApplicationUsage()->addCommandLineOption("--keystone-off","Set the keystone hint to false.");
} }
std::string str; std::string str;
@ -694,6 +742,8 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
if (arguments.read("--keystone",str)) if (arguments.read("--keystone",str))
{ {
_keystoneHint = true;
if (!_keystoneFileNames.empty()) _keystoneFileNames.clear(); if (!_keystoneFileNames.empty()) _keystoneFileNames.clear();
_keystoneFileNames.push_back(str); _keystoneFileNames.push_back(str);
@ -703,6 +753,16 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
} }
} }
if (arguments.read("--keystone-on"))
{
_keystoneHint = true;
}
if (arguments.read("--keystone-off"))
{
_keystoneHint = false;
}
while(arguments.read("--cc")) while(arguments.read("--cc"))
{ {
_compileContextsHint = true; _compileContextsHint = true;