commit d9706fd2df4ae07c0b380f929d54e6f7da19a500
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Fri Feb 10 16:11:56 2017 +0000

    Change the the render() API!
    
    THis introduces some regressions with the Effects3D app.

diff --git a/src/main/java/org/distorted/library/DistortedOutputSurface.java b/src/main/java/org/distorted/library/DistortedOutputSurface.java
index 6ddfd34..ded8177 100644
--- a/src/main/java/org/distorted/library/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/DistortedOutputSurface.java
@@ -91,43 +91,23 @@ abstract class DistortedOutputSurface extends DistortedSurface
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Draw the (texture,mesh,effects) object to the Framebuffer.
+ * Draws all the attached children to this OutputSurface.
  * <p>
  * Must be called from a thread holding OpenGL Context.
  *
- * @param surface InputSurface to skin our Mesh with.
- * @param mesh Class descendant from MeshObject
- * @param effects The DistortedEffects to use when rendering
- * @param time Current time, in milliseconds.
+ * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes.
  */
-  public void renderTo(DistortedInputSurface surface, MeshObject mesh, DistortedEffects effects, long time)
+  public void render(long time)
     {
-    surface.create();  // Watch out  - this needs to be before
-    create();          // the 'setAsInput' because this has side-effects!
+    DistortedSurface.deleteAllMarked();
+    create();
 
-    if( surface.setAsInput() )
+    for(int i=0; i<mNumChildren; i++)
       {
-      DistortedSurface.deleteAllMarked();
-      effects.drawPriv(surface.getWidth()/2.0f, surface.getHeight()/2.0f, mesh, this, time);
+      mChildren.get(i).drawRecursive(time,this);
       }
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Draws the Tree, and all its children, to the Framebuffer.
- * <p>
- * Must be called from a thread holding OpenGL Context.
- *
- * @param dt DistortedNode to render.
- * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the Tree.
- */
-  public void renderTo(DistortedNode dt, long time)
-    {
-    DistortedSurface.deleteAllMarked();
-    create();
-    dt.drawRecursive(time,this);
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Bind this Surface as a Framebuffer we can render to.
@@ -212,7 +192,7 @@ abstract class DistortedOutputSurface extends DistortedSurface
  */
   public synchronized boolean detach(DistortedNode node)
     {
-    if( mChildren.remove(node) )
+    if( mNumChildren>0 && mChildren.remove(node) )
       {
       mNumChildren--;
       return true;
@@ -227,7 +207,10 @@ abstract class DistortedOutputSurface extends DistortedSurface
  */
   public synchronized void detachAll()
     {
-    mNumChildren = 0;
-    mChildren.clear();
+    if( mNumChildren>0 )
+      {
+      mNumChildren = 0;
+      mChildren.clear();
+      }
     }
 }
