From 5c4800c7743e61c31f806986cbc2054f84bc5036 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 22 Oct 2013 11:17:29 +0000 Subject: [PATCH] Fixed handling of in scene graph osg::Program being overriden by shader composition. --- src/osg/State.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index a09e34b0f..6f9794aaa 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -484,12 +484,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()) @@ -911,7 +917,7 @@ void State::initializeExtensionProcs() if ( osg::getGLVersionNumber() >= 2.0 || osg::isGLExtensionSupported(_contextID,"GL_ARB_vertex_shader") || OSG_GLES2_FEATURES) { glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS,&_glMaxTextureUnits); - if(OSG_GLES2_FEATURES) + if(OSG_GLES2_FEATURES) _glMaxTextureCoords = _glMaxTextureUnits; else glGetIntegerv(GL_MAX_TEXTURE_COORDS,&_glMaxTextureCoords);