commit b2939df4a6d25778c7b8b8943c5b2afc902527b8
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Wed Mar 8 15:36:02 2017 +0000

    Now there's a single place one can have a look at all the Meshes being rendered to a OutputSurface: OutputSurface.renderChildren().
    This will need to get modified for per-object post-processing.

diff --git a/src/main/java/org/distorted/library/DistortedNode.java b/src/main/java/org/distorted/library/DistortedNode.java
index d8f0c90..0e35919 100644
--- a/src/main/java/org/distorted/library/DistortedNode.java
+++ b/src/main/java/org/distorted/library/DistortedNode.java
@@ -238,55 +238,12 @@ public class DistortedNode implements DistortedAttacheable
         DistortedEffects.blitPriv(mData.mFBO);
         }
 
-      // 'renderChildren'
-      for(int i=0; i<mNumChildren[0]; i++)
-        {
-        numRenders += mChildren.get(i).draw(currTime,mData.mFBO);
-        }
+      numRenders += mData.mFBO.renderChildren(currTime,mNumChildren[0],mChildren);
       }
 
     return numRenders;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// return the total number of render calls issued
-
-  int drawRecursive(long currTime, DistortedOutputSurface surface)
-    {
-    int ret = 0;
-
-    if( mNumChildren[0]>0 && mData.currTime!=currTime )
-      {
-      mData.currTime = currTime;
-      mData.mFBO.setAsOutput();
-
-      GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
-      GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT);
-
-      if( mSurface.setAsInput() )
-        {
-        ret++;
-        DistortedEffects.blitPriv(mData.mFBO);
-        }
-
-      for(int i=0; i<mNumChildren[0]; i++)
-        {
-        ret += mChildren.get(i).drawRecursive(currTime, mData.mFBO);
-        }
-      }
-
-    DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
-
-    if( input.setAsInput() )
-      {
-      ret++;
-      mState.apply();
-      mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
-      }
-
-    return ret;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/DistortedOutputSurface.java b/src/main/java/org/distorted/library/DistortedOutputSurface.java
index a04d422..b01f7cf 100644
--- a/src/main/java/org/distorted/library/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/DistortedOutputSurface.java
@@ -101,40 +101,21 @@ abstract class DistortedOutputSurface extends DistortedSurface implements Distor
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Draws all the attached children to this OutputSurface.
- * <p>
- * Must be called from a thread holding OpenGL Context.
- *
- * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes.
- * @return Number of objects rendered.
- */
-  public int render(long time)
-    {
-    DistortedAttachDaemon.toDo();
-    toDo();
-    DistortedRenderState.reset();
-
-    int numRenders=0;
 
-    for(int i=0; i<mNumChildren; i++)
-      {
-      numRenders += mChildren.get(i).renderRecursive(time);
-      }
-
-    setAsOutput();
+  int renderChildren(long time, int num, ArrayList<DistortedNode> children)
+    {
+    int numRenders = 0;
 
-    // 'renderChildren'
-    for(int i=0; i<mNumChildren; i++)
+    for(int i=0; i<num; i++)
       {
-      numRenders += mChildren.get(i).draw(time,this);
+      numRenders += children.get(i).draw(time,this);
       }
 
     return numRenders;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Draws all the attached children to this OutputSurface.
@@ -144,7 +125,7 @@ abstract class DistortedOutputSurface extends DistortedSurface implements Distor
  * @param time Current time, in milliseconds. This will be passed to all the Effects stored in the children Nodes.
  * @return Number of objects rendered.
  */
-  public int renderOld(long time)
+  public int render(long time)
     {
     // change tree topology (attach and detach children)
 /*
@@ -179,13 +160,16 @@ abstract class DistortedOutputSurface extends DistortedSurface implements Distor
     // mark OpenGL state as unknown
     DistortedRenderState.reset();
 
-    int numRenders = 0;
+    int numRenders=0;
 
     for(int i=0; i<mNumChildren; i++)
       {
-      numRenders += mChildren.get(i).drawRecursive(time,this);
+      numRenders += mChildren.get(i).renderRecursive(time);
       }
 
+    setAsOutput();
+    numRenders += renderChildren(time,mNumChildren,mChildren);
+
     return numRenders;
     }
 
