commit bd3da5b2624d2ecc327bf1613014860a4905d00b
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Dec 5 14:18:46 2016 +0000

    Move DistortedNode and Distorted to use the new DistortedRenderTarget.

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 4f45532..f81c446 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -91,9 +91,8 @@ public class Distorted
   static int mTextureCoordH;    // pass in model texture coordinate information.
   static int mProgramH;         // This is a handle to our shading program.
 
-  static DistortedProjection mProjection = new DistortedProjection();
-  static float mFOV = 60.0f;
-  
+  static DistortedRenderTarget mRenderTarget = new DistortedRenderTarget(0);
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private Distorted()
@@ -293,10 +292,7 @@ public class Distorted
  */
   public static void setFov(float fov)
     {
-    mFOV = fov;
-   
-    if( mProjection.width>0 && mProjection.height>0 )
-      mProjection.onSurfaceChanged( mProjection.width, mProjection.height);
+    mRenderTarget.setProjection(fov,0.0f,0.0f);
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -366,7 +362,7 @@ public class Distorted
  */
   public static void onSurfaceChanged(int surfaceWidth, int surfaceHeight)
     {
-    mProjection.onSurfaceChanged(surfaceWidth, surfaceHeight);
+    mRenderTarget.resize(surfaceWidth,surfaceHeight);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/DistortedNode.java b/src/main/java/org/distorted/library/DistortedNode.java
index c28ee14..fa8ffbe 100644
--- a/src/main/java/org/distorted/library/DistortedNode.java
+++ b/src/main/java/org/distorted/library/DistortedNode.java
@@ -34,96 +34,31 @@ import android.opengl.GLES20;
  */
 public class DistortedNode 
   {
-  private static final int TEXTURE_FAILED_TO_CREATE = -1;   
-  private static final int TEXTURE_NOT_CREATED_YET  = -2;   
-   
+  private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>();
+  private static long mNextNodeID =0;
+
   private DistortedObject mObject;
   private NodeData mData;
-  
+
   private DistortedNode mParent;
   private ArrayList<DistortedNode> mChildren;
   private int[] mNumChildren;  // ==mChildren.length(), but we only create mChildren if the first one gets added
-  
-  private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>();
-  private static long mNextNodeID =0;
 
-  //////////////////////////////////////////////////////////////////
-  
   private class NodeData
     {
-    long ID;  
+    long ID;
     int numPointingNodes;
-    int mFramebufferID;
-    int mTextureID;
-    DistortedProjection mProjection;
+    DistortedRenderTarget mDRT;
     boolean mRendered;
-    
-  //////////////////////////////////////////////////////////////////
- 
-   NodeData(long id)
-     {
-     ID = id;
-     numPointingNodes= 1;
-     mFramebufferID = 0;
-     mTextureID = TEXTURE_NOT_CREATED_YET;
-     mProjection = null;
-     mRendered = false;
-     }
-   
-  //////////////////////////////////////////////////////////////////
-
-    boolean createFBO()
-      {  
-      int[] textureIds = new int[1];
-      GLES20.glGenTextures(1, textureIds, 0);
-      mTextureID = textureIds[0];
-      int[] mFBORenderToTexture = new int[1];
-      
-      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
-      GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
-      GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
-      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
-      GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);
-      GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, mProjection.width, mProjection.height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
-
-      GLES20.glGenFramebuffers(1, mFBORenderToTexture, 0);
-      GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFBORenderToTexture[0]);
-      GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mTextureID, 0);
-      int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
-    
-      if(status != GLES20.GL_FRAMEBUFFER_COMPLETE)
-        {
-        android.util.Log.e("Node", "failed to create framebuffer, error="+status);  
-        
-        GLES20.glDeleteTextures(1, textureIds, 0);
-        GLES20.glDeleteFramebuffers(1, mFBORenderToTexture, 0);
-        mFramebufferID = 0;
-        mTextureID = TEXTURE_FAILED_TO_CREATE;
-        return false;
-        }
-      
-      mFramebufferID = mFBORenderToTexture[0];
-      
-      return true;
-      }
-   
-  //////////////////////////////////////////////////////////////////
 
-    void deleteFBO()
+    NodeData(long id)
       {
-      int[] textureIds = new int[1];
-      int[] mFBORenderToTexture = new int[1];
-     
-      textureIds[0] = mTextureID;
-      mFBORenderToTexture[0] = mFramebufferID;
-      
-      GLES20.glDeleteTextures(1, textureIds, 0);
-      GLES20.glDeleteFramebuffers(1, mFBORenderToTexture, 0);
-      
-      mFramebufferID = 0;
-      mTextureID = TEXTURE_NOT_CREATED_YET;
+      ID              = id;
+      numPointingNodes= 1;
+      mDRT            = null;
+      mRendered       = false;
       }
-   }
+    }
  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -147,50 +82,42 @@ public class DistortedNode
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
   
