commit 5c84d9c257e5f374fb0a120704e39324924ce374
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Oct 8 23:27:10 2021 +0200

    Set possibility for the Postprocessing effects to eclipse the whole object or only work at the edges.

diff --git a/src/main/java/org/distorted/library/effect/PostprocessEffect.java b/src/main/java/org/distorted/library/effect/PostprocessEffect.java
index dc406df..1b69fac 100644
--- a/src/main/java/org/distorted/library/effect/PostprocessEffect.java
+++ b/src/main/java/org/distorted/library/effect/PostprocessEffect.java
@@ -98,6 +98,7 @@ public abstract class PostprocessEffect extends Effect implements InternalMaster
 
   private final ArrayList<Job> mJobs = new ArrayList<>();
   private int mQualityLevel;
+  private boolean mUseHaloDepth;
 
   float mQualityScale;
 
@@ -174,6 +175,17 @@ public abstract class PostprocessEffect extends Effect implements InternalMaster
     return mQualityLevel;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+  /**
+   * Only for use by the library itself.
+   *
+   * @y.exclude
+   */
+  public boolean getHaloDepth()
+    {
+    return mUseHaloDepth;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Only for use by the library itself.
@@ -289,4 +301,17 @@ public abstract class PostprocessEffect extends Effect implements InternalMaster
     mJobs.add(new Job(MIPMAP,quality.getLevel()));
     InternalMaster.newSlave(this);
     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * When preprocessing - so drawning the 'halo' - do we also want to write the depth buffer?
+ * If yes, the halo would cover the whole object; if no, it would be just around it (and possibly
+ * could be covered by other similarly postprocessed objects nearby)
+ *
+ * @param depth should the halo around the object cover it or not?
+ */
+  public void setHaloDepth(boolean depth)
+    {
+    mUseHaloDepth = depth;
+    }
   }
\ No newline at end of file
diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
index d149012..40a8036 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
@@ -53,6 +53,7 @@ public class EffectQueuePostprocess extends EffectQueue
   private static final int INDEX = EffectType.POSTPROCESS.ordinal();
 
   private int mHalo;
+  private boolean mUseHaloDepth;
   private float mR, mG, mB, mA;
 
   private static DistortedProgram mPreProgram;
@@ -90,13 +91,18 @@ public class EffectQueuePostprocess extends EffectQueue
       // that (see preprocess())
       array[NUM_FLOAT_UNIFORMS*i+5]=0.0f;
 
-      if( mEffects[i].compute(array, NUM_FLOAT_UNIFORMS*i, currTime, step) )
+      PostprocessEffect effect = (PostprocessEffect)mEffects[i];
+
+      if( effect.compute(array, NUM_FLOAT_UNIFORMS*i, currTime, step) )
         {
         EffectMessageSender.newMessage(mEffects[i]);
         }
 
       halo = (int)array[NUM_FLOAT_UNIFORMS*i];
       if( halo>mHalo ) mHalo = halo;
+
+      // TODO  (now only really works in case of 1 effect!)
+      mUseHaloDepth = effect.getHaloDepth();
       }
 
     // TODO  (now only really works in case of 1 effect!)
@@ -173,6 +179,7 @@ public class EffectQueuePostprocess extends EffectQueue
 
     InternalRenderState.setUpStencilMark(mA!=0.0f);
     InternalRenderState.disableBlending();
+    if( !mUseHaloDepth ) GLES30.glDepthMask(false);
 
     GLES30.glViewport(0, 0, width, height );
 
@@ -198,6 +205,7 @@ public class EffectQueuePostprocess extends EffectQueue
 
     InternalRenderState.restoreBlending();
     InternalRenderState.unsetUpStencilMark();
+    if( !mUseHaloDepth ) GLES30.glDepthMask(true);
 
     return 1;
     }
diff --git a/src/main/java/org/distorted/library/main/InternalRenderState.java b/src/main/java/org/distorted/library/main/InternalRenderState.java
index 4eb6a0e..3e52df0 100644
--- a/src/main/java/org/distorted/library/main/InternalRenderState.java
+++ b/src/main/java/org/distorted/library/main/InternalRenderState.java
@@ -51,9 +51,9 @@ public class InternalRenderState
     private int blendSrc, blendDst;
     }
 
-  private RenderState mState;          // state the current object wants to have
-  static private RenderState cState = new RenderState();   // current OpenGL Stave
-  static private RenderState sState = new RenderState();   // saved OpenGL state
+  private final RenderState mState;          // state the current object wants to have
+  static private final RenderState cState = new RenderState();   // current OpenGL Stave
+  static private final RenderState sState = new RenderState();   // saved OpenGL state
 
   private int mClear;
 
