commit 39086ebbe64239517f18000ae252f83f1dbaaf23
Author: leszek <leszek@koltunski.pl>
Date:   Mon Mar 6 22:29:53 2017 +0000

    New method of rendering.
    Advantage: now there's one (well, ATM two, but I hope soon really in one) place where we can have a look at all the Meshes that are being rendered to a OutputSurface.
    This should help with proper per-object POSTPROCESSING effects like Multiblur.

diff --git a/src/main/java/org/distorted/library/DistortedNode.java b/src/main/java/org/distorted/library/DistortedNode.java
index 3b2d444..d8f0c90 100644
--- a/src/main/java/org/distorted/library/DistortedNode.java
+++ b/src/main/java/org/distorted/library/DistortedNode.java
@@ -194,6 +194,60 @@ public class DistortedNode implements DistortedAttacheable
     if( mParent!=null ) mParent.adjustIsomorphism();
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// return the total number of render calls issued
+
+  int draw(long currTime, DistortedOutputSurface surface)
+    {
+    DistortedInputSurface input = mNumChildren[0]==0 ? mSurface : mData.mFBO;
+
+    if( input.setAsInput() )
+      {
+      mState.apply();
+      mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
+      return 1;
+      }
+
+    return 0;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// return the total number of render calls issued
+
+  int renderRecursive(long currTime)
+    {
+    int numRenders = 0;
+
+    if( mNumChildren[0]>0 && mData.currTime!=currTime )
+      {
+      mData.currTime = currTime;
+
+      for (int i=0; i<mNumChildren[0]; i++)
+        {
+        numRenders += mChildren.get(i).renderRecursive(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() )
+        {
+        numRenders++;
+        DistortedEffects.blitPriv(mData.mFBO);
+        }
+
+      // 'renderChildren'
+      for(int i=0; i<mNumChildren[0]; i++)
+        {
+        numRenders += mChildren.get(i).draw(currTime,mData.mFBO);
+        }
+      }
+
+    return numRenders;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // return the total number of render calls issued
 
diff --git a/src/main/java/org/distorted/library/DistortedOutputSurface.java b/src/main/java/org/distorted/library/DistortedOutputSurface.java
index fd3fea7..b1ed520 100644
--- a/src/main/java/org/distorted/library/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/DistortedOutputSurface.java
@@ -103,6 +103,33 @@ abstract class DistortedOutputSurface extends DistortedSurface implements Distor
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  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();
+
+    // 'renderChildren'
+    for(int i=0; i<mNumChildren; i++)
+      {
+      numRenders += mChildren.get(i).draw(time,this);
+      }
+
+    return numRenders;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
 /**
  * Draws all the attached children to this OutputSurface.
  * <p>
@@ -111,7 +138,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 render(long time)
+  public int renderOld(long time)
     {
     // change tree topology (attach and detach children)
 /*
