commit 226144d09a5038779477e2c04df07efe65ea29db
Author: leszek <leszek@koltunski.pl>
Date:   Thu May 4 01:13:23 2017 +0100

    Progress with VBOs - this time abstract out a new class, DistortedObject - i.e. everything that uploads something to GPU and thus needs to be auto re-created upon loss of the context.

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 6d563da..0d8dd09 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -130,9 +130,8 @@ public class Distorted
  */
   public static void onPause()
     {
-    DistortedSurface.onPause();
+    DistortedObject.onPause();
     DistortedNode.onPause();
-    MeshObject.onPause();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -142,13 +141,12 @@ public class Distorted
  */
   public static void onDestroy()
     {
-    DistortedSurface.onDestroy();
+    DistortedObject.onDestroy();
     DistortedNode.onDestroy();
     DistortedEffects.onDestroy();
     DistortedEffectsPostprocess.onDestroy();
     DistortedMaster.onDestroy();
     EffectQueue.onDestroy();
-    MeshObject.onDestroy();
     EffectMessageSender.stopSending();
 
     mInitialized = false;
diff --git a/src/main/java/org/distorted/library/DistortedEffects.java b/src/main/java/org/distorted/library/DistortedEffects.java
index 861b00c..3a8ecb8 100644
--- a/src/main/java/org/distorted/library/DistortedEffects.java
+++ b/src/main/java/org/distorted/library/DistortedEffects.java
@@ -51,10 +51,6 @@ import java.nio.FloatBuffer;
  */
 public class DistortedEffects
   {
-  private static final int POSITION_DATA_SIZE= 3; // Main Program: size of the position data in elements
-  private static final int NORMAL_DATA_SIZE  = 3; // Main Program: size of the normal data in elements
-  private static final int TEX_DATA_SIZE     = 2; // Main Program: size of the texture coordinate data in elements.
-
   /// MAIN PROGRAM ///
   private static DistortedProgram mMainProgram;
   private static int mMainTextureH;
@@ -305,11 +301,11 @@ public class DistortedEffects
     mF.send(halfW,halfH);
 
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosVBO[0]);
-    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
+    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mNorVBO[0]);
-    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], NORMAL_DATA_SIZE  , GLES30.GL_FLOAT, false, 0, 0);
+    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE  , GLES30.GL_FLOAT, false, 0, 0);
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
-    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
+    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
     GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
 
diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
new file mode 100644
index 0000000..5a29373
--- /dev/null
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -0,0 +1,233 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// 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.HashMap;
+import java.util.LinkedList;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Any Object which gets uploaded to GPU memory and thus needs to be re-created (transparently to
+ * applications!) whenever we lose OpenGL context.
+ *
+ * Keep all objects created in a static LinkedList. The point: we need to be able to mark
+ * Objects for deletion, and delete all marked Objects later at a convenient time (that's
+ * because we can only delete from a thread that holds the OpenGL context so here we provide a
+ * framework where one is able to mark for deletion at any time and actual deletion takes place
+ * on the next render).
+*/
+abstract class DistortedObject
+{
+  static final int FAILED_TO_CREATE = 1;
+  static final int NOT_CREATED_YET  = 2;
+  static final int DONT_CREATE      = 3;
+  static final int CREATED          = 4;
+
+  static final int TYPE_USER = 0;
+  static final int TYPE_TREE = 1;
+  static final int TYPE_SYST = 2;
+
+  private static final int JOB_CREATE = 0;
+  private static final int JOB_DELETE = 1;
+
+  private class Job
+    {
+    DistortedObject object;
+    int action;
+
+    Job(DistortedObject o, int a)
+      {
+      object = o;
+      action = a;
+      }
+    }
+
+  private static boolean mToDo = false;
+  private static LinkedList<DistortedObject> mDoneList = new LinkedList<>();
+  private static HashMap<Long,Job> mToDoMap = new HashMap<>();
+  private static long mNextClientID = 0;
+  private static long mNextSystemID = 0;
+
+  private long mID;
+  private int mType;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  abstract void create();
+  abstract void delete();
+  abstract void recreate();
+  abstract String printDetails();
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// must be called from a thread holding OpenGL Context
+
+  static synchronized boolean toDo()
+    {
+    if( mToDo )
+      {
+      Job job;
+      DistortedObject object;
+
+      for(Long key: mToDoMap.keySet())
+        {
+        job = mToDoMap.get(key);
+        object = job.object;
+
+        //android.util.Log.d("Object", object.getClass().getSimpleName()+"  ---> need to "
+        //                  +(job.action==JOB_CREATE ? "create":"delete")+" objectID="+object.mID );
+
+        if( job.action==JOB_CREATE )
+          {
+          object.create();
+          mDoneList.add(object);
+          }
+        else if( job.action==JOB_DELETE )
+          {
+          object.delete();
+          }
+        }
+
+      mToDoMap.clear();
+      mToDo = false;
+      return true;
+      }
+
+    return false;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  static synchronized void onPause()
+    {
+    DistortedObject object;
+    int num = mDoneList.size();
+
+    for(int i=0; i<num; i++)
+      {
+      object = mDoneList.removeFirst();
+      mToDoMap.put(object.mID, object.new Job(object,JOB_CREATE) );
+      object.recreate();
+      }
+
+    mToDo = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  static synchronized void onDestroy()
+    {
+    mToDoMap.clear();
+    mDoneList.clear();
+
+    mToDo = true;
+    mNextClientID = 0;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @SuppressWarnings("unused")
+  static void debugLists()
+    {
+    android.util.Log.e("Object", "Done list:");
+
+    DistortedObject object;
+    int num = mDoneList.size();
+
+    for(int i=0; i<num; i++)
+      {
+      object = mDoneList.get(i);
+      object.print("");
+      }
+
+    android.util.Log.e("Object", "ToDo list:");
+
+    Job job;
+
+    for(Long key: mToDoMap.keySet())
+      {
+      job = mToDoMap.get(key);
+      job.object.print(job.action==JOB_CREATE ? " create":" delete");
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void print(String msg)
+    {
+    String str = "ID:"+mID;
+
+    switch(mType)
+      {
+      case TYPE_SYST: str+=" SYSTEM "; break;
+      case TYPE_USER: str+=" USER   "; break;
+      case TYPE_TREE: str+=" TREE   "; break;
+      default       : str+=" ERROR? ";
+      }
+
+    android.util.Log.e("Object", str+printDetails()+msg);
+    }
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  DistortedObject(int create, int type)
+    {
+    mID  = type==TYPE_SYST ? --mNextSystemID : ++mNextClientID;
+    mType= type;
+
+    if( create!=DONT_CREATE )
+      {
+      mToDoMap.put(mID, new Job(this,JOB_CREATE) );
+      mToDo = true;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  synchronized void markForCreation()
+    {
+    mDoneList.remove(this);
+    mToDoMap.put(mID, new Job(this,JOB_CREATE) );
+    mToDo = true;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Mark the underlying OpenGL object for deletion. Actual deletion will take place on the next render.
+ */
+  synchronized public void markForDeletion()
+    {
+    mDoneList.remove(this);
+    mToDoMap.put(mID, new Job(this,JOB_DELETE) );
+    mToDo = true;
+    }
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Return unique ID of this Object.
+ */
+  public long getID()
+    {
+    return mID;
+    }
+
+}
diff --git a/src/main/java/org/distorted/library/DistortedOutputSurface.java b/src/main/java/org/distorted/library/DistortedOutputSurface.java
index 3f99e25..3778075 100644
--- a/src/main/java/org/distorted/library/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/DistortedOutputSurface.java
@@ -77,9 +77,6 @@ abstract class DistortedOutputSurface extends DistortedSurface implements Distor
 
     mProjectionMatrix = new float[16];
 
-    mWidth = width;
-    mHeight= height;
-
     mFOV = 60.0f;
     mNear=  0.5f;
 
@@ -181,14 +178,14 @@ abstract class DistortedOutputSurface extends DistortedSurface implements Distor
 
           for(int j=0; j<EffectQuality.LENGTH; j++)
             {
-            mBuffer1[j] = new DistortedFramebuffer( mDepthCreated!=DONT_CREATE, DistortedSurface.TYPE_SYST,
+            mBuffer1[j] = new DistortedFramebuffer( mDepthCreated!=DONT_CREATE, DistortedObject.TYPE_SYST,
                                                     (int)(mWidth*mipmap), (int)(mHeight*mipmap) );
-            mBuffer2[j] = new DistortedFramebuffer(false                     , DistortedSurface.TYPE_SYST,
+            mBuffer2[j] = new DistortedFramebuffer( false                     , DistortedObject.TYPE_SYST,
                                                     (int)(mWidth*mipmap), (int)(mHeight*mipmap) );
             mBuffer1[j].mMipmap = mipmap;
             mipmap *= EffectQuality.MULTIPLIER;
             }
-          DistortedSurface.toDo();  // create immediately
+          DistortedObject.toDo();  // create immediately
           }
 
         numRenders += child.draw(time,mBuffer1[currP.getQuality()]);
@@ -260,18 +257,7 @@ if( !sNew.equals(sOld) )
 /*
     if( changed2 )
       {
-      DistortedSurface.debugLists();
-      }
-*/
-    // create and delete all Meshes (we need to create Vertex Buffer Objects)
-/*
-    boolean changed3 =
-*/
-    MeshObject.toDo();
-/*
-    if( changed3 )
-      {
-      MeshObject.debugLists();
+      DistortedObject.debugLists();
       }
 */
     // mark OpenGL state as unknown
diff --git a/src/main/java/org/distorted/library/DistortedSurface.java b/src/main/java/org/distorted/library/DistortedSurface.java
index ef505ca..54c8da5 100644
--- a/src/main/java/org/distorted/library/DistortedSurface.java
+++ b/src/main/java/org/distorted/library/DistortedSurface.java
@@ -19,228 +19,37 @@
 
 package org.distorted.library;
 
-import java.util.HashMap;
-import java.util.LinkedList;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Keep all objects created in a static LinkedList. The point: we need to be able to mark
- * Objects for deletion, and delete all marked Objects later at a convenient time (that's
- * because we can only delete from a thread that holds the OpenGL context so here we provide a
- * framework where one is able to mark for deletion at any time and actual deletion takes place
- * on the next render).
-*/
-abstract class DistortedSurface
-  {
-  static final int FAILED_TO_CREATE = 1;
-  static final int NOT_CREATED_YET  = 2;
-  static final int DONT_CREATE      = 3;
-  static final int CREATED          = 4;
-
-  static final int TYPE_USER = 0;
-  static final int TYPE_TREE = 1;
-  static final int TYPE_SYST = 2;
-
-  private static final int JOB_CREATE = 0;
-  private static final int JOB_DELETE = 1;
-
-  private class Job
-    {
-    DistortedSurface surface;
-    int action;
-
-    Job(DistortedSurface s, int a)
-      {
-      surface = s;
-      action  = a;
-      }
-    }
-
-  private static boolean mToDo = false;
-  private static LinkedList<DistortedSurface> mDoneList = new LinkedList<>();
-  private static HashMap<Long,Job> mToDoMap = new HashMap<>();
-  private static long mNextClientID = 0;
-  private static long mNextSystemID = 0;
 
-  private long mID;
-  private int mType;
+abstract class DistortedSurface extends DistortedObject
+{
   int mColorCreated;
   int[] mColorH = new int[1];
   int mWidth, mHeight;
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  abstract void create();
-  abstract void delete();
-  abstract void recreate();
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// must be called from a thread holding OpenGL Context
-
-  static synchronized boolean toDo()
-    {
-    if( mToDo )
-      {
-      Job job;
-      DistortedSurface surface;
-
-      for(Long key: mToDoMap.keySet())
-        {
-        job = mToDoMap.get(key);
-        surface = job.surface;
-
-        //android.util.Log.d("SURFACE", "  ---> need to "+(job.action==JOB_CREATE ? "create":"delete")+" surfaceID="+surface.getID() );
-
-        if( job.action==JOB_CREATE )
-          {
-          surface.create();
-          mDoneList.add(surface);
-          }
-        else if( job.action==JOB_DELETE )
-          {
-          surface.delete();
-          }
-        }
-
-      mToDoMap.clear();
-      mToDo = false;
-      return true;
-      }
-
-    return false;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static synchronized void onPause()
-    {
-    DistortedSurface surface;
-    int num = mDoneList.size();
-
-    for(int i=0; i<num; i++)
-      {
-      surface = mDoneList.removeFirst();
-      mToDoMap.put(surface.getID(), surface.new Job(surface,JOB_CREATE) );
-      surface.recreate();
-      }
-
-    mToDo = true;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static synchronized void onDestroy()
-    {
-    mToDoMap.clear();
-    mDoneList.clear();
-
-    mToDo = true;
-    mNextClientID = 0;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @SuppressWarnings("unused")
-  static void debugLists()
-    {
-    android.util.Log.e("Surface", "Done list:");
-
-    DistortedSurface surface;
-    int num = mDoneList.size();
-
-    for(int i=0; i<num; i++)
-      {
-      surface = mDoneList.get(i);
-      surface.print(i, "");
-      }
-
-    android.util.Log.e("Surface", "ToDo list:");
-
-    Job job;
-    int i=0;
-
-    for(Long key: mToDoMap.keySet())
-      {
-      job = mToDoMap.get(key);
-      job.surface.print(i++, job.action==JOB_CREATE ? " create":" delete");
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void print(int i, String extra)
-    {
-    String str;
-
-    if( this instanceof DistortedFramebuffer ) str = (i+": Framebuffer ");
-    else if( this instanceof DistortedTexture) str = (i+": Texture     ");
-    else if( this instanceof DistortedScreen ) str = (i+": Screen      ");
-    else                                       str = (i+": UNKNOWN     ");
-
-    str += ("("+getWidth()+","+getHeight()+") surfaceID:"+getID());
-
-    switch(mType)
-      {
-      case TYPE_SYST: str+=" SYSTEM"; break;
-      case TYPE_USER: str+=" USER"  ; break;
-      case TYPE_TREE: str+=" TREE"  ; break;
-      default       : str+=" ERROR??";
-      }
-
-    android.util.Log.e("Surface", str+extra);
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   DistortedSurface(int width, int height, int create, int type)
     {
+    super(create,type);
+
     mWidth        = width ;
     mHeight       = height;
     mColorCreated = create;
     mColorH[0]    = 0;
-    mID           = type==TYPE_SYST ? --mNextSystemID : ++mNextClientID;
-    mType         = type;
-
-    if( create!=DONT_CREATE )
-      {
-      mToDoMap.put(mID, new Job(this,JOB_CREATE) );
-      mToDo = true;
-      }
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// debugging only
 
-  synchronized void markForCreation()
+  String printDetails()
     {
-    mDoneList.remove(this);
-    mToDoMap.put(mID, new Job(this,JOB_CREATE) );
-    mToDo = true;
+    return getClass().getSimpleName()+" "+mWidth+"x"+mHeight;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Mark the underlying OpenGL object for deletion. Actual deletion will take place on the next render.
- */
-  synchronized public void markForDeletion()
-    {
-    mDoneList.remove(this);
-    mToDoMap.put(mID, new Job(this,JOB_DELETE) );
-    mToDo = true;
-    }
-
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Return unique ID of this Surface.
- */
-  public long getID()
-    {
-    return mID;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
 /**
  * Return the width of this Surface.
  *
@@ -276,4 +85,4 @@ abstract class DistortedSurface
     {
     return mesh==null ? 0 : (int)(mWidth*mesh.zFactor);
     }
-  }
+}
diff --git a/src/main/java/org/distorted/library/MeshObject.java b/src/main/java/org/distorted/library/MeshObject.java
index 079a020..23e560d 100644
--- a/src/main/java/org/distorted/library/MeshObject.java
+++ b/src/main/java/org/distorted/library/MeshObject.java
@@ -22,8 +22,6 @@ package org.distorted.library;
 import android.opengl.GLES30;
 
 import java.nio.FloatBuffer;
-import java.util.HashMap;
-import java.util.LinkedList;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
@@ -33,37 +31,13 @@ import java.util.LinkedList;
  * If you want to render to a particular shape, extend from here, construct the three FloatBuffers and
  * provide correct dataLength, i.e. the number of vertices.
  */
-public abstract class MeshObject
+public abstract class MeshObject extends DistortedObject
    {
    static final int BYTES_PER_FLOAT   = 4; //
    static final int POSITION_DATA_SIZE= 3; // Size of the position data in elements
    static final int NORMAL_DATA_SIZE  = 3; // Size of the normal data in elements.
    static final int TEX_DATA_SIZE     = 2; // Size of the texture coordinate data in elements.
 
-   ///// CREATING/DELETING Vertex Buffer Objects ///////////////////////////
-   private static final int JOB_CREATE = 0;
-   private static final int JOB_DELETE = 1;
-
-   private class Job
-     {
-     MeshObject mesh;
-     int action;
-
-     Job(MeshObject o, int a)
-       {
-       mesh   = o;
-       action = a;
-       }
-     }
-
-   private static boolean mToDo = false;
-   private static LinkedList<MeshObject> mDoneList = new LinkedList<>();
-   private static HashMap<Long,Job> mToDoMap = new HashMap<>();
-   /////////////////////////////////////////////////////////////////////////
-
-   private static long mNextID = 0;
-   private long mID;
-
    int dataLength;
    FloatBuffer mMeshPositions, mMeshNormals, mMeshTexture;
    int[] mPosVBO = new int[1];
@@ -77,49 +51,10 @@ public abstract class MeshObject
 
    MeshObject(float factor)
      {
-     zFactor = factor;
-     mID     = mNextID++;
+     super(DistortedObject.NOT_CREATED_YET,DistortedObject.TYPE_USER);
 
+     zFactor = factor;
      recreate();
-
-     mToDoMap.put(mID, new Job(this,JOB_CREATE) );
-     mToDo = true;
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// must be called from a thread holding OpenGL Context
-
-   static synchronized boolean toDo()
-     {
-     if( mToDo )
-       {
-       Job job;
-       MeshObject mesh;
-
-       for(Long key: mToDoMap.keySet())
-         {
-         job = mToDoMap.get(key);
-         mesh = job.mesh;
-
-         //android.util.Log.d("MESH", "  ---> need to "+(job.action==JOB_CREATE ? "create":"delete") );
-
-         if( job.action==JOB_CREATE )
-           {
-           mesh.create();
-           mDoneList.add(mesh);
-           }
-         else if( job.action==JOB_DELETE )
-           {
-           mesh.delete();
-           }
-         }
-
-       mToDoMap.clear();
-       mToDo = false;
-       return true;
-       }
-
-     return false;
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -128,7 +63,7 @@ public abstract class MeshObject
 // Do NOT release mMeshPositions etc as we will need them when we need to re-create the buffers after
 // a loss of OpenGL context!
 
-   private void create()
+   void create()
      {
      if( mPosVBO[0]<0 )
        {
@@ -155,7 +90,7 @@ public abstract class MeshObject
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // must be called from a thread holding OpenGL Context
 
-   private void delete()
+   void delete()
      {
      if( mPosVBO[0]>=0 )
        {
@@ -176,7 +111,7 @@ public abstract class MeshObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-   private void recreate()
+   void recreate()
      {
      mPosVBO[0] = -1;
      mNorVBO[0] = -1;
@@ -184,75 +119,13 @@ public abstract class MeshObject
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// debugging only
 
-  static synchronized void onPause()
-    {
-    MeshObject mesh;
-    int num = mDoneList.size();
-
-    for(int i=0; i<num; i++)
-      {
-      mesh = mDoneList.removeFirst();
-      mToDoMap.put(mesh.getID(), mesh.new Job(mesh,JOB_CREATE) );
-      mesh.recreate();
-      }
-
-    mToDo = true;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static synchronized void onDestroy()
-    {
-    mToDoMap.clear();
-    mDoneList.clear();
-
-    mToDo = true;
-    mNextID = 0;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  @SuppressWarnings("unused")
-  static void debugLists()
-    {
-    android.util.Log.e("Mesh", "Done list:");
-
-    MeshObject mesh;
-    int num = mDoneList.size();
-
-    for(int i=0; i<num; i++)
-      {
-      mesh = mDoneList.get(i);
-      mesh.print(i, "");
-      }
-
-    android.util.Log.e("Mesh", "ToDo list:");
-
-    Job job;
-    int i=0;
-
-    for(Long key: mToDoMap.keySet())
-      {
-      job = mToDoMap.get(key);
-      job.mesh.print(i++, job.action==JOB_CREATE ? " create":" delete");
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void print(int i, String extra)
-    {
-    String str;
-
-         if( this instanceof MeshFlat ) str = (i+": MeshFlat  ");
-    else if( this instanceof MeshCubes) str = (i+": MeshCubes ");
-    else                                str = (i+": UNKNOWN   ");
-
-    str += ( "dataLength: "+dataLength+" meshID:"+getID());
+   String printDetails()
+     {
+     return getClass().getSimpleName()+" vertices:"+dataLength;
+     }
 
-    android.util.Log.e("Mesh", str+extra);
-    }
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Get the minimal set of Vertices which have the same convex hull as the whole set.
@@ -263,35 +136,5 @@ public abstract class MeshObject
  * This is used to be able to quickly compute, in window coordinates, the Mesh'es bounding rectangle.
  */
    abstract float[] getBoundingVertices();
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-   synchronized void markForCreation()
-     {
-     mDoneList.remove(this);
-     mToDoMap.put(mID, new Job(this,JOB_CREATE) );
-     mToDo = true;
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Mark the underlying OpenGL object for deletion. Actual deletion will take place on the next render.
- */
-   synchronized public void markForDeletion()
-     {
-     mDoneList.remove(this);
-     mToDoMap.put(mID, new Job(this,JOB_DELETE) );
-     mToDo = true;
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Return unique ID of this Mesh.
- */
-   public long getID()
-    {
-    return mID;
-    }
    }
+
