From 4b223c770bdc6f0185d1fa92e54d01b09f716e4a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 28 May 2013 15:40:28 +0000 Subject: [PATCH] From Michael Bach Jensen and Robert Osfield, "As discussed (http://forum.openscenegraph.org/viewtopic.php?t=12027) here is my submission :-) The following change to State.cpp fixes the case where textures in a stateset along with a compute shader program did not make those textures available to the shader, since it got evaluated before the texture bind(s)." Note from Robert, Michael only change State::apply(StateSet*) so I also applied the same reversal in apply of texutre modes/state into the State::apply() method for consistency. --- src/osg/State.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/osg/State.cpp b/src/osg/State.cpp index 775f23559..817153d3c 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -505,9 +505,7 @@ void State::apply(const StateSet* dstate) _currentShaderCompositionUniformList.clear(); - applyModeList(_modeMap,dstate->getModeList()); - applyAttributeList(_attributeMap,dstate->getAttributeList()); - + // apply all texture state and modes const StateSet::TextureModeList& ds_textureModeList = dstate->getTextureModeList(); const StateSet::TextureAttributeList& ds_textureAttributeList = dstate->getTextureAttributeList(); @@ -524,6 +522,9 @@ void State::apply(const StateSet* dstate) else if (unit<_textureAttributeMapList.size()) applyAttributeMapOnTexUnit(unit,_textureAttributeMapList[unit]); } + applyModeList(_modeMap,dstate->getModeList()); + applyAttributeList(_attributeMap,dstate->getAttributeList()); + if (_shaderCompositionEnabled) { applyShaderComposition(); @@ -569,13 +570,7 @@ void State::apply() if (_shaderCompositionEnabled) _currentShaderCompositionUniformList.clear(); - // go through all active OpenGL modes, enabling/disable where - // appropriate. - applyModeMap(_modeMap); - - // go through all active StateAttribute's, applying where appropriate. - applyAttributeMap(_attributeMap); - + // apply all texture state and modes unsigned int unit; unsigned int unitMax = maximum(_textureModeMapList.size(),_textureAttributeMapList.size()); for(unit=0;unit