-  private void drawRecursive(long currTime, DistortedProjection dp, int mFBO)
+  private void drawRecursive(long currTime, DistortedRenderTarget drt)
     {
     if( mNumChildren[0]<=0 )
       {
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mObject.mTextureDataH[0]);
-      
-      if( mData.mProjection!=null )
-        {
-        mData.deleteFBO();
-        mData.mProjection = null;
-        }
       }
     else
       {
       if( mData.mRendered==false )
         {
         mData.mRendered = true;
-       
-        if( mData.mTextureID==TEXTURE_NOT_CREATED_YET ) mData.createFBO();
-       
-        GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mData.mFramebufferID);
+        mData.mDRT.setOutput();
+
         GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
         GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
       
         if( mObject.mBitmapSet[0] )
           {
           GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mObject.mTextureDataH[0]);
-          mObject.drawNoEffectsPriv(mData.mProjection);
+          mObject.drawNoEffectsPriv(mData.mDRT);
           }
       
         synchronized(this)
           {
           for(int i=0; i<mNumChildren[0]; i++)
             {
-            mChildren.get(i).drawRecursive(currTime, mData.mProjection, mData.mFramebufferID);
+            mChildren.get(i).drawRecursive(currTime, mData.mDRT);
             }
           }
         }
-      
-      GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFBO);
-      GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mData.mTextureID);   // this is safe because we must have called createFBO() above before.     
+
+      drt.setOutput();
+      mData.mDRT.setInput();   // this is safe because we must have called createFBO() above before.
       }
     
-    mObject.drawPriv(currTime, dp);
+    mObject.drawPriv(currTime, drt);
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -246,14 +173,9 @@ public class DistortedNode
       if( otherNodesPoint )  mData = new NodeData(++mNextNodeID);
       else                   mData.ID = ++mNextNodeID;  // numPointingNodes must be 1 already
 
-      if( newList.size()>1 && mData.mProjection==null )
-        {     
-        mData.mProjection = new DistortedProjection();
-        mData.mProjection.onSurfaceChanged(mObject.getWidth(), mObject.getHeight());
-        mData.mFramebufferID = 0;
-        mData.mTextureID = TEXTURE_NOT_CREATED_YET;
-        }
-       
+      if( newList.size()>1 && mData.mDRT==null )
+        mData.mDRT = new DistortedRenderTarget(mObject.getWidth(), mObject.getHeight());
+
       mMapNodeID.put(newList, mData);
       }
     else
@@ -275,9 +197,9 @@ public class DistortedNode
       {
       tmp = mMapNodeID.get(key);
           
-      if( tmp.mProjection!=null )
+      if( tmp.mDRT != null )
         {
-    	  tmp.mTextureID = TEXTURE_NOT_CREATED_YET;
+    	  tmp.mDRT.reset();
         tmp.mRendered  = false;
         }
       }
@@ -522,9 +444,11 @@ public class DistortedNode
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
-    
+
+    DistortedRenderTargetList.deleteAllMarked();
+
     markRecursive();
