Thanks for the example Michael.  Using this example I recreated the problem
with svn/trunk and fixed it by adding a clean up of an osg::Program that
are applied during the GLObjectVisitor traversal.  I have checked the fix
into svn/trunk and OSG-3.2 branch.  I have also attached a diff file of the
changes.  Might I suggest this would be a good time to try out the OSG-3.2
branch or svn/trunk :-)


On 23 January 2014 07:46, Michael Bach Jensen <mich...@ifad.dk> wrote:

> Hi Robert and Nick,
>
> It does very much look like a missing cleanup after compilation.
>
> The following things need to be present:
> - a geometry shader
> - a uniform
> - rendering the node using the above after an object that is not
> compatible with the shader program.
>
> I have attached a modified version of osgshape.cpp that causes the failure.
>
> Thank you for looking into it!
>
> Cheers,
> Michael
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=57961#57961
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
Index: src/osgUtil/GLObjectsVisitor.cpp
===================================================================
--- src/osgUtil/GLObjectsVisitor.cpp    (revision 14023)
+++ src/osgUtil/GLObjectsVisitor.cpp    (working copy)
@@ -31,19 +31,31 @@
 
 }
 
-
 void GLObjectsVisitor::apply(osg::Node& node)
 {
+    bool programSetBefore = _lastCompiledProgram.valid();
+
     if (node.getStateSet())
     {
         apply(*(node.getStateSet()));
     }
 
     traverse(node);
+
+    bool programSetAfter = 
_renderInfo.getState()->getLastAppliedProgramObject()!=0;
+    if (programSetBefore && !programSetAfter)
+    {
+        osg::GL2Extensions* extensions = 
osg::GL2Extensions::Get(_renderInfo.getState()->getContextID(), true);
+        extensions->glUseProgram(0);
+        _renderInfo.getState()->setLastAppliedProgramObject(0);
+        _lastCompiledProgram = 0;
+    }
 }
 
 void GLObjectsVisitor::apply(osg::Geode& node)
 {
+    bool programSetBefore = _lastCompiledProgram.valid();
+
     if (node.getStateSet())
     {
         apply(*(node.getStateSet()));
@@ -61,6 +73,15 @@
             }
         }
     }
+
+    bool programSetAfter = _lastCompiledProgram.valid();
+    if (!programSetBefore && programSetAfter)
+    {
+        osg::GL2Extensions* extensions = 
osg::GL2Extensions::Get(_renderInfo.getState()->getContextID(), true);
+        extensions->glUseProgram(0);
+        _renderInfo.getState()->setLastAppliedProgramObject(0);
+        _lastCompiledProgram = 0;
+    }
 }
 
 void GLObjectsVisitor::apply(osg::Drawable& drawable)
@@ -159,7 +180,7 @@
 
 /////////////////////////////////////////////////////////////////
 //
-// GLObjectsVisitor
+// GLObjectsOperation
 //
 
 GLObjectsOperation::GLObjectsOperation(GLObjectsVisitor::Mode mode):
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to