commit d1e740c550bf6b10a5af2c6c13f2fa3d162dd255
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Thu Dec 8 16:47:16 2016 +0000

    Move the 'Save' app to using a DistortedFramebuffer.

diff --git a/src/main/java/org/distorted/library/DistortedFramebuffer.java b/src/main/java/org/distorted/library/DistortedFramebuffer.java
index 19f6ad2..a0a4eb7 100644
--- a/src/main/java/org/distorted/library/DistortedFramebuffer.java
+++ b/src/main/java/org/distorted/library/DistortedFramebuffer.java
@@ -194,26 +194,6 @@ public class DistortedFramebuffer
       }
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Set this as the Framebuffer to write to.
-
-  void setAsOutput()
-    {
-    if( texIds[0]==TEXTURE_NOT_CREATED_YET ) createFBO();
-
-    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Set this as the Framebuffer to read from.
-
-  void setAsInput()
-    {
-    if( texIds[0]==TEXTURE_NOT_CREATED_YET ) createFBO();
-
-    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texIds[0]);
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -313,4 +293,27 @@ public class DistortedFramebuffer
       if( texIds[0]>0 ) markForDeletion();
       }
     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ *  Set this as the Framebuffer to write to.
+ */
+  public void setAsOutput()
+    {
+    if( texIds[0]==TEXTURE_NOT_CREATED_YET ) createFBO();
+
+    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, fboIds[0]);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ *  Set this as the Framebuffer to read from.
+ */
+  public void setAsInput()
+    {
+    if( texIds[0]==TEXTURE_NOT_CREATED_YET ) createFBO();
+
+    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texIds[0]);
+    }
+
   }
diff --git a/src/main/java/org/distorted/library/DistortedNode.java b/src/main/java/org/distorted/library/DistortedNode.java
index e5b850a..2ad88d8 100644
--- a/src/main/java/org/distorted/library/DistortedNode.java
+++ b/src/main/java/org/distorted/library/DistortedNode.java
@@ -456,13 +456,26 @@ public class DistortedNode
  */
   public void draw(long currTime)
     {  
-    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
 
     markRecursive();
     drawRecursive(currTime,Distorted.mFramebuffer);
     }
- 
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Draws the Node, and all its children, to the Framebuffer passed.
+ *
+ * @param currTime Current time, in milliseconds.
+ * @param df       Framebuffer to render this to.
+ */
+  public void draw(long currTime, DistortedFramebuffer df)
+    {
+    df.setAsOutput();
+    markRecursive();
+    drawRecursive(currTime,df);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Returns the DistortedObject object that's in the Node.
diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index 97085e1..a9d26b5 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -320,19 +320,31 @@ public abstract class DistortedObject
 /**
  * Draw the DistortedObject to the location specified by current Matrix effects.    
  *     
- * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
+ * @param currTime current time, in milliseconds.
  *        This gets passed on to Dynamics inside the Effects that are currently applied to the
  *        Object.
  */
   public void draw(long currTime)
     {
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
-
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
-
     drawPriv(currTime, Distorted.mFramebuffer);
     }
- 
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Draw the DistortedObject to the Framebuffer passed.
+ *
+ * @param currTime Current time, in milliseconds.
+ * @param df       Framebuffer to render this to.
+ */
+  public void draw(long currTime, DistortedFramebuffer df)
+    {
+    df.setAsOutput();
+    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
+    drawPriv(currTime,df);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Releases all resources.
@@ -545,7 +557,7 @@ public abstract class DistortedObject
 /**
  * Scales the Object by (possibly changing in time) 3D scale factors.
  * 
- * @param scale 3-dimensional Dynamic which at any given time returns a Static3D
+ * @param scale 3-dimensional Data which at any given time returns a Static3D
  *              representing the current x- , y- and z- scale factors.
  * @return      ID of the effect added, or -1 if we failed to add one.
  */