-    drawRecursive(currTime,Distorted.mProjection,0);
+    drawRecursive(currTime,Distorted.mRenderTarget);
     }
  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index 9624276..efc214e 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -159,12 +159,12 @@ public abstract class DistortedObject
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-  void drawPriv(long currTime, DistortedProjection dp)
+  void drawPriv(long currTime, DistortedRenderTarget drt)
     {
-    GLES20.glViewport(0, 0, dp.width, dp.height);
+    GLES20.glViewport(0, 0, drt.mWidth, drt.mHeight);
       
     mM.compute(currTime);
-    mM.send(dp);
+    mM.send(drt);
       
     mV.compute(currTime);
     mV.send();
@@ -177,10 +177,10 @@ public abstract class DistortedObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-  void drawNoEffectsPriv(DistortedProjection dp)
+  void drawNoEffectsPriv(DistortedRenderTarget drt)
     {
-    GLES20.glViewport(0, 0, dp.width, dp.height);
-    mM.sendZero(dp);
+    GLES20.glViewport(0, 0, drt.mWidth, drt.mHeight);
+    mM.sendZero(drt);
     mV.sendZero();
     mF.sendZero();
     mGrid.draw();
@@ -275,7 +275,7 @@ public abstract class DistortedObject
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
       
-    drawPriv(currTime, Distorted.mProjection);
+    drawPriv(currTime, Distorted.mRenderTarget);
     }
  
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/DistortedProjection.java b/src/main/java/org/distorted/library/DistortedProjection.java
deleted file mode 100644
index 7f71151..0000000
--- a/src/main/java/org/distorted/library/DistortedProjection.java
+++ /dev/null
@@ -1,73 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted is free software: you can redistribute it and/or modify                             //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Distorted is distributed in the hope that it will be useful,                                  //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
-// GNU General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library;
-
-import android.opengl.Matrix;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Only used within the Distorted Library itself.
- */
-class DistortedProjection
-  {
-  int width,height,depth,distance;
-  float[] projectionMatrix;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-   
-  DistortedProjection()
-   {
-   projectionMatrix = new float[16];   
-   }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  void onSurfaceChanged(int surfaceWidth, int surfaceHeight)
-    {
-    width = surfaceWidth;
-    height= surfaceHeight;  
-    
-    float ratio  = (float) surfaceWidth / surfaceHeight;
-    float left   =-ratio;          //
-    float right  = ratio;          // Create a new perspective projection matrix.
-    float bottom = -1.0f;          //
-    float top    =  1.0f;          // any change to those values will have serious consequences!
-    float near, far;
-   
-    if( Distorted.mFOV>0.0f )  // perspective projection
-      {  
-      near= (float)(top / Math.tan(Distorted.mFOV*Math.PI/360)); 
-      distance = (int)(height*near/(top-bottom));
-      far = 2*distance-near;
-     
-      Matrix.frustumM(projectionMatrix, 0, left, right, bottom, top, near, far);
-      }
-    else                      // parallel projection
-      {
-      near= (float)(top / Math.tan(Math.PI/360)); 
-      distance = (int)(height*near/(top-bottom));
-      far = 2*distance-near;
-    
-      Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2,-surfaceHeight/2, surfaceHeight/2, near, far);
-      }
-   
-    depth = (int)((far-near)/2);
-    }
-  }
\ No newline at end of file
diff --git a/src/main/java/org/distorted/library/DistortedRenderTarget.java b/src/main/java/org/distorted/library/DistortedRenderTarget.java
index f1e6062..440d0c3 100644
--- a/src/main/java/org/distorted/library/DistortedRenderTarget.java
+++ b/src/main/java/org/distorted/library/DistortedRenderTarget.java
@@ -37,6 +37,8 @@ public class DistortedRenderTarget
   int mWidth,mHeight,mDepth,mDistance;
   float[] mProjectionMatrix;
 
