Hi Chris et. al,
I have had a bash at adding controls for setting the
NvOptimusEnablement. I don't have a Optimus laptop so have no way of
testing this feature. All I know is that it compiles under Linux so
far. I have checked below changes into svn/trunk. Could you test out
with your Optimus laptop?
Robert.
$ svn diff
]Index: include/osg/DisplaySettings
===================================================================
--- include/osg/DisplaySettings (revision 14603)
+++ include/osg/DisplaySettings (working copy)
@@ -293,7 +293,12 @@
/** Get the hint of the profile mask to use in when creating
graphic contexts.*/
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; }
bool getKeystoneHint() const { return _keystoneHint; }
Index: src/osg/DisplaySettings.cpp
===================================================================
--- src/osg/DisplaySettings.cpp (revision 14603)
+++ src/osg/DisplaySettings.cpp (working copy)
@@ -23,6 +23,22 @@
using namespace osg;
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()
{
static ref_ptr<DisplaySettings> s_displaySettings = new DisplaySettings;
@@ -29,6 +45,8 @@
return s_displaySettings;
}
+OSG_INIT_SINGLETON_PROXY(ProxyInitDisplaySettings, DisplaySettings::instance())
+
DisplaySettings::DisplaySettings(const DisplaySettings& vs):Referenced(true)
{
setDisplaySettings(vs);
@@ -334,10 +352,12 @@
static ApplicationUsageProxy
DisplaySetting_e29(ApplicationUsage::ENVIRONMENTAL_VARIABLE,
"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)");
+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()
{
@@ -704,6 +724,11 @@
_OSXMenubarBehavior = MENUBAR_FORCE_SHOW;
}
}
+
+ if( (ptr = getenv("OSG_NvOptimusEnablement")) != 0)
+ {
+ setNvOptimusEnablement(atoi(ptr));
+ }
}
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org