commit f8686932d564d9bebf968e29b226cc8031cd3d19
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Dec 19 16:29:36 2016 +0000

    Minor.

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 646059c..9923d06 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -70,8 +70,6 @@ public class Distorted
    */
   public static final int CLONE_CHILDREN= 0x10;
 
-  private static boolean mInitialized = false;
-
   static int[] mMainProgramAttributes;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -85,7 +83,7 @@ public class Distorted
 
   static boolean isInitialized()
     {
-    return mInitialized;
+    return (mMainProgramAttributes!=null);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -105,8 +103,6 @@ public class Distorted
   public static void onCreate(final Context context)
   throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
     { 
-    mInitialized = true;  
-
     final InputStream vertexStream   = context.getResources().openRawResource(R.raw.main_vertex_shader);
     final InputStream fragmentStream = context.getResources().openRawResource(R.raw.main_fragment_shader);
 
@@ -116,8 +112,6 @@ public class Distorted
     mainProgram.bindAndEnableAttributes();
     mMainProgramAttributes = mainProgram.getAttributes();
 
-    int textureUniformH = GLES20.glGetUniformLocation(programH, "u_Texture");
-
     GLES20.glEnable (GLES20.GL_DEPTH_TEST);
     GLES20.glDepthFunc(GLES20.GL_LEQUAL);
     GLES20.glEnable(GLES20.GL_BLEND);
@@ -125,12 +119,11 @@ public class Distorted
     GLES20.glEnable(GLES20.GL_CULL_FACE);
     GLES20.glCullFace(GLES20.GL_BACK);
     GLES20.glFrontFace(GLES20.GL_CW);
-    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
-    GLES20.glUniform1i(textureUniformH, 0);
 
     EffectQueueFragment.getUniforms(programH);
     EffectQueueVertex.getUniforms(programH);
     EffectQueueMatrix.getUniforms(programH);
+    DistortedTexture.getUniforms(programH);
 
     DistortedTree.reset();
     EffectMessageSender.startSending();
@@ -149,7 +142,7 @@ public class Distorted
     EffectQueue.onDestroy();
     DistortedEffects.onDestroy();
     EffectMessageSender.stopSending();
-   
-    mInitialized = false;
+
+    mMainProgramAttributes = null;
     }
   }
diff --git a/src/main/java/org/distorted/library/DistortedTexture.java b/src/main/java/org/distorted/library/DistortedTexture.java
index 21cbafe..22a6d3b 100644
--- a/src/main/java/org/distorted/library/DistortedTexture.java
+++ b/src/main/java/org/distorted/library/DistortedTexture.java
@@ -44,6 +44,8 @@ public class DistortedTexture
   private static boolean mListMarked = false;
   private static LinkedList<DistortedTexture> mList = new LinkedList<>();
 
+  private static int mTextureH;
+
   private int mSizeX, mSizeY;  // in screen space
   float mHalfX, mHalfY;        // halves of the above
   private long mID;
@@ -118,6 +120,16 @@ public class DistortedTexture
     return mID;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  static void getUniforms(int mProgramH)
+    {
+    mTextureH= GLES20.glGetUniformLocation( mProgramH, "u_Texture");
+
+    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
+    GLES20.glUniform1i(mTextureH, 0);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   static synchronized void onDestroy()