+  boolean mMarked;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void createProjection()
@@ -107,6 +109,7 @@ public class DistortedRenderTarget
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// must be called form a thread holding OpenGL Context
 
   private void deleteFBO()
     {
@@ -123,6 +126,24 @@ public class DistortedRenderTarget
     mTextureID = TEXTURE_NOT_CREATED_YET;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// must be called form a thread holding OpenGL Context
+
+  void release()
+    {
+    if( mTextureID>=0 ) deleteFBO();
+
+    mProjectionMatrix = null;
+    mMarked = false;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void reset()
+    {
+    mTextureID = TEXTURE_NOT_CREATED_YET;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 
@@ -132,12 +153,14 @@ public class DistortedRenderTarget
 
     mHeight        = height;
     mWidth         = width;
-    mFramebufferID = -1;
+    mFramebufferID = 0;
     mTextureID     = TEXTURE_NOT_CREATED_YET;
     mFOV           = 60.0f;
     mX             = 0.0f;
     mY             = 0.0f;
 
+    mMarked = false;
+
     createProjection();
     }
 
@@ -152,15 +175,16 @@ public class DistortedRenderTarget
     mFOV           = 60.0f;
     mX             = 0.0f;
     mY             = 0.0f;
+
+    mMarked = false;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void release()
+  public void markForDeletion()
     {
-    if( mTextureID>=0 ) deleteFBO();
-
-    mProjectionMatrix = null;
+    DistortedRenderTargetList.markForDeletion();
+    mMarked = true;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -178,12 +202,15 @@ public class DistortedRenderTarget
 
   public void resize(int width, int height)
     {
-    mWidth = width;
-    mHeight= height;
+    if( mWidth!=width || mHeight!=height )
+      {
+      mWidth = width;
+      mHeight= height;
 
-    createProjection();
+      createProjection();
 
-    if( mTextureID>0 ) deleteFBO();
+      if( mTextureID>0 ) markForDeletion();
+      }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -194,12 +221,23 @@ public class DistortedRenderTarget
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// set this as Render Target. Must be called from a thread holding OpenGL context.
+// set this as Render Target to draw to. Must be called from a thread holding OpenGL context.
 
-  public void use()
+  public void setOutput()
     {
     if( mTextureID==TEXTURE_NOT_CREATED_YET ) createFBO();
 
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFramebufferID);
     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// set this as Render Target to draw from. Must be called from a thread holding OpenGL context.
+
+  public void setInput()
+    {
+    if( mTextureID==TEXTURE_NOT_CREATED_YET ) createFBO();
+
+    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
+    }
+
   }
diff --git a/src/main/java/org/distorted/library/DistortedRenderTargetList.java b/src/main/java/org/distorted/library/DistortedRenderTargetList.java
new file mode 100644
index 0000000..813c250
--- /dev/null
+++ b/src/main/java/org/distorted/library/DistortedRenderTargetList.java
@@ -0,0 +1,77 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library;
+
+import java.util.LinkedList;
+import java.util.Iterator;
+
+/**
+ * List of all DistortedRenderTarget objects currently created by the application.
+ *
+ * The point: we need to be able ot mark RenderTargets for deletion, and delete all marked
+ * objects later at a convenient time. Thus we keep all of them in a LinkedList here.
+ */
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+final class DistortedRenderTargetList
+  {
+  private static boolean mMarked = false;
+  private static LinkedList<DistortedRenderTarget> mList = new LinkedList<>();
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  static synchronized void add(DistortedRenderTarget drt)
+    {
+    mList.add(drt);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  static synchronized void markForDeletion()
+    {
+    mMarked = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// must be called form a thread holding OpenGL Context
+
+  static synchronized void deleteAllMarked()
+    {
+    if( mMarked )
+      {
+      DistortedRenderTarget tmp;
+      Iterator<DistortedRenderTarget> iterator = mList.iterator();
+
+      while(iterator.hasNext())
+        {
+        tmp = iterator.next();
+
+        if( tmp.mMarked )
+          {
+          tmp.release();
+          iterator.remove();
+          }
+        }
+
+      mMarked = false;
+      }
+    }
+  }
diff --git a/src/main/java/org/distorted/library/EffectQueueMatrix.java b/src/main/java/org/distorted/library/EffectQueueMatrix.java
index 9df4ee3..8db7619 100644
--- a/src/main/java/org/distorted/library/EffectQueueMatrix.java
+++ b/src/main/java/org/distorted/library/EffectQueueMatrix.java
@@ -153,10 +153,10 @@ class EffectQueueMatrix extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // here construct the ModelView Matrix
 
-  synchronized void send(DistortedProjection dp)
+  synchronized void send(DistortedRenderTarget drt)
     {
     Matrix.setIdentityM(mViewMatrix, 0);
-    Matrix.translateM(mViewMatrix, 0, -dp.width/2, dp.height/2, -dp.distance);
+    Matrix.translateM(mViewMatrix, 0, -drt.mWidth/2, drt.mHeight/2, -drt.mDistance);
     
     float x,y,z, sx,sy,sz;
    
@@ -230,10 +230,10 @@ class EffectQueueMatrix extends EffectQueue
       }
    
     Matrix.translateM(mViewMatrix, 0, mObjHalfX,-mObjHalfY, 0);
-    Matrix.multiplyMM(mMVPMatrix, 0, dp.projectionMatrix, 0, mViewMatrix, 0);
+    Matrix.multiplyMM(mMVPMatrix, 0, drt.mProjectionMatrix, 0, mViewMatrix, 0);
     
     GLES20.glUniform3f( mObjDH , mObjHalfX, mObjHalfY, mObjHalfZ);
-    GLES20.glUniform1f( mDepthH, dp.depth);   
+    GLES20.glUniform1f( mDepthH, drt.mDepth);
     GLES20.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0);
     GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
     }
@@ -241,14 +241,14 @@ class EffectQueueMatrix extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // here construct the ModelView Matrix, but without any effects
 
-  synchronized void sendZero(DistortedProjection dp)
+  synchronized void sendZero(DistortedRenderTarget drt)
     {
     Matrix.setIdentityM(mTmpMatrix, 0);
-    Matrix.translateM(mTmpMatrix, 0, mObjHalfX-dp.width/2, dp.height/2-mObjHalfY, -dp.distance);
-    Matrix.multiplyMM(mMVPMatrix, 0, dp.projectionMatrix, 0, mTmpMatrix, 0);
+    Matrix.translateM(mTmpMatrix, 0, mObjHalfX-drt.mWidth/2, drt.mHeight/2-mObjHalfY, -drt.mDistance);
+    Matrix.multiplyMM(mMVPMatrix, 0, drt.mProjectionMatrix, 0, mTmpMatrix, 0);
     
     GLES20.glUniform3f( mObjDH , mObjHalfX, mObjHalfY, mObjHalfZ);
-    GLES20.glUniform1f( mDepthH, dp.depth);  
+    GLES20.glUniform1f( mDepthH, drt.mDepth);
     GLES20.glUniformMatrix4fv(mMVMatrixH , 1, false, mTmpMatrix, 0);
     GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix, 0);
     }
