commit 65e837598995609ee67fb6dbfb05d80b649fd0cb
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Tue May 16 17:08:01 2017 +0100

    Fix creating FBOs with combined DEPTH/STENCIL.
    
    This makes the Stencil app fully work, including rendering thru a FBO.

diff --git a/src/main/java/org/distorted/library/DistortedFramebuffer.java b/src/main/java/org/distorted/library/DistortedFramebuffer.java
index f9f40d7..ff42466 100644
--- a/src/main/java/org/distorted/library/DistortedFramebuffer.java
+++ b/src/main/java/org/distorted/library/DistortedFramebuffer.java
@@ -64,17 +64,25 @@ public class DistortedFramebuffer extends DistortedOutputSurface implements Dist
       GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_NEAREST);
 
       if( mDepthStencil==DEPTH_NO_STENCIL )
-        GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_DEPTH_COMPONENT, mWidth, mHeight, 0, GLES30.GL_DEPTH_COMPONENT, GLES30.GL_UNSIGNED_SHORT, null);
+        {
+        GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_DEPTH_COMPONENT, mWidth, mHeight, 0, GLES30.GL_DEPTH_COMPONENT, GLES30.GL_UNSIGNED_INT, null);
+        }
       else if( mDepthStencil==BOTH_DEPTH_STENCIL )
-        GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_DEPTH24_STENCIL8, mWidth, mHeight, 0, GLES30.GL_DEPTH_STENCIL, GLES30.GL_UNSIGNED_SHORT, null);
+        {
+        GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, GLES30.GL_DEPTH24_STENCIL8, mWidth, mHeight, 0, GLES30.GL_DEPTH_STENCIL, GLES30.GL_UNSIGNED_INT_24_8, null);
+        }
 
       GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
       GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, mFBOH[0]);
 
       if( mDepthStencil==DEPTH_NO_STENCIL )
+        {
         GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT, GLES30.GL_TEXTURE_2D, mDepthStencilH[0], 0);
+        }
       else if( mDepthStencil==BOTH_DEPTH_STENCIL )
+        {
         GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_STENCIL_ATTACHMENT, GLES30.GL_TEXTURE_2D, mDepthStencilH[0], 0);
+        }
 
       GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, 0);
 
@@ -231,29 +239,28 @@ public class DistortedFramebuffer extends DistortedOutputSurface implements Dist
  */
   public void enableDepthStencil(int depthStencil)
     {
-    if( depthStencil!= NO_DEPTH_NO_STENCIL && mDepthStencilCreated==DONT_CREATE )
+    if( depthStencil != mDepthStencil )
       {
-      mDepthStencilCreated = NOT_CREATED_YET;
       mDepthStencil = depthStencil;
 
-      if( mBuffer1[0]!=null )
+      if( depthStencil!= NO_DEPTH_NO_STENCIL && mDepthStencilCreated==DONT_CREATE )
         {
-        for(int i=0; i<EffectQuality.LENGTH; i++) mBuffer1[i].enableDepthStencil(depthStencil);
-        }
+        mDepthStencilCreated = NOT_CREATED_YET;
 
-      markForCreation();
-      }
-    if( depthStencil== NO_DEPTH_NO_STENCIL && mDepthStencilCreated!=DONT_CREATE )
-      {
-      mDepthStencilCreated = DONT_CREATE;
-      mDepthStencil = depthStencil;
+        if( mBuffer1[0]!=null )
+          for(int i=0; i<EffectQuality.LENGTH; i++) mBuffer1[i].enableDepthStencil(depthStencil);
 
-      if( mBuffer1[0]!=null )
-        {
-        for(int i=0; i<EffectQuality.LENGTH; i++) mBuffer1[i].enableDepthStencil(depthStencil);
+        markForCreation();
         }
+      if( depthStencil== NO_DEPTH_NO_STENCIL && mDepthStencilCreated!=DONT_CREATE )
+        {
+        mDepthStencilCreated = DONT_CREATE;
 
-      markForCreation();
+        if( mBuffer1[0]!=null )
+          for(int i=0; i<EffectQuality.LENGTH; i++) mBuffer1[i].enableDepthStencil(depthStencil);
+
+        markForCreation();
+        }
       }
     }
 
