commit 6173632c20d99e0fa2e5c61eca0898b8123504e7
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Jun 12 13:03:37 2017 +0100

    Further progress with Apps: 21 (out of 30) compile now.

diff --git a/src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java b/src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java
index 8e69a87..7619938 100644
--- a/src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java
+++ b/src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java
@@ -28,10 +28,10 @@ import android.graphics.Paint;
 import android.graphics.Paint.Style;
 import android.opengl.GLSurfaceView;
 
+import org.distorted.library.effect.EffectName;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.main.DistortedEffects;
-import org.distorted.library.EffectNames;
 import org.distorted.library.main.MeshFlat;
 import org.distorted.library.main.Distorted;
 
@@ -109,11 +109,11 @@ class MovingEffectsRenderer implements GLSurfaceView.Renderer
 
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
      {
-     DistortedEffects.enableEffect(EffectNames.SWIRL);
-     DistortedEffects.enableEffect(EffectNames.SMOOTH_ALPHA);
-     DistortedEffects.enableEffect(EffectNames.SMOOTH_CHROMA);
-     DistortedEffects.enableEffect(EffectNames.DISTORT);
-     DistortedEffects.enableEffect(EffectNames.SINK);
+     DistortedEffects.enableEffect(EffectName.SWIRL);
+     DistortedEffects.enableEffect(EffectName.SMOOTH_ALPHA);
+     DistortedEffects.enableEffect(EffectName.SMOOTH_CHROMA);
+     DistortedEffects.enableEffect(EffectName.DISTORT);
+     DistortedEffects.enableEffect(EffectName.SINK);
 
      try
        {
diff --git a/src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java b/src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
index 7766be7..2e48a7b 100644
--- a/src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
+++ b/src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
@@ -27,8 +27,13 @@ import android.opengl.GLSurfaceView;
 import android.view.MotionEvent;
 import android.util.AttributeSet;
 
+import org.distorted.library.effect.EffectType;
+import org.distorted.library.effect.FragmentEffectAlpha;
+import org.distorted.library.effect.FragmentEffectChroma;
+import org.distorted.library.effect.VertexEffectDistort;
+import org.distorted.library.effect.VertexEffectSink;
+import org.distorted.library.effect.VertexEffectSwirl;
 import org.distorted.library.main.DistortedEffects;
-import org.distorted.library.EffectTypes;
 import org.distorted.library.type.Dynamic3D;
 import org.distorted.library.type.Dynamic4D;
 import org.distorted.library.type.Static1D;
@@ -42,7 +47,7 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
     {
     private static final int LOOP_TIME = 5000;
     private static final int NUM_POINTS= 100;
-   
+
     public static final int EFFECT_POINTS=0;
     public static final int EFFECT_BUBBLE=1;
     public static final int EFFECT_SINK  =2;
@@ -66,6 +71,12 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
 
     private MovingEffectsRenderer mRenderer;
 
+    private VertexEffectDistort mEffectDistort;
+    private VertexEffectSink mEffectSink;
+    private VertexEffectSwirl mEffectSwirl;
+    private FragmentEffectChroma mEffectChroma;
+    private FragmentEffectAlpha mEffectAlpha;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
     public MovingEffectsSurfaceView(Context context, AttributeSet attrs)
@@ -88,6 +99,12 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
         setFocusableInTouchMode(true);
         setRenderer(mRenderer);
         }
+
+      mEffectDistort = new VertexEffectDistort(new Static3D(0,0,mMax/10) , di3D, dr);
+      mEffectSink    = new VertexEffectSink(new Static1D(10), di3D, dr);
+      mEffectSwirl   = new VertexEffectSwirl( new Static1D(30), di3D, dr);
+      mEffectAlpha   = new FragmentEffectAlpha(new Static1D(0.5f), mRegion, true);
+      mEffectChroma  = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mRegion, true);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -119,9 +136,9 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
       synchronized(lock)
         {
         DistortedEffects q = mRenderer.getEffects();
-        q.abortEffects(EffectTypes.VERTEX);
-        q.abortEffects(EffectTypes.FRAGMENT);
-        q.distort( new Static3D(0,0,mMax/10) , di3D, dr);
+        q.abortByType(EffectType.VERTEX);
+        q.abortByType(EffectType.FRAGMENT);
+        q.apply(mEffectDistort);
         mCurrEffect = EFFECT_BUBBLE;
         }
       }
