commit c40df162dd9326e705f0f1268a103fa78c927a13
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Dec 14 16:30:10 2018 +0000

    Improve the Triblur app to be able to switch objects into 1 of 3 states: no postprocessing, blur, glow.

diff --git a/src/main/java/org/distorted/examples/triblur/TriblurActivity.java b/src/main/java/org/distorted/examples/triblur/TriblurActivity.java
index c32a7e7..70ea826 100644
--- a/src/main/java/org/distorted/examples/triblur/TriblurActivity.java
+++ b/src/main/java/org/distorted/examples/triblur/TriblurActivity.java
@@ -37,6 +37,16 @@ import org.distorted.library.main.Distorted;
 
 public class TriblurActivity extends Activity implements SeekBar.OnSeekBarChangeListener, AdapterView.OnItemSelectedListener
 {
+    private static final int NONE0 = 0;
+    private static final int NONE1 = 1;
+    private static final int NONE2 = 2;
+    private static final int BLUR0 = 3;
+    private static final int BLUR1 = 4;
+    private static final int BLUR2 = 5;
+    private static final int GLOW0 = 6;
+    private static final int GLOW1 = 7;
+    private static final int GLOW2 = 8;
+
     private int mQuality;
     private int mBackground;
 
@@ -64,6 +74,9 @@ public class TriblurActivity extends Activity implements SeekBar.OnSeekBarChange
 
         privateQuality(1);
         privateBackgroundColor(1);
+        privateEffect(BLUR0);
+        privateEffect(BLUR1);
+        privateEffect(BLUR2);
         }
 
       Spinner typeSpinner  = findViewById(R.id.triblur_spinnerQuality);
@@ -146,7 +159,7 @@ public class TriblurActivity extends Activity implements SeekBar.OnSeekBarChange
       TriblurSurfaceView view = this.findViewById(R.id.triblurSurfaceView);
       TriblurRenderer renderer = view.getRenderer();
 
-      savedInstanceState.putBooleanArray("checkboxes", renderer.getChecked() );
+      savedInstanceState.putIntArray("effects", renderer.getEffects() );
       savedInstanceState.putInt("quality", mQuality);
       savedInstanceState.putInt("background", mBackground);
       }
