Converted OpenGL version number code to using osg::asciiToFloat to avoid issues with conversion using locale senstive atof function

This commit is contained in:
Robert Osfield 2008-11-24 13:19:01 +00:00
parent bf8c3cc07e
commit fccd05b290
4 changed files with 6 additions and 5 deletions

View File

@ -22,6 +22,7 @@
#include <osg/ref_ptr>
#include <osg/GL2Extensions>
#include <osg/GLExtensions>
#include <osg/Math>
using namespace osg;
@ -325,7 +326,7 @@ void GL2Extensions::setupGL2Extensions(unsigned int contextID)
return;
}
_glVersion = atof( version );
_glVersion = asciiToFloat( version );
_glslLanguageVersion = 0.0f;
_isShaderObjectsSupported = osg::isGLExtensionSupported(contextID,"GL_ARB_shader_objects");
@ -341,7 +342,7 @@ void GL2Extensions::setupGL2Extensions(unsigned int contextID)
while(glGetError() != GL_NO_ERROR) {} // reset error flag
const char* langVerStr = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
if( (glGetError() == GL_NO_ERROR) && langVerStr )
_glslLanguageVersion = atof( langVerStr );
_glslLanguageVersion = asciiToFloat( langVerStr );
else
_glslLanguageVersion = 1.0f;
}

View File

@ -47,7 +47,7 @@ float osg::getGLVersionNumber()
if (!versionstring) return 0.0;
std::string vs( versionstring );
return( atof( vs.substr( 0, vs.find( " " ) ).c_str() ) );
return( asciiToFloat( vs.substr( 0, vs.find( " " ) ).c_str() ) );
}
bool osg::isExtensionInExtensionString(const char *extension, const char *extensionString)

View File

@ -29,7 +29,7 @@ TexEnvFilter::~TexEnvFilter()
void TexEnvFilter::apply(State& state) const
{
// note from RO, need to adapt to do testing per graphics context.
static float glVersion = atof( (const char *)glGetString( GL_VERSION ) );
static float glVersion = asciiToFloat( (const char *)glGetString( GL_VERSION ) );
static bool s_isTexLodBias = glVersion>=1.4 || isGLExtensionSupported(state.getContextID(),"GL_EXT_texture_lod_bias");
if (s_isTexLodBias)

View File

@ -1635,7 +1635,7 @@ void Texture::Extensions::setupGLExtensions(unsigned int contextID)
}
float glVersion = atof( (const char *)version );
float glVersion = asciiToFloat( (const char *)version );
const char* renderer = (const char*) glGetString(GL_RENDERER);
std::string rendererString(renderer ? renderer : "");