@@ -135,9 +152,9 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
       synchronized(lock)
         {
         DistortedEffects q = mRenderer.getEffects();
-        q.abortEffects(EffectTypes.VERTEX);
-        q.abortEffects(EffectTypes.FRAGMENT);
-        q.sink(new Static1D(10), di3D, dr);
+        q.abortByType(EffectType.VERTEX);
+        q.abortByType(EffectType.FRAGMENT);
+        q.apply(mEffectSink);
         mCurrEffect = EFFECT_SINK;
         }
       }
@@ -151,9 +168,9 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
       synchronized(lock)
         {
         DistortedEffects q = mRenderer.getEffects();
-        q.abortEffects(EffectTypes.VERTEX);
-        q.abortEffects(EffectTypes.FRAGMENT);
-        q.chroma(new Static1D(0.5f), new Static3D(1,0,0), mRegion, true);
+        q.abortByType(EffectType.VERTEX);
+        q.abortByType(EffectType.FRAGMENT);
+        q.apply(mEffectChroma);
         mCurrEffect = EFFECT_CHROMA;
         }
       }
@@ -167,9 +184,9 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
       synchronized(lock)
         {
         DistortedEffects q = mRenderer.getEffects();
-        q.abortEffects(EffectTypes.VERTEX);
-        q.abortEffects(EffectTypes.FRAGMENT);
-        q.alpha(new Static1D(0.5f), mRegion, true);
+        q.abortByType(EffectType.VERTEX);
+        q.abortByType(EffectType.FRAGMENT);
+        q.apply(mEffectAlpha);
         mCurrEffect = EFFECT_TRANS;
         }
       }
@@ -183,9 +200,9 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
       synchronized(lock)
         {
         DistortedEffects q = mRenderer.getEffects();
-        q.abortEffects(EffectTypes.VERTEX);
-        q.abortEffects(EffectTypes.FRAGMENT);
-        q.swirl( new Static1D(30), di3D, dr);
+        q.abortByType(EffectType.VERTEX);
+        q.abortByType(EffectType.FRAGMENT);
+        q.apply(mEffectSwirl);
         mCurrEffect = EFFECT_SWIRL;
         }
       }
@@ -197,8 +214,8 @@ public class MovingEffectsSurfaceView extends GLSurfaceView
       synchronized(lock)
         {
         DistortedEffects q = mRenderer.getEffects();
-        q.abortEffects(EffectTypes.VERTEX);
-        q.abortEffects(EffectTypes.FRAGMENT);
+        q.abortByType(EffectType.VERTEX);
+        q.abortByType(EffectType.FRAGMENT);
         di3D.removeAll();
         mRegion.removeAll();
         mCurrEffect = EFFECT_POINTS;
diff --git a/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java b/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
index 1d2eeee..964620d 100644
--- a/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
+++ b/src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java
@@ -27,11 +27,14 @@ import javax.microedition.khronos.opengles.GL10;
 
 import org.distorted.examples.R;
 
+import org.distorted.library.effect.EffectName;
+import org.distorted.library.effect.FragmentEffectChroma;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectRotate;
+import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedNode;
-import org.distorted.library.EffectNames;
-import org.distorted.library.EffectTypes;
 import org.distorted.library.main.MeshFlat;
 import org.distorted.library.type.Dynamic1D;
 import org.distorted.library.type.Static3D;
@@ -58,6 +61,7 @@ class OlimpicRenderer implements GLSurfaceView.Renderer
    private MeshFlat mMesh;
    private int mScreenW, mScreenH;
    private int mPrevRendered, mCurrRendered;
+   private Static3D mMove, mScale;
 
    private DistortedNode[] mCircleNode = new DistortedNode[NUM_CIRCLES];
    private DistortedEffects[] mEffects = new DistortedEffects[NUM_LEAVES];
@@ -114,16 +118,16 @@ class OlimpicRenderer implements GLSurfaceView.Renderer
       for(int j=0; j<NUM_LEAVES; j++)
         {
         mEffects[j] = new DistortedEffects();
-        mEffects[j].rotate( new Static1D(j*(360/NUM_LEAVES)), axis, center );
-        mEffects[j].move(moveVector);
+        mEffects[j].apply( new MatrixEffectRotate(new Static1D(j*(360/NUM_LEAVES)), axis, center) );
+        mEffects[j].apply(new MatrixEffectMove(moveVector));
         }
 
       for(int i=0; i<NUM_CIRCLES; i++)
         {
         effects = new DistortedEffects();
-        effects.move( new Static3D(positions[2*i], positions[2*i+1], 0) );
-        effects.rotate( rot, axis, center );
-        effects.chroma( new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]) );
+        effects.apply( new MatrixEffectMove(new Static3D(positions[2*i], positions[2*i+1], 0)) );
+        effects.apply( new MatrixEffectRotate(rot, axis, center) );
+        effects.apply( new FragmentEffectChroma(new Static1D(0.5f), new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2])) );
 
         mCircleNode[i] = new DistortedNode( surface, effects, mMesh);
         mRoot.attach(mCircleNode[i]);
