commit 36532c7fa959a2d46157591a04d9c1746d206146
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Dec 16 16:56:02 2022 +0100

    This app reproduces an issue with glow being improperly displayed on my physical LG phone.

diff --git a/src/main/java/org/distorted/examples/flatblur/FlatBlurActivity.java b/src/main/java/org/distorted/examples/flatblur/FlatBlurActivity.java
index 15f1946..16518f6 100644
--- a/src/main/java/org/distorted/examples/flatblur/FlatBlurActivity.java
+++ b/src/main/java/org/distorted/examples/flatblur/FlatBlurActivity.java
@@ -23,15 +23,13 @@ import android.app.Activity;
 import android.opengl.GLSurfaceView;
 import android.os.Bundle;
 import android.view.View;
-import android.widget.CheckBox;
-import android.widget.SeekBar;
 
 import org.distorted.examples.R;
 import org.distorted.library.main.DistortedLibrary;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-public class FlatBlurActivity extends Activity implements SeekBar.OnSeekBarChangeListener
+public class FlatBlurActivity extends Activity
 {
     @Override
     protected void onCreate(Bundle savedState) 
@@ -39,10 +37,6 @@ public class FlatBlurActivity extends Activity implements SeekBar.OnSeekBarChang
       super.onCreate(savedState);
       DistortedLibrary.onCreate();
       setContentView(R.layout.flatblurlayout);
-
-      SeekBar barSize  = findViewById(R.id.flatblurBlurStrength);
-      barSize.setOnSeekBarChangeListener(this);
-      barSize.setProgress(0);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -77,30 +71,19 @@ public class FlatBlurActivity extends Activity implements SeekBar.OnSeekBarChang
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void enableBlur(View view)
+    public void button1(View view)
       {
-      CheckBox box = (CheckBox)view;
-      boolean checked = box.isChecked();
-
       FlatBlurSurfaceView v = findViewById(R.id.flatblurSurfaceView);
       FlatBlurRenderer renderer = v.getRenderer();
-      renderer.enableBlur(!checked);
+      renderer.button1();
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
-    {
-    FlatBlurSurfaceView v = findViewById(R.id.flatblurSurfaceView);
-    FlatBlurRenderer renderer = v.getRenderer();
-    renderer.setBlurStrength(progress);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void onStartTrackingTouch(SeekBar bar) { }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void onStopTrackingTouch(SeekBar bar)  { }
+    public void button2(View view)
+      {
+      FlatBlurSurfaceView v = findViewById(R.id.flatblurSurfaceView);
+      FlatBlurRenderer renderer = v.getRenderer();
+      renderer.button2();
+      }
 }
diff --git a/src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java b/src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java
index 6203c31..57caa80 100644
--- a/src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java
+++ b/src/main/java/org/distorted/examples/flatblur/FlatBlurRenderer.java
@@ -21,18 +21,8 @@ package org.distorted.examples.flatblur;
 
 import android.opengl.GLSurfaceView;
 
-import org.distorted.library.effect.EffectQuality;
-import org.distorted.library.effect.MatrixEffectMove;
-import org.distorted.library.effect.MatrixEffectScale;
-import org.distorted.library.effect.PostprocessEffectBlur;
-import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedLibrary;
-import org.distorted.library.main.DistortedNode;
 import org.distorted.library.main.DistortedScreen;
-import org.distorted.library.main.DistortedTexture;
-import org.distorted.library.mesh.MeshQuad;
-import org.distorted.library.type.Static2D;
-import org.distorted.library.type.Static3D;
 
 import javax.microedition.khronos.egl.EGLConfig;
 import javax.microedition.khronos.opengles.GL10;
@@ -41,13 +31,8 @@ import javax.microedition.khronos.opengles.GL10;
 
 class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.ExceptionListener
 {
-    private static final int HALO = 15;
-
     private final GLSurfaceView mView;
     private final DistortedScreen mScreen;
-    private final PostprocessEffectBlur mBlur;
-    private final DistortedNode mRedNode;
-    private final Static2D mBlurStrength;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -55,38 +40,6 @@ class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
       {
       mView = v;
       mScreen = new DistortedScreen();
-
-      int x = 50;
-      int scale = 200;
-      mRedNode = createNode(-x,0,1,scale,0xffff0000);
-      DistortedNode whiteNode = createNode(x,0,1,scale,0xffffffff);
-
-      mScreen.attach(mRedNode);
-      mScreen.attach(whiteNode);
-
-      mBlurStrength = new Static2D(HALO,0);
-      mBlur = new PostprocessEffectBlur(mBlurStrength);
-      mBlur.setQuality(EffectQuality.MEDIUM);
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    private DistortedNode createNode(int x, int y, int z, int scale, int color)
-      {
-      DistortedTexture texture = new DistortedTexture();
-      texture.setColorARGB(color);
-      MeshQuad mesh = new MeshQuad();
-      DistortedEffects effects = new DistortedEffects();
-
-      Static3D move = new Static3D(x,y,z);
-
-      MatrixEffectMove mainMove  = new MatrixEffectMove(move);
-      MatrixEffectScale mainScale= new MatrixEffectScale(scale);
-
-      effects.apply(mainScale);
-      effects.apply(mainMove);
-
-      return new DistortedNode(texture,effects,mesh);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -107,7 +60,7 @@ class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
     
     public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
       {
-      PostprocessEffectBlur.enable();
+      OverlayStars.enableEffects();
       DistortedLibrary.onSurfaceCreated( mView.getContext(), this);
       }
 
@@ -115,24 +68,21 @@ class FlatBlurRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
 
     public void distortedException(Exception ex)
       {
-      android.util.Log.e("SetTexture", ex.getMessage() );
+      android.util.Log.e("FlatBlur", ex.getMessage() );
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void enableBlur(boolean enable)
+    public void button1()
       {
-      DistortedEffects effects = mRedNode.getEffects();
-      long id = mBlur.getID();
-
-      if( enable ) effects.abortById(id);
-      else         effects.apply(mBlur);
+      OverlayStars stars = new OverlayStars();
+      stars.startOverlay(mScreen);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void setBlurStrength(int strength)
+    public void button2()
       {
-      mBlurStrength.set(HALO,strength*0.5f);
+
       }
 }
diff --git a/src/main/java/org/distorted/examples/flatblur/FlatBlurSurfaceView.java b/src/main/java/org/distorted/examples/flatblur/FlatBlurSurfaceView.java
index 45f52b4..7e97668 100644
--- a/src/main/java/org/distorted/examples/flatblur/FlatBlurSurfaceView.java
+++ b/src/main/java/org/distorted/examples/flatblur/FlatBlurSurfaceView.java
@@ -47,7 +47,6 @@ class FlatBlurSurfaceView extends GLSurfaceView
         final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
         setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
         setRenderer(mRenderer);
-        Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show();
         }
       }
 
diff --git a/src/main/java/org/distorted/examples/flatblur/OverlayStars.java b/src/main/java/org/distorted/examples/flatblur/OverlayStars.java
new file mode 100644
index 0000000..38b9baf
--- /dev/null
+++ b/src/main/java/org/distorted/examples/flatblur/OverlayStars.java
@@ -0,0 +1,155 @@
+package org.distorted.examples.flatblur;
+
+import org.distorted.library.effect.EffectQuality;
+import org.distorted.library.effect.PostprocessEffectGlow;
+import org.distorted.library.effect.VertexEffectMove;
+import org.distorted.library.effect.VertexEffectScale;
+import org.distorted.library.main.DistortedEffects;
+import org.distorted.library.main.DistortedNode;
+import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedTexture;
+import org.distorted.library.main.InternalOutputSurface;
+import org.distorted.library.mesh.MeshJoined;
+import org.distorted.library.mesh.MeshQuad;
+import org.distorted.library.message.EffectListener;
+import org.distorted.library.type.Dynamic;
+import org.distorted.library.type.Dynamic2D;
+import org.distorted.library.type.Dynamic3D;
+import org.distorted.library.type.Dynamic4D;
+import org.distorted.library.type.Static2D;
+import org.distorted.library.type.Static3D;
+import org.distorted.library.type.Static4D;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class OverlayStars implements EffectListener
+{
+   private static final int DUR_MOV =  4000;
+   private static final int DUR_GLO =  2000;
+
+   private static final int[] colors = new int[] {0,0,1,  1,0,1,  1,0,0,  1,1,0,  0,1,0,  1,1,1}; // blue, pink, red, yellow, green, white
+   private static final int INDEX = 5;
+
+   private DistortedNode mNode;
+   private DistortedScreen mScreen;
+
+   private float mWidth;
+   private long mMoveID, mGlowID;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+   private Dynamic3D createRandomMove()
+      {
+      Dynamic3D move = new Dynamic3D();
+      move.setMode(Dynamic.MODE_PATH);
+      move.setDuration(DUR_MOV);
+      move.setCount(0.5f);
+
+      Static3D pointS = new Static3D(0,-500,0);
+      Static3D pointE = new Static3D(0,0,0);
+
+      move.add(pointS);
+      move.add(pointE);
+
+      return move;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+   private DistortedNode createNode()
+      {
+      DistortedTexture texture = new DistortedTexture();
+      texture.setColorARGB(0xffff0000);
+
+      MeshQuad[] mesh = new MeshQuad[2];
+      mesh[0] = new MeshQuad();
+      mesh[1] = new MeshQuad();
+      mesh[0].setEffectAssociation(0,1,0);
+      mesh[1].setEffectAssociation(0,2,1);
+
+      MeshJoined wholeMesh = new MeshJoined(mesh);
+
+      DistortedEffects effects = new DistortedEffects();
+
+      float scaleM  = mWidth*0.40f;
+      float scaleP  = mWidth*0.15f;
+      Static3D moveM= new Static3D(0,0,1);
+
+      VertexEffectMove mainMove     = new VertexEffectMove(moveM);
+      VertexEffectScale mainScale   = new VertexEffectScale(scaleM);
+      mainMove.setMeshAssociation(2,-1);
+      mainScale.setMeshAssociation(2,-1);
+
+      VertexEffectScale scaleE = new VertexEffectScale(scaleP);
+      scaleE.setMeshAssociation(1,-1);
+      effects.apply(scaleE);
+
+      Dynamic3D moveP = createRandomMove();
+      VertexEffectMove moveE= new VertexEffectMove(moveP);
+      moveE.setMeshAssociation(0,0);
+      effects.apply(moveE);
+
+      mMoveID = moveE.getID();
+      moveE.notifyWhenFinished(this);
+
+      effects.apply(mainMove);
+      effects.apply(mainScale);
+
+      return new DistortedNode(texture,effects,wholeMesh);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+   public void startOverlay(DistortedScreen screen)
+      {
+      mScreen = screen;
+      mWidth = mScreen.getWidth();
+
+      mNode = createNode();
+      mNode.enableDepthStencil(InternalOutputSurface.NO_DEPTH_NO_STENCIL);
+      mScreen.attach(mNode);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+   public void effectFinished(long id)
+      {
+      if( id==mMoveID )
+         {
+         Dynamic2D haloRadius = new Dynamic2D(DUR_GLO,1.0f);
+         haloRadius.add(new Static2D( 0, 0));
+         haloRadius.add(new Static2D(15,50));
+         haloRadius.add(new Static2D( 0, 0));
+
+         Dynamic4D color= new Dynamic4D(DUR_GLO,1.0f);
+         Static4D P1    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.0f);
+         Static4D P2    = new Static4D(colors[3*INDEX],colors[3*INDEX+1], colors[3*INDEX+2], 0.5f);
+         color.add(P1);
+         color.add(P2);
+         color.add(P1);
+
+         PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
+         glow.setQuality(EffectQuality.MEDIUM);
+         mGlowID = glow.getID();
+         glow.notifyWhenFinished(this);
+         DistortedEffects effects = mNode.getEffects();
+         effects.apply(glow);
+         }
+      if( id==mGlowID )
+         {
+         mScreen.detach(mNode);
+         mNode.markForDeletion();
+         mNode=null;
+         }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @SuppressWarnings("unused")
+  public static void enableEffects()
+     {
+     VertexEffectMove.enable();
+     VertexEffectScale.enable();
+     PostprocessEffectGlow.enable();
+     }
+}
\ No newline at end of file
diff --git a/src/main/res/layout/flatblurlayout.xml b/src/main/res/layout/flatblurlayout.xml
index 528132c..28a46a0 100644
--- a/src/main/res/layout/flatblurlayout.xml
+++ b/src/main/res/layout/flatblurlayout.xml
@@ -16,21 +16,20 @@
         android:layout_height="wrap_content"
         android:gravity="center">
 
-        <CheckBox
-                android:id="@+id/flatblurEnableBlur"
+        <Button
+                android:id="@+id/flatblurButton1"
                 android:layout_width="0dp"
                 android:layout_height="match_parent"
                 android:layout_weight="1"
-                android:onClick="enableBlur"
+                android:onClick="button1"
                 android:checked="false"/>
-
-        <SeekBar
-                android:id="@+id/flatblurBlurStrength"
+        <Button
+                android:id="@+id/flatblurButton2"
                 android:layout_width="0dp"
                 android:layout_height="match_parent"
-                android:layout_weight="2"
-                android:layout_gravity="center_vertical"
-                android:layout_margin="5dp"/>
+                android:layout_weight="1"
+                android:onClick="button2"
+                android:checked="false"/>
 
     </LinearLayout>
 
