Skip to content

Commit

Permalink
Replaced local static usage to avoid threading and mulit-context issues
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Sep 22, 2016
1 parent d772304 commit 1f9725e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/osg/LightModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <osg/GL>
#include <osg/LightModel>
#include <osg/Notify>
#include <osg/State>

using namespace osg;

Expand All @@ -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
Expand All @@ -47,19 +50,16 @@ 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
#endif

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<GLExtensions>()->glVersion>=1.2)
{
if (_colorControl==SEPARATE_SPECULAR_COLOR)
{
Expand All @@ -76,8 +76,14 @@ void LightModel::apply(State&) const
#endif

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,_twoSided);
}

#else

void LightModel::apply(State&) const
{
OSG_NOTICE<<"Warning: LightModel::apply(State&) - not supported."<<std::endl;
#endif
}

#endif

0 comments on commit 1f9725e

Please sign in to comment.