@@ -158,16 +171,16 @@ public class TriblurActivity extends Activity implements SeekBar.OnSeekBarChange
       {
       super.onRestoreInstanceState(savedInstanceState);
 
-      boolean[] checkboxes = savedInstanceState.getBooleanArray("checkboxes");
+      int[] effects = savedInstanceState.getIntArray("effects");
 
       TriblurSurfaceView view = this.findViewById(R.id.triblurSurfaceView);
       TriblurRenderer renderer = view.getRenderer();
 
-      if( checkboxes!=null )
+      if( effects!=null )
         {
-        for(int i=0; i<checkboxes.length; i++)
+        for(int i=0; i<effects.length; i++)
           {
-          renderer.setChecked(i,checkboxes[i]);
+          renderer.setEffects(i,effects[i]);
           }
         }
 
@@ -206,17 +219,40 @@ public class TriblurActivity extends Activity implements SeekBar.OnSeekBarChange
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void onClick(View view)
+  public void effect(View v)
+    {
+    switch(v.getId())
+      {
+      case R.id.triblurRadioNone0: privateEffect(NONE0); break;
+      case R.id.triblurRadioNone1: privateEffect(NONE1); break;
+      case R.id.triblurRadioNone2: privateEffect(NONE2); break;
+      case R.id.triblurRadioBlur0: privateEffect(BLUR0); break;
+      case R.id.triblurRadioBlur1: privateEffect(BLUR1); break;
+      case R.id.triblurRadioBlur2: privateEffect(BLUR2); break;
+      case R.id.triblurRadioGlow0: privateEffect(GLOW0); break;
+      case R.id.triblurRadioGlow1: privateEffect(GLOW1); break;
+      case R.id.triblurRadioGlow2: privateEffect(GLOW2); break;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void privateEffect(int index)
     {
-    CheckBox box = (CheckBox)view;
-    boolean checked = box.isChecked();
-    TriblurSurfaceView sView = this.findViewById(R.id.triblurSurfaceView);
+    TriblurSurfaceView view = this.findViewById(R.id.triblurSurfaceView);
+    TriblurRenderer renderer = view.getRenderer();
 
-    switch(box.getId())
+    switch(index)
       {
-      case R.id.triblurCheckBox0  : sView.getRenderer().setChecked(0,checked); break;
-      case R.id.triblurCheckBox1  : sView.getRenderer().setChecked(1,checked); break;
-      case R.id.triblurCheckBox2  : sView.getRenderer().setChecked(2,checked); break;
+      case NONE0: renderer.setEffects(0,0); break;
+      case NONE1: renderer.setEffects(1,0); break;
+      case NONE2: renderer.setEffects(2,0); break;
+      case BLUR0: renderer.setEffects(0,1); break;
+      case BLUR1: renderer.setEffects(1,1); break;
+      case BLUR2: renderer.setEffects(2,1); break;
+      case GLOW0: renderer.setEffects(0,2); break;
+      case GLOW1: renderer.setEffects(1,2); break;
+      case GLOW2: renderer.setEffects(2,2); break;
       }
     }
 
diff --git a/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java b/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
index 485f176..e78a768 100644
--- a/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
+++ b/src/main/java/org/distorted/examples/triblur/TriblurRenderer.java
@@ -25,11 +25,13 @@ import android.opengl.GLSurfaceView;
 
 import org.distorted.examples.R;
 import org.distorted.library.effect.EffectQuality;
+import org.distorted.library.effect.EffectType;
 import org.distorted.library.effect.FragmentEffectChroma;
 import org.distorted.library.effect.MatrixEffectMove;
 import org.distorted.library.effect.MatrixEffectQuaternion;
 import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.effect.PostprocessEffectBlur;
+import org.distorted.library.effect.PostprocessEffectGlow;
 import org.distorted.library.main.Distorted;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedNode;
@@ -65,10 +67,11 @@ class TriblurRenderer implements GLSurfaceView.Renderer
     private GLSurfaceView mView;
     private DistortedTexture mTex;
     private DistortedNode[] mNode;
-    private Static1D[]  mBlurVector;
+    private Static1D[]  mEffectVector;
     private DistortedScreen mScreen;
     private PostprocessEffectBlur[] mBlur;
-    private boolean[] mBlurStatus;
+    private PostprocessEffectGlow[] mGlow;
+    private int[] mEffectStatus;
     private Static3D mMove1, mMove2, mScale1, mScale2, mCenter;
 
     Static4D mQuat1, mQuat2;
@@ -90,10 +93,11 @@ class TriblurRenderer implements GLSurfaceView.Renderer
       mScreen = new DistortedScreen();
       mScreen.showFPS();
 
-      mBlurStatus   = new boolean[NUM_OBJECTS];
-      mBlurVector   = new Static1D[NUM_OBJECTS];
+      mEffectStatus = new int[NUM_OBJECTS];
+      mEffectVector = new Static1D[NUM_OBJECTS];
       mNode         = new DistortedNode[NUM_OBJECTS];
       mBlur         = new PostprocessEffectBlur[NUM_OBJECTS];
+      mGlow         = new PostprocessEffectGlow[NUM_OBJECTS];
 
       FragmentEffectChroma[] chroma= new FragmentEffectChroma[NUM_OBJECTS];
       Static3D[] chromaVector      = new Static3D[NUM_OBJECTS];
@@ -118,8 +122,9 @@ class TriblurRenderer implements GLSurfaceView.Renderer
         {
         moveVector[i]    = new Static3D(OBJECTS[NUM*i  ], OBJECTS[NUM*i+1], OBJECTS[NUM*i+2]);
         chromaVector[i]  = new Static3D(OBJECTS[NUM*i+3], OBJECTS[NUM*i+4], OBJECTS[NUM*i+5]);
-        mBlurVector[i]   = new Static1D(10);
-        mBlur[i]         = new PostprocessEffectBlur(mBlurVector[i]);
+        mEffectVector[i] = new Static1D(10);
+        mBlur[i]         = new PostprocessEffectBlur(mEffectVector[i]);
+        mGlow[i]         = new PostprocessEffectGlow(mEffectVector[i], new Static4D(1.0f,1.0f,1.0f,0.5f) );
         chroma[i]        = new FragmentEffectChroma( new Static1D(0.3f), chromaVector[i]);
         effects[i]       = new DistortedEffects();
 
@@ -131,7 +136,7 @@ class TriblurRenderer implements GLSurfaceView.Renderer
         effects[i].apply(quatEffect2);
         effects[i].apply(new MatrixEffectMove(moveVector[i]));
 
-        mBlurStatus[i] = true;
+        mEffectStatus[i] = 1;
         mNode[i] = new DistortedNode(mTex, effects[i], mesh );
         mScreen.attach(mNode[i]);
         }
@@ -227,37 +232,35 @@ class TriblurRenderer implements GLSurfaceView.Renderer
       {
       if( object>=0 && object<NUM_OBJECTS )
         {
-        mBlurVector[object].set(range / 2);
+        mEffectVector[object].set(range / 2);
         }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    boolean[] getChecked()
+    int[] getEffects()
      {
-     return mBlurStatus;
+     return mEffectStatus;
      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    void setChecked(int object, boolean checked)
+    void setEffects(int object, int effect)
       {
       if( object>=0 && object<NUM_OBJECTS )
         {
-        if( checked && !mBlurStatus[object] )
+        if( mEffectStatus[object] != effect )
           {
-          mBlurStatus[object] = true;
-          mNode[object].getEffects().apply(mBlur[object]);
-          }
-        if( !checked && mBlurStatus[object] )
-          {
-          mBlurStatus[object] = false;
-          mNode[object].getEffects().abortEffect(mBlur[object]);
+          mEffectStatus[object] = effect;
+          mNode[object].getEffects().abortByType(EffectType.POSTPROCESS);
+
+          if( effect==1 ) mNode[object].getEffects().apply(mBlur[object]);
+          if( effect==2 ) mNode[object].getEffects().apply(mGlow[object]);
           }
         }
       else
         {
-        android.util.Log.e("renderer", "Error, number: "+object+" checked: "+checked );
+        android.util.Log.e("renderer", "Error, number: "+object+" effect: "+effect );
         }
 
       //android.util.Log.d("renderer", "setting box "+number+" BLUR state to "+checked);
diff --git a/src/main/res/layout/triblurlayout.xml b/src/main/res/layout/triblurlayout.xml
index 0eb8eac..ca36c85 100644
--- a/src/main/res/layout/triblurlayout.xml
+++ b/src/main/res/layout/triblurlayout.xml
@@ -10,7 +10,6 @@
         android:layout_height="0dp"
         android:layout_weight="1" />
 
-
     <LinearLayout
         android:id="@+id/linearLayout3"
         android:layout_width="fill_parent"
@@ -35,75 +34,162 @@
     </LinearLayout>
 
     <LinearLayout
-        android:orientation="horizontal"
-        android:background="@color/red"
         android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:paddingBottom="10dp"
-        android:paddingTop="10dp">
+        android:layout_height="60dp"
+        android:background="@color/red"
+        android:orientation="horizontal"
+        android:paddingTop="5dp">
 
-        <CheckBox
-            android:layout_height="fill_parent"
-            android:layout_width="wrap_content"
-            android:id="@+id/triblurCheckBox0"
-            android:paddingLeft="10dp"
-            android:onClick="onClick"
-            android:checked="true"/>
+        <RadioGroup
+            android:id="@+id/triblurRadio0"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.6"
+            android:orientation="horizontal">
+
+            <RadioButton
+                android:id="@+id/triblurRadioNone0"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="effect"
+                android:text="@string/none"
+                android:textSize="14sp" />
+
+            <RadioButton
+                android:id="@+id/triblurRadioBlur0"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:checked="true"
+                android:onClick="effect"
+                android:text="@string/blur"
+                android:textSize="14sp" />
+
+            <RadioButton
+                android:id="@+id/triblurRadioGlow0"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="effect"
+                android:text="@string/glow"
+                android:textSize="14sp" />
+
+        </RadioGroup>
 
         <SeekBar
             android:id="@+id/triblurSeek0"
+            android:layout_width="wrap_content"
             android:layout_height="fill_parent"
-            android:layout_width="fill_parent"
-            android:paddingLeft="10dp"
-            android:paddingRight="10dp" />
+            android:layout_weight="0.4"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp" />
     </LinearLayout>
 
     <LinearLayout
-        android:orientation="horizontal"
-        android:background="@color/yellow"
         android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:paddingBottom="10dp"
-        android:paddingTop="10dp">
+        android:layout_height="60dp"
+        android:background="@color/yellow"
+        android:orientation="horizontal"
+        android:paddingTop="5dp">
 
-        <CheckBox
-            android:layout_height="fill_parent"
-            android:layout_width="wrap_content"
-            android:id="@+id/triblurCheckBox1"
-            android:paddingLeft="10dp"
-            android:onClick="onClick"
-            android:checked="true"/>
+        <RadioGroup
+            android:id="@+id/triblurRadio1"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.6"
+            android:orientation="horizontal">
+
+            <RadioButton
+                android:id="@+id/triblurRadioNone1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="effect"
+                android:text="@string/none"
+                android:textSize="14sp" />
+
+            <RadioButton
+                android:id="@+id/triblurRadioBlur1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:checked="true"
+                android:onClick="effect"
+                android:text="@string/blur"
+                android:textSize="14sp" />
+
+            <RadioButton
+                android:id="@+id/triblurRadioGlow1"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="effect"
+                android:text="@string/glow"
+                android:textSize="14sp" />
+
+        </RadioGroup>
 
         <SeekBar
             android:id="@+id/triblurSeek1"
+            android:layout_width="wrap_content"
             android:layout_height="fill_parent"
-            android:layout_width="fill_parent"
-            android:paddingLeft="10dp"
-            android:paddingRight="10dp" />
+            android:layout_weight="0.4"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp" />
     </LinearLayout>
 
     <LinearLayout
-        android:orientation="horizontal"
-        android:background="@color/green"
         android:layout_width="match_parent"
-        android:layout_height="50dp"
-        android:paddingBottom="10dp"
-        android:paddingTop="10dp">
+        android:layout_height="60dp"
+        android:background="@color/green"
+        android:orientation="horizontal"
+        android:paddingTop="5dp">
 
-        <CheckBox
-            android:layout_height="fill_parent"
-            android:layout_width="wrap_content"
-            android:id="@+id/triblurCheckBox2"
-            android:paddingLeft="10dp"
-            android:onClick="onClick"
-            android:checked="true"/>
+        <RadioGroup
+            android:id="@+id/triblurRadio2"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.6"
+            android:orientation="horizontal">
+
+            <RadioButton
+                android:id="@+id/triblurRadioNone2"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="effect"
+                android:text="@string/none"
+                android:textSize="14sp" />
+
+            <RadioButton
+                android:id="@+id/triblurRadioBlur2"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:checked="true"
+                android:onClick="effect"
+                android:text="@string/blur"
+                android:textSize="14sp" />
+
+            <RadioButton
+                android:id="@+id/triblurRadioGlow2"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:onClick="effect"
+                android:text="@string/glow"
+                android:textSize="14sp" />
+
+        </RadioGroup>
 
         <SeekBar
             android:id="@+id/triblurSeek2"
+            android:layout_width="wrap_content"
             android:layout_height="fill_parent"
-            android:layout_width="fill_parent"
-            android:paddingLeft="10dp"
-            android:paddingRight="10dp" />
+            android:layout_weight="0.4"
+            android:paddingLeft="5dp"
+            android:paddingRight="5dp" />
     </LinearLayout>
 
     <LinearLayout
@@ -113,8 +199,8 @@
         android:gravity="center|fill_horizontal"
         android:orientation="horizontal"
         android:background="@color/cyan"
-        android:paddingBottom="10dp"
-        android:paddingTop="10dp" >
+        android:paddingBottom="2dp"
+        android:paddingTop="2dp" >
 
         <RadioGroup
             android:id="@+id/triblurRadioBackground"
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 0d7bc9a..d055d44 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -14,6 +14,7 @@
     <string name="contrast">Contrast</string>
     <string name="swirl">Swirl</string>
     <string name="blur">Blur</string>
+    <string name="glow">Glow</string>
 
     <string name="type_matrix">Matrix</string>
     <string name="type_vertex">Vertex</string>
@@ -76,6 +77,7 @@
     <string name="framebuffer">Framebuffer</string>
     <string name="matrixautomatic">Automatic Matrix Effects</string>
     <string name="inflate">Inflate</string>
+    <string name="none">None</string>
 
     <string name="quality0">Highest</string>
     <string name="quality1">High</string>
