Moved getenv usage across to safer osg::getEnvVar() usage
This commit is contained in:
parent
0e7e06349e
commit
338b0e2b7b
@ -17,6 +17,7 @@
|
|||||||
#include <osg/Config>
|
#include <osg/Config>
|
||||||
|
|
||||||
#ifdef OSG_ENVVAR_SUPPORTED
|
#ifdef OSG_ENVVAR_SUPPORTED
|
||||||
|
#include <stdlib.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -29,6 +30,15 @@ inline unsigned int getClampedLength(const char* str, unsigned int maxNumChars=4
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string getEnvVar(const char* name)
|
||||||
|
{
|
||||||
|
std::string value;
|
||||||
|
const char* ptr = getenv(name);
|
||||||
|
if (ptr) value.assign(ptr, getClampedLength(ptr));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool getEnvVar(const char* name, T& value)
|
inline bool getEnvVar(const char* name, T& value)
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
#include <osg/Math>
|
#include <osg/Math>
|
||||||
#include <osg/buffered_value>
|
#include <osg/buffered_value>
|
||||||
|
#include <osg/EnvVar>
|
||||||
|
#include <osg/ApplicationUsage>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -65,6 +67,9 @@ static osg::buffered_object<ExtensionSet> s_gluExtensionSetList;
|
|||||||
static osg::buffered_object<std::string> s_gluRendererList;
|
static osg::buffered_object<std::string> s_gluRendererList;
|
||||||
static osg::buffered_value<int> s_gluInitializedList;
|
static osg::buffered_value<int> s_gluInitializedList;
|
||||||
|
|
||||||
|
static ApplicationUsageProxy GLEXtension_e0(ApplicationUsage::ENVIRONMENTAL_VARIABLE, "OSG_GL_EXTENSION_DISABLE <value>", "Use space deliminarted list of GL extensions to disable associated GL extensions");
|
||||||
|
static ApplicationUsageProxy GLEXtension_e1(ApplicationUsage::ENVIRONMENTAL_VARIABLE, "OSG_MAX_TEXTURE_SIZE <value>", "Clamp the maximum GL texture size to specified value.");
|
||||||
|
|
||||||
float osg::getGLVersionNumber()
|
float osg::getGLVersionNumber()
|
||||||
{
|
{
|
||||||
// needs to be extended to do proper things with subversions like 1.5.1, etc.
|
// needs to be extended to do proper things with subversions like 1.5.1, etc.
|
||||||
@ -308,8 +313,7 @@ void osg::setGLExtensionDisableString(const std::string& disableString)
|
|||||||
|
|
||||||
std::string& osg::getGLExtensionDisableString()
|
std::string& osg::getGLExtensionDisableString()
|
||||||
{
|
{
|
||||||
static const char* envVar = getenv("OSG_GL_EXTENSION_DISABLE");
|
static std::string s_GLExtensionDisableString(getEnvVar("OSG_GL_EXTENSION_DISABLE"));
|
||||||
static std::string s_GLExtensionDisableString(envVar?envVar:"Nothing defined");
|
|
||||||
|
|
||||||
return s_GLExtensionDisableString;
|
return s_GLExtensionDisableString;
|
||||||
}
|
}
|
||||||
@ -901,16 +905,13 @@ GLExtensions::GLExtensions(unsigned int in_contextID):
|
|||||||
if (validContext) glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxTextureSize);
|
if (validContext) glGetIntegerv(GL_MAX_TEXTURE_SIZE,&maxTextureSize);
|
||||||
|
|
||||||
char *ptr;
|
char *ptr;
|
||||||
if( (ptr = getenv("OSG_MAX_TEXTURE_SIZE")) != 0)
|
|
||||||
{
|
|
||||||
GLint osg_max_size = atoi(ptr);
|
|
||||||
|
|
||||||
if (osg_max_size<maxTextureSize)
|
GLint osg_max_size = maxTextureSize;
|
||||||
{
|
|
||||||
|
|
||||||
|
if( (getEnvVar("OSG_MAX_TEXTURE_SIZE", osg_max_size)) && osg_max_size<maxTextureSize)
|
||||||
|
{
|
||||||
maxTextureSize = osg_max_size;
|
maxTextureSize = osg_max_size;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
setGLExtensionFuncPtr(glTexStorage2D,"glTexStorage2D","glTexStorage2DARB", validContext);
|
setGLExtensionFuncPtr(glTexStorage2D,"glTexStorage2D","glTexStorage2DARB", validContext);
|
||||||
setGLExtensionFuncPtr(glCompressedTexImage2D,"glCompressedTexImage2D","glCompressedTexImage2DARB", validContext);
|
setGLExtensionFuncPtr(glCompressedTexImage2D,"glCompressedTexImage2D","glCompressedTexImage2DARB", validContext);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <osg/View>
|
#include <osg/View>
|
||||||
#include <osg/GLObjects>
|
#include <osg/GLObjects>
|
||||||
#include <osg/ContextData>
|
#include <osg/ContextData>
|
||||||
|
#include <osg/EnvVar>
|
||||||
|
|
||||||
#include <osg/FrameBufferObject>
|
#include <osg/FrameBufferObject>
|
||||||
#include <osg/Program>
|
#include <osg/Program>
|
||||||
@ -153,10 +154,10 @@ std::string GraphicsContext::ScreenIdentifier::displayName() const
|
|||||||
|
|
||||||
void GraphicsContext::ScreenIdentifier::readDISPLAY()
|
void GraphicsContext::ScreenIdentifier::readDISPLAY()
|
||||||
{
|
{
|
||||||
const char* ptr = 0;
|
std::string str;
|
||||||
if ((ptr=getenv("DISPLAY")) != 0)
|
if (getEnvVar("DISPLAY", str))
|
||||||
{
|
{
|
||||||
setScreenIdentifier(ptr);
|
setScreenIdentifier(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <osg/Notify>
|
#include <osg/Notify>
|
||||||
#include <osg/ApplicationUsage>
|
#include <osg/ApplicationUsage>
|
||||||
|
#include <osg/EnvVar>
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -140,9 +141,8 @@ struct NotifySingleton
|
|||||||
|
|
||||||
_notifyLevel = osg::NOTICE; // Default value
|
_notifyLevel = osg::NOTICE; // Default value
|
||||||
|
|
||||||
char* OSGNOTIFYLEVEL=getenv("OSG_NOTIFY_LEVEL");
|
std::string OSGNOTIFYLEVEL;
|
||||||
if (!OSGNOTIFYLEVEL) OSGNOTIFYLEVEL=getenv("OSGNOTIFYLEVEL");
|
if(getEnvVar("OSG_NOTIFY_LEVEL", OSGNOTIFYLEVEL) || getEnvVar("OSGNOTIFYLEVEL", OSGNOTIFYLEVEL))
|
||||||
if(OSGNOTIFYLEVEL)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string stringOSGNOTIFYLEVEL(OSGNOTIFYLEVEL);
|
std::string stringOSGNOTIFYLEVEL(OSGNOTIFYLEVEL);
|
||||||
|
@ -516,7 +516,6 @@ void Program::apply( osg::State& state ) const
|
|||||||
{
|
{
|
||||||
// for shader debugging: to minimize performance impact,
|
// for shader debugging: to minimize performance impact,
|
||||||
// optionally validate based on notify level.
|
// optionally validate based on notify level.
|
||||||
// TODO: enable this using notify level, or perhaps its own getenv()?
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
if( osg::isNotifyEnabled(osg::INFO) )
|
if( osg::isNotifyEnabled(osg::INFO) )
|
||||||
pcp->validateProgram();
|
pcp->validateProgram();
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <osg/Drawable>
|
#include <osg/Drawable>
|
||||||
#include <osg/ApplicationUsage>
|
#include <osg/ApplicationUsage>
|
||||||
#include <osg/ContextData>
|
#include <osg/ContextData>
|
||||||
|
#include <osg/EnvVar>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -75,15 +76,18 @@ State::State():
|
|||||||
|
|
||||||
_checkGLErrors = ONCE_PER_FRAME;
|
_checkGLErrors = ONCE_PER_FRAME;
|
||||||
|
|
||||||
const char* str = getenv("OSG_GL_ERROR_CHECKING");
|
std::string str;
|
||||||
if (str && (strcmp(str,"ONCE_PER_ATTRIBUTE")==0 || strcmp(str,"ON")==0 || strcmp(str,"on")==0))
|
if (getEnvVar("OSG_GL_ERROR_CHECKING", str))
|
||||||
|
{
|
||||||
|
if (str=="ONCE_PER_ATTRIBUTE" || str=="ON" || str=="on")
|
||||||
{
|
{
|
||||||
_checkGLErrors = ONCE_PER_ATTRIBUTE;
|
_checkGLErrors = ONCE_PER_ATTRIBUTE;
|
||||||
}
|
}
|
||||||
else if(str && (strcmp(str, "OFF") == 0 || strcmp(str, "off") == 0))
|
else if (str=="OFF" || str=="off")
|
||||||
{
|
{
|
||||||
_checkGLErrors = NEVER_CHECK_GL_ERRORS;
|
_checkGLErrors = NEVER_CHECK_GL_ERRORS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_currentActiveTextureUnit=0;
|
_currentActiveTextureUnit=0;
|
||||||
_currentClientActiveTextureUnit=0;
|
_currentClientActiveTextureUnit=0;
|
||||||
|
Loading…
Reference in New Issue
Block a user