commit 9e99993008656322d69bedf5320ef2e4248d24cf
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Jun 29 12:48:31 2018 +0100

    Start merging master and OIT.

diff --git a/src/main/java/org/distorted/library/main/DistortedEffects.java b/src/main/java/org/distorted/library/main/DistortedEffects.java
index 05edc63..e905f29 100644
--- a/src/main/java/org/distorted/library/main/DistortedEffects.java
+++ b/src/main/java/org/distorted/library/main/DistortedEffects.java
@@ -128,12 +128,9 @@ public class DistortedEffects
     final InputStream blitVertStream = resources.openRawResource(R.raw.blit_vertex_shader);
     final InputStream blitFragStream = resources.openRawResource(R.raw.blit_fragment_shader);
 
-    String blitVertHeader= (Distorted.GLSL_VERSION + "#define NUM_VERTEX 0\n"  );
-    String blitFragHeader= (Distorted.GLSL_VERSION + "#define NUM_FRAGMENT 0\n");
-
     try
       {
-      mBlitProgram = new DistortedProgram(blitVertStream,blitFragStream,blitVertHeader,blitFragHeader, Distorted.GLSL);
+      mBlitProgram = new DistortedProgram(blitVertStream,blitFragStream,Distorted.GLSL_VERSION,Distorted.GLSL_VERSION, Distorted.GLSL);
       }
     catch(Exception e)
       {
@@ -151,7 +148,7 @@ public class DistortedEffects
 
     try
       {
-      mBlitDepthProgram = new DistortedProgram(blitDepthVertStream,blitDepthFragStream,blitVertHeader,blitFragHeader, Distorted.GLSL);
+      mBlitDepthProgram = new DistortedProgram(blitDepthVertStream,blitDepthFragStream,Distorted.GLSL_VERSION,Distorted.GLSL_VERSION, Distorted.GLSL);
       }
     catch(Exception e)
       {
diff --git a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
index 1959a4e..081cf27 100644
--- a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
@@ -354,7 +354,7 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
 
             numRenders += lastQueue.postprocess(mBuffer,fbo);
             numRenders += blitWithDepth(time, mBuffer[quality],fbo);
-            mBuffer[quality].clearBuffer(time,fbo);
+            mBuffer[quality].clearBuffer(fbo);
             }
 
           internalQuality = currQueue.getInternalQuality();
@@ -417,14 +417,20 @@ public abstract class DistortedOutputSurface extends DistortedSurface implements
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private void clearBuffer(long time,int fbo)
+  private void clearBuffer(int fbo)
     {
-    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[fbo]);
-
-    mTime[fbo] = time;    // have to do this otherwise on the next setAsOutput() we would clear
     DistortedRenderState.colorDepthStencilOn();
+
     GLES31.glClearColor(mClearR, mClearG, mClearB, mClearA);
+    GLES31.glClearDepthf(mClearDepth);
+    GLES31.glClearStencil(mClearStencil);
+
+    GLES31.glBindFramebuffer(GLES31.GL_FRAMEBUFFER, mFBOH[fbo]);
+    GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mColorH[2*fbo+1], 0);
+    GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT|GLES31.GL_DEPTH_BUFFER_BIT|GLES31.GL_STENCIL_BUFFER_BIT);
+    GLES31.glFramebufferTexture2D(GLES31.GL_FRAMEBUFFER, GLES31.GL_COLOR_ATTACHMENT0, GLES31.GL_TEXTURE_2D, mColorH[2*fbo  ], 0);
     GLES31.glClear(GLES31.GL_COLOR_BUFFER_BIT);
+
     DistortedRenderState.colorDepthStencilRestore();
     }
 
