commit 806ca386003740f76712e7371d7e17e31bfc23fc
Author: leszek <leszek@koltunski.pl>
Date:   Sat May 13 01:16:07 2017 +0100

    Simplify setting up DistortedScreen.

diff --git a/src/main/java/org/distorted/library/DistortedRenderState.java b/src/main/java/org/distorted/library/DistortedRenderState.java
index 911e486..f9831aa 100644
--- a/src/main/java/org/distorted/library/DistortedRenderState.java
+++ b/src/main/java/org/distorted/library/DistortedRenderState.java
@@ -245,9 +245,6 @@ class DistortedRenderState
         }
       }
 
-//  android.util.Log.d("State", "mFunc="+mStencilFuncFunc+" sFunc="+sStencilFuncFunc);
-//  android.util.Log.d("State", "GL_ALWAYS="+GLES30.GL_ALWAYS+" GL_EQUAL="+GLES30.GL_EQUAL);
-
     /////////////////////////////////////////////////////
     // 8. Adjust Stencil function?
     if( mStencilFuncFunc!=sStencilFuncFunc || mStencilFuncRef!=sStencilFuncRef || mStencilFuncMask!=sStencilFuncMask )
diff --git a/src/main/java/org/distorted/library/DistortedScreen.java b/src/main/java/org/distorted/library/DistortedScreen.java
index ac26741..7f3afe8 100644
--- a/src/main/java/org/distorted/library/DistortedScreen.java
+++ b/src/main/java/org/distorted/library/DistortedScreen.java
@@ -20,6 +20,13 @@
 package org.distorted.library;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.ConfigurationInfo;
+import android.opengl.GLSurfaceView;
+import android.view.SurfaceView;
+
 /**
  * Class which represents the Screen.
  * <p>
@@ -43,10 +50,18 @@ public class DistortedScreen extends DistortedOutputSurface
  * <p>
  * Has to be followed by a 'resize()' to set the size.
  */
-  public DistortedScreen()
+  public DistortedScreen(GLSurfaceView view)
     {
     // set color to 'DONT_CREATE' so that Screens will not get added to the Surface lists
     // set depth to 'CREATED' so that depth will be, by default, on.
     super(0,0,DONT_CREATE,CREATED,0,TYPE_USER);
+
+    if( view!=null )
+      {
+      Context context = view.getContext();
+      final ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+      final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
+      view.setEGLContextClientVersion((configurationInfo.reqGlEsVersion >> 16) >= 3 ? 3 : 2);
+      }
     }
   }
