Added DisplaySettings::s/getNvOptimusEnablement() and OSG_NvOptimusEnablement env var control to control the setting of the NvOptimusEnablement variable
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14614 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
075e874c85
commit
6f9ac83693
@ -293,6 +293,11 @@ class OSG_EXPORT DisplaySettings : public osg::Referenced
|
|||||||
/** Get the hint of the profile mask to use in when creating graphic contexts.*/
|
/** Get the hint of the profile mask to use in when creating graphic contexts.*/
|
||||||
unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
|
unsigned int getGLContextProfileMask() const { return _glContextProfileMask; }
|
||||||
|
|
||||||
|
/** Set the NvOptimusEnablement value. Default can be set using OSG_NvOptimusEnablement env var.*/
|
||||||
|
void setNvOptimusEnablement(int value);
|
||||||
|
/** Get the NvOptimusEnablement value. */
|
||||||
|
int getNvOptimusEnablement() const;
|
||||||
|
|
||||||
|
|
||||||
void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
|
void setKeystoneHint(bool enabled) { _keystoneHint = enabled; }
|
||||||
bool getKeystoneHint() const { return _keystoneHint; }
|
bool getKeystoneHint() const { return _keystoneHint; }
|
||||||
|
@ -23,12 +23,30 @@
|
|||||||
using namespace osg;
|
using namespace osg;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||||
|
extern "C" { _declspec(dllexport) DWORD NvOptimusEnablement=0x00000001; }
|
||||||
|
#else
|
||||||
|
extern "C" { int NvOptimusEnablement=0x00000001; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void DisplaySettings::setNvOptimusEnablement(int value)
|
||||||
|
{
|
||||||
|
NvOptimusEnablement = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DisplaySettings::getNvOptimusEnablement() const
|
||||||
|
{
|
||||||
|
return NvOptimusEnablement;
|
||||||
|
}
|
||||||
|
|
||||||
ref_ptr<DisplaySettings>& DisplaySettings::instance()
|
ref_ptr<DisplaySettings>& DisplaySettings::instance()
|
||||||
{
|
{
|
||||||
static ref_ptr<DisplaySettings> s_displaySettings = new DisplaySettings;
|
static ref_ptr<DisplaySettings> s_displaySettings = new DisplaySettings;
|
||||||
return s_displaySettings;
|
return s_displaySettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSG_INIT_SINGLETON_PROXY(ProxyInitDisplaySettings, DisplaySettings::instance())
|
||||||
|
|
||||||
DisplaySettings::DisplaySettings(const DisplaySettings& vs):Referenced(true)
|
DisplaySettings::DisplaySettings(const DisplaySettings& vs):Referenced(true)
|
||||||
{
|
{
|
||||||
setDisplaySettings(vs);
|
setDisplaySettings(vs);
|
||||||
@ -334,10 +352,12 @@ static ApplicationUsageProxy DisplaySetting_e28(ApplicationUsage::ENVIRONMENTAL_
|
|||||||
static ApplicationUsageProxy DisplaySetting_e29(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
|
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 :");
|
||||||
|
|
||||||
static ApplicationUsageProxy DisplaySetting_e30(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
|
static ApplicationUsageProxy DisplaySetting_e30(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
|
||||||
"OSG_MENUBAR_BEHAVIOR <behavior>",
|
"OSG_MENUBAR_BEHAVIOR <behavior>",
|
||||||
"OSX Only : Specify the behavior of the menubar (AUTO_HIDE, FORCE_HIDE, FORCE_SHOW)");
|
"OSX Only : Specify the behavior of the menubar (AUTO_HIDE, FORCE_HIDE, FORCE_SHOW)");
|
||||||
|
static ApplicationUsageProxy DisplaySetting_e31(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
|
||||||
|
"OSG_NvOptimusEnablement <value>",
|
||||||
|
"Set the hint to NvOptimus of whether to enable it or not, set 1 to enable, 0 to disable");
|
||||||
|
|
||||||
void DisplaySettings::readEnvironmentalVariables()
|
void DisplaySettings::readEnvironmentalVariables()
|
||||||
{
|
{
|
||||||
@ -704,6 +724,11 @@ void DisplaySettings::readEnvironmentalVariables()
|
|||||||
_OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
|
_OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( (ptr = getenv("OSG_NvOptimusEnablement")) != 0)
|
||||||
|
{
|
||||||
|
setNvOptimusEnablement(atoi(ptr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
void DisplaySettings::readCommandLine(ArgumentParser& arguments)
|
||||||
|
Loading…
Reference in New Issue
Block a user