Merged changes to DisplaySettings from Stephan Huber in prep for controlling the menu hiding behaviour under OSX.
Added new WindowSystemInterface::setDisplaySettings() method to provide a mechanism for passing settings onto the WindowSystemInterface so it can then set up the system appropriately. Added assignment of the DisplaySettings to the WindowSystemInterface in Viewer/ComppsiteViewer::realize().
This commit is contained in:
parent
b7b7186cf8
commit
c45f3aa4fb
@ -283,21 +283,29 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
|
||||
/** Get the hint of the profile mask to use in when creating graphic contexts.*/
|
||||
unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
|
||||
|
||||
|
||||
|
||||
|
||||
void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
|
||||
bool getKeystoneHint() const { return _keystoneHint; }
|
||||
|
||||
|
||||
typedef std::vector<std::string> FileNames;
|
||||
void setKeystoneFileNames(const FileNames& filenames) { _keystoneFileNames = filenames; }
|
||||
FileNames& getKeystoneFileNames() { return _keystoneFileNames; }
|
||||
const FileNames& getKeystoneFileNames() const { return _keystoneFileNames; }
|
||||
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::Object> > Objects;
|
||||
void setKeystones(const Objects& objects) { _keystones = objects; }
|
||||
Objects& getKeystones() { return _keystones; }
|
||||
const Objects& getKeystones() const { return _keystones; }
|
||||
|
||||
enum OSXMenubarBehavior {
|
||||
MENUBAR_AUTO_HIDE,
|
||||
MENUBAR_FORCE_HIDE,
|
||||
MENUBAR_FORCE_SHOW
|
||||
};
|
||||
|
||||
OSXMenubarBehavior getOSXMenubarBehavior() const { return _OSXMenubarBehavior; }
|
||||
void setOSXMenubarBehavior(OSXMenubarBehavior hint) { _OSXMenubarBehavior = hint; }
|
||||
|
||||
/** helper function for computing the left eye projection matrix.*/
|
||||
virtual osg::Matrixd computeLeftEyeProjectionImplementation(const osg::Matrixd& projection) const;
|
||||
@ -365,11 +373,13 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
||||
|
||||
SwapMethod _swapMethod;
|
||||
|
||||
|
||||
|
||||
bool _keystoneHint;
|
||||
FileNames _keystoneFileNames;
|
||||
Objects _keystones;
|
||||
|
||||
Objects _keystones;
|
||||
|
||||
OSXMenubarBehavior _OSXMenubarBehavior;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -176,6 +176,10 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
|
||||
virtual void enumerateScreenSettings(const ScreenIdentifier& screenIdentifier, ScreenSettingsList & resolutionList) = 0;
|
||||
|
||||
virtual void setDisplaySettings(DisplaySettings*) {}
|
||||
|
||||
virtual osg::DisplaySettings* getDisplaySettings() const { return 0; }
|
||||
|
||||
virtual GraphicsContext* createGraphicsContext(Traits* traits) = 0;
|
||||
|
||||
virtual ~WindowingSystemInterface() {}
|
||||
@ -206,6 +210,7 @@ class OSG_EXPORT GraphicsContext : public Object
|
||||
settings.refreshRate = refreshRate;
|
||||
return setScreenSettings(screenIdentifier, settings);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -100,6 +100,8 @@ void DisplaySettings::setDisplaySettings(const DisplaySettings& vs)
|
||||
_keystoneHint = vs._keystoneHint;
|
||||
_keystoneFileNames = vs._keystoneFileNames;
|
||||
_keystones = vs._keystones;
|
||||
|
||||
_OSXMenubarBehavior = vs._OSXMenubarBehavior;
|
||||
}
|
||||
|
||||
void DisplaySettings::merge(const DisplaySettings& vs)
|
||||
@ -157,6 +159,9 @@ void DisplaySettings::merge(const DisplaySettings& vs)
|
||||
Objects::iterator found_itr = std::find(_keystones.begin(), _keystones.end(), object);
|
||||
if (found_itr == _keystones.end()) _keystones.push_back(const_cast<osg::Object*>(object));
|
||||
}
|
||||
|
||||
if (vs._OSXMenubarBehavior > _OSXMenubarBehavior)
|
||||
_OSXMenubarBehavior = vs._OSXMenubarBehavior;
|
||||
}
|
||||
|
||||
void DisplaySettings::setDefaults()
|
||||
@ -215,6 +220,8 @@ void DisplaySettings::setDefaults()
|
||||
_swapMethod = SWAP_DEFAULT;
|
||||
|
||||
_keystoneHint = false;
|
||||
|
||||
_OSXMenubarBehavior = MENUBAR_AUTO_HIDE;
|
||||
}
|
||||
|
||||
void DisplaySettings::setMaxNumberOfGraphicsContexts(unsigned int num)
|
||||
@ -327,6 +334,9 @@ static ApplicationUsageProxy DisplaySetting_e29(ApplicationUsage::ENVIRONMENTAL_
|
||||
"OSG_KEYSTONE_FILES <filename>[:filename]..",
|
||||
"Specify filenames of keystone parameter files. Under Windows use ; to deliminate files, otherwise use :");
|
||||
|
||||
static ApplicationUsageProxy DisplaySetting_e30(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
|
||||
"OSG_MENUBAR_BEHAVIOR <behavior>",
|
||||
"OSX Only : Specify the behavior of the menubar (AUTO_HIDE, FORCE_HIDE, FORCE_SHOW)");
|
||||
|
||||
void DisplaySettings::readEnvironmentalVariables()
|
||||
{
|
||||
@ -658,6 +668,24 @@ void DisplaySettings::readEnvironmentalVariables()
|
||||
_keystoneFileNames.push_back(lastPath);
|
||||
}
|
||||
}
|
||||
|
||||
if( (ptr = getenv("OSG_MENUBAR_BEHAVIOR")) != 0)
|
||||
{
|
||||
if (strcmp(ptr,"AUTO_HIDE")==0)
|
||||
{
|
||||
_OSXMenubarBehavior = MENUBAR_AUTO_HIDE;
|
||||
}
|
||||
else
|
||||
if (strcmp(ptr,"FORCE_HIDE")==0)
|
||||
{
|
||||
_OSXMenubarBehavior = MENUBAR_FORCE_HIDE;
|
||||
}
|
||||
else
|
||||
if (strcmp(ptr,"FORCE_SHOW")==0)
|
||||
{
|
||||
_OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
@ -686,6 +714,7 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
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.");
|
||||
arguments.getApplicationUsage()->addCommandLineOption("--menubar-behavior <behavior>","Set the menubar behavior (AUTO_HIDE | FORCE_HIDE | FORCE_SHOW)");
|
||||
}
|
||||
|
||||
std::string str;
|
||||
@ -824,6 +853,12 @@ void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||
else if (str=="UNDEFINED") _swapMethod = SWAP_UNDEFINED;
|
||||
}
|
||||
|
||||
while(arguments.read("--menubar-behavior",str))
|
||||
{
|
||||
if (str=="AUTO_HIDE") _OSXMenubarBehavior = MENUBAR_AUTO_HIDE;
|
||||
else if (str=="FORCE_HIDE") _OSXMenubarBehavior = MENUBAR_FORCE_HIDE;
|
||||
else if (str=="FORCE_SHOW") _OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -585,8 +585,15 @@ void CompositeViewer::realize()
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int maxTexturePoolSize = osg::DisplaySettings::instance()->getMaxTexturePoolSize();
|
||||
unsigned int maxBufferObjectPoolSize = osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
|
||||
// get the display settings that will be active for this viewer
|
||||
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
|
||||
// pass on the display settings to the WindowSystemInterface.
|
||||
if (wsi && wsi->getDisplaySettings()==0) wsi->setDisplaySettings(ds);
|
||||
|
||||
unsigned int maxTexturePoolSize = ds->getMaxTexturePoolSize();
|
||||
unsigned int maxBufferObjectPoolSize = ds->getMaxBufferObjectPoolSize();
|
||||
|
||||
for(Contexts::iterator citr = contexts.begin();
|
||||
citr != contexts.end();
|
||||
|
@ -520,13 +520,15 @@ void Viewer::realize()
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int maxTexturePoolSize = osg::DisplaySettings::instance()->getMaxTexturePoolSize();
|
||||
if (_camera->getDisplaySettings()) maxTexturePoolSize = std::max(maxTexturePoolSize, _camera->getDisplaySettings()->getMaxTexturePoolSize());
|
||||
if (_displaySettings.valid()) maxTexturePoolSize = std::max(maxTexturePoolSize, _displaySettings->getMaxTexturePoolSize());
|
||||
// get the display settings that will be active for this viewer
|
||||
osg::DisplaySettings* ds = _displaySettings.valid() ? _displaySettings.get() : osg::DisplaySettings::instance().get();
|
||||
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
|
||||
|
||||
unsigned int maxBufferObjectPoolSize = osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
|
||||
if (_displaySettings.valid()) maxBufferObjectPoolSize = std::max(maxBufferObjectPoolSize, _displaySettings->getMaxBufferObjectPoolSize());
|
||||
if (_camera->getDisplaySettings()) maxBufferObjectPoolSize = std::max(maxBufferObjectPoolSize, _camera->getDisplaySettings()->getMaxBufferObjectPoolSize());
|
||||
// pass on the display settings to the WindowSystemInterface.
|
||||
if (wsi && wsi->getDisplaySettings()==0) wsi->setDisplaySettings(ds);
|
||||
|
||||
unsigned int maxTexturePoolSize = ds->getMaxTexturePoolSize();
|
||||
unsigned int maxBufferObjectPoolSize = ds->getMaxBufferObjectPoolSize();
|
||||
|
||||
for(Contexts::iterator citr = contexts.begin();
|
||||
citr != contexts.end();
|
||||
|
Loading…
Reference in New Issue
Block a user