From c6813cf8e21e11f30b41ed099fa6ed92d737ca49 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 22 Sep 2016 14:33:03 +0100 Subject: [PATCH] Replaced local static usage to avoid threading and mulit-context issues --- src/osg/LightModel.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/osg/LightModel.cpp b/src/osg/LightModel.cpp index 41c4accb2..6617e5d85 100644 --- a/src/osg/LightModel.cpp +++ b/src/osg/LightModel.cpp @@ -16,6 +16,7 @@ #include #include #include +#include using namespace osg; @@ -34,6 +35,8 @@ LightModel::~LightModel() { } +#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE + // need to define if gl.h version < 1.2. #ifndef GL_LIGHT_MODEL_COLOR_CONTROL #define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 @@ -47,10 +50,8 @@ LightModel::~LightModel() #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #endif - -void LightModel::apply(State&) const +void LightModel::apply(State& state) const { -#ifdef OSG_GL_FIXED_FUNCTION_AVAILABLE #ifdef OSG_GLES1_AVAILABLE #define glLightModeli glLightModelx @@ -58,8 +59,7 @@ void LightModel::apply(State&) const glLightModelfv(GL_LIGHT_MODEL_AMBIENT,_ambient.ptr()); - static bool s_separateSpecularSupported = strncmp((const char*)glGetString(GL_VERSION),"1.2",3)>=0; - if (s_separateSpecularSupported) + if (state.get()->glVersion>=1.2) { if (_colorControl==SEPARATE_SPECULAR_COLOR) { @@ -76,8 +76,14 @@ void LightModel::apply(State&) const #endif glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSided); -#else - OSG_NOTICE<<"Warning: LightModel::apply(State&) - not supported."<