From 5ed399ca4864218dfc62d4bf614d764cf3235bfb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 22 Oct 2013 11:18:28 +0000 Subject: [PATCH] Fixed handling of osg::Program so that it's not overriden by shader composition when enabled --- src/osg/State.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 2d0db35be..62d8c7e2c 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -535,12 +535,18 @@ void State::apply(const StateSet* dstate) else if (unit<_textureAttributeMapList.size()) applyAttributeMapOnTexUnit(unit,_textureAttributeMapList[unit]); } + const Program::PerContextProgram* previousLastAppliedProgramObject = _lastAppliedProgramObject; + applyModeList(_modeMap,dstate->getModeList()); applyAttributeList(_attributeMap,dstate->getAttributeList()); if (_shaderCompositionEnabled) { - applyShaderComposition(); + if (previousLastAppliedProgramObject == _lastAppliedProgramObject || _lastAppliedProgramObject==0) + { + // No program has been applied by the StateSet stack so assume shader composition is required + applyShaderComposition(); + } } if (dstate->getUniformList().empty())