@@ -133,92 +137,88 @@ class OlimpicRenderer implements GLSurfaceView.Renderer
 
       mScreen = new DistortedScreen(mView);
       mScreen.attach(mRoot);
+
+      mMove = new Static3D(0,0,0);
+      mScale= new Static3D(1,1,1);
+      effects.apply(new MatrixEffectMove(mMove));
+      effects.apply(new MatrixEffectScale(mScale));
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-    public void onDrawFrame(GL10 glUnused) 
-      {
-      mCurrRendered = mScreen.render(System.currentTimeMillis());
+   public void onDrawFrame(GL10 glUnused)
+     {
+     mCurrRendered = mScreen.render(System.currentTimeMillis());
 
-      if( mCurrRendered!=mPrevRendered )
-        {
-        mPrevRendered = mCurrRendered;
+     if( mCurrRendered!=mPrevRendered )
+       {
+       mPrevRendered = mCurrRendered;
 
-        final OlimpicActivity act = (OlimpicActivity)mView.getContext();
+       final OlimpicActivity act = (OlimpicActivity)mView.getContext();
 
-        act.runOnUiThread(new Runnable()
+       act.runOnUiThread(new Runnable()
           {
           public void run()
             {
-            act.setText("rendered: "+mCurrRendered+" objects");
-            }
+           act.setText("rendered: "+mCurrRendered+" objects");
+           }
           });
-        }
-      }
+       }
+     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
-    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
-      {
-      DistortedEffects effects = mRoot.getEffects();
-
-      effects.abortEffects(EffectTypes.MATRIX);
-      
-      if( (float)mScreenH/mScreenW > (float)height/width )
-        {
-        int w = (height*mScreenW)/mScreenH;
-        float factor = (float)height/mScreenH;
-
-        effects.move( new Static3D((width-w)/2 ,0, 0) );
-        effects.scale( factor );
-        }
-      else
-        {
-        int h = (width*mScreenH)/mScreenW;
-        float factor = (float)width/mScreenW;
-
-        effects.move( new Static3D(0,(height-h)/2,0) );
-        effects.scale( factor );
-        }
+   public void onSurfaceChanged(GL10 glUnused, int width, int height)
+     {
+     if( (float)mScreenH/mScreenW > (float)height/width )
+       {
+       int w = (height*mScreenW)/mScreenH;
+       float factor = (float)height/mScreenH;
+       mMove.set((width-w)/2 ,0, 0);
+       mScale.set(factor,factor,factor);
+       }
+     else
+       {
+       int h = (width*mScreenH)/mScreenW;
+       float factor = (float)width/mScreenW;
+       mMove.set(0,(height-h)/2,0);
+       mScale.set(factor,factor,factor);
+       }
       
-      mScreen.resize(width, height);
-      }
+     mScreen.resize(width, height);
+     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
-    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
-      {
-      InputStream is = mView.getContext().getResources().openRawResource(R.raw.leaf);
-      Bitmap leaf;
+   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
+     {
+     InputStream is = mView.getContext().getResources().openRawResource(R.raw.leaf);
+     Bitmap leaf;
       
-      try 
-        {
-        leaf = BitmapFactory.decodeStream(is);
-        } 
-      finally 
-        {
-        try 
-          {
-          is.close();
-          } 
-        catch(IOException e) { }
-        }  
+     try
+       {
+       leaf = BitmapFactory.decodeStream(is);
+       }
+     finally
+       {
+       try
+         {
+         is.close();
+         }
+       catch(IOException e) { }
+       }
       
-      mLeaf.setTexture(leaf);
+     mLeaf.setTexture(leaf);
 
-      DistortedEffects.enableEffect(EffectNames.CHROMA);
+     DistortedEffects.enableEffect(EffectName.CHROMA);
 
-      try
-        {
-        Distorted.onCreate(mView.getContext());
-        }
-      catch(Exception ex)
-        {
-        android.util.Log.e("Olympic", ex.getMessage() );
-        }
-      }
- 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-    
+     try
+       {
+       Distorted.onCreate(mView.getContext());
+       }
+     catch(Exception ex)
+       {
+       android.util.Log.e("Olympic", ex.getMessage() );
+       }
+     }
 }
