Moved from getenv to osg::getEnvVar usage

This commit is contained in:
Robert Osfield 2017-11-01 14:45:27 +00:00
parent e59ad87044
commit 3b85aa35df
3 changed files with 25 additions and 30 deletions

View File

@ -23,6 +23,7 @@
#include <osg/GL>
#include <osg/DeleteHandler>
#include <osg/ApplicationUsage>
#include <osg/EnvVar>
#include <vector>
#include <map>
@ -1314,10 +1315,10 @@ void GraphicsWindowWin32::init()
_applyWorkaroundForMultimonitorMultithreadNVidiaWin32Issues = true;
#endif
const char* str = getenv("OSG_WIN32_NV_MULTIMON_MULTITHREAD_WORKAROUND");
if (str)
std::string str;
if (osg::getEnvVar("OSG_WIN32_NV_MULTIMON_MULTITHREAD_WORKAROUND", str))
{
_applyWorkaroundForMultimonitorMultithreadNVidiaWin32Issues = (strcmp(str, "on")==0 || strcmp(str, "ON")==0 || strcmp(str, "On")==0 );
_applyWorkaroundForMultimonitorMultithreadNVidiaWin32Issues = (str=="on") || (str=="ON") || (str=="On");
}
}

View File

@ -18,6 +18,7 @@
#include <osgViewer/View>
#include <osgViewer/Renderer>
#include <osg/EnvVar>
#include <osg/io_utils>
#include <osg/TextureCubeMap>
@ -37,6 +38,7 @@ static osg::ApplicationUsageProxy ViewerBase_e2(osg::ApplicationUsage::ENVIRONME
static osg::ApplicationUsageProxy ViewerBase_e3(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_WINDOW x y width height","Set the default window dimensions that windows should open up on.");
static osg::ApplicationUsageProxy ViewerBase_e4(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_RUN_FRAME_SCHEME","Frame rate manage scheme that viewer run should use, ON_DEMAND or CONTINUOUS (default).");
static osg::ApplicationUsageProxy ViewerBase_e5(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_RUN_MAX_FRAME_RATE","Set the maximum number of frame as second that viewer run. 0.0 is default and disables an frame rate capping.");
static osg::ApplicationUsageProxy ViewerBase_e6(osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE,"OSG_RUN_FRAME_COUNT", "Set the maximum number of frames to run the viewer run method.");
using namespace osgViewer;
@ -68,18 +70,14 @@ void ViewerBase::viewerBaseInit()
_runFrameScheme = CONTINUOUS;
_runMaxFrameRate = 0.0f;
const char* str = getenv("OSG_RUN_FRAME_SCHEME");
if (str)
std::string str;
if (osg::getEnvVar("OSG_RUN_FRAME_SCHEME", str))
{
if (strcmp(str, "ON_DEMAND")==0) _runFrameScheme = ON_DEMAND;
else if (strcmp(str, "CONTINUOUS")==0) _runFrameScheme = CONTINUOUS;
if (str=="ON_DEMAND") _runFrameScheme = ON_DEMAND;
else if (str=="CONTINUOUS") _runFrameScheme = CONTINUOUS;
}
str = getenv("OSG_RUN_MAX_FRAME_RATE");
if (str)
{
_runMaxFrameRate = osg::asciiToDouble(str);
}
osg::getEnvVar("OSG_RUN_MAX_FRAME_RATE", _runMaxFrameRate);
_useConfigureAffinity = true;
}
@ -215,13 +213,14 @@ void ViewerBase::setThreadingModel(ThreadingModel threadingModel)
ViewerBase::ThreadingModel ViewerBase::suggestBestThreadingModel()
{
const char* str = getenv("OSG_THREADING");
if (str)
std::string str;
osg::getEnvVar("OSG_THREADING", str);
if (!str.empty())
{
if (strcmp(str,"SingleThreaded")==0) return SingleThreaded;
else if (strcmp(str,"CullDrawThreadPerContext")==0) return CullDrawThreadPerContext;
else if (strcmp(str,"DrawThreadPerContext")==0) return DrawThreadPerContext;
else if (strcmp(str,"CullThreadPerCameraDrawThreadPerContext")==0) return CullThreadPerCameraDrawThreadPerContext;
if (str=="SingleThreaded") return SingleThreaded;
else if (str=="CullDrawThreadPerContext") return CullDrawThreadPerContext;
else if (str=="DrawThreadPerContext") return DrawThreadPerContext;
else if (str=="CullThreadPerCameraDrawThreadPerContext") return CullThreadPerCameraDrawThreadPerContext;
}
Contexts contexts;
@ -690,10 +689,10 @@ int ViewerBase::run()
realize();
}
const char* run_frame_count_str = getenv("OSG_RUN_FRAME_COUNT");
unsigned int runTillFrameNumber = run_frame_count_str==0 ? osg::UNINITIALIZED_FRAME_NUMBER : atoi(run_frame_count_str);
unsigned int runTillFrameNumber = osg::UNINITIALIZED_FRAME_NUMBER;
osg::getEnvVar("OSG_RUN_FRAME_COUNT", runTillFrameNumber);
while(!done() && (run_frame_count_str==0 || getViewerFrameStamp()->getFrameNumber()<runTillFrameNumber))
while(!done() && (runTillFrameNumber==osg::UNINITIALIZED_FRAME_NUMBER || getViewerFrameStamp()->getFrameNumber()<runTillFrameNumber))
{
double minFrameTime = _runMaxFrameRate>0.0 ? 1.0/_runMaxFrameRate : 0.0;
osg::Timer_t startFrameTick = osg::Timer::instance()->tick();

View File

@ -25,6 +25,7 @@
#include <osg/TexMat>
#include <osg/Texture2D>
#include <osg/TextureRectangle>
#include <osg/EnvVar>
#include <osg/io_utils>
#include <osgViewer/Viewer>
@ -407,15 +408,9 @@ RecordCameraPathHandler::RecordCameraPathHandler(const std::string& filename, fl
_animStartTime(0),
_lastFrameTime(osg::Timer::instance()->tick())
{
const char* str = getenv("OSG_RECORD_CAMERA_PATH_FPS");
if (str)
{
_interval = 1.0f / osg::asciiToDouble(str);
}
else
{
_interval = 1.0f / fps;
}
osg::getEnvVar("OSG_RECORD_CAMERA_PATH_FPS", fps);
_interval = 1.0f / fps;
}
void RecordCameraPathHandler::getUsage(osg::ApplicationUsage &usage) const