commit f2367b75d71bafb47c66af4547234cb87600e466
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Tue Mar 28 13:26:36 2017 +0100

    Upgrade from GLSL 1.00 to GLSL 3.00 ES
    Introduce separate BLUR1 and BLUR2 shaders, the second one marging (writing to gl_FragDepth still does not work)

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 330242e..3663dfa 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -21,7 +21,6 @@ package org.distorted.library;
 
 import android.content.Context;
 import android.content.res.Resources;
-import android.opengl.GLES30;
 import org.distorted.library.program.*;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -30,6 +29,7 @@ import org.distorted.library.program.*;
  */
 public class Distorted 
   {
+  static final String glslVersion="#version 300 es\n";
   /**
    * When creating an instance of a DistortedTexture from another instance, clone the Bitmap that's
    * backing up our DistortedTexture.
diff --git a/src/main/java/org/distorted/library/DistortedEffects.java b/src/main/java/org/distorted/library/DistortedEffects.java
index 9371884..8fc92dc 100644
--- a/src/main/java/org/distorted/library/DistortedEffects.java
+++ b/src/main/java/org/distorted/library/DistortedEffects.java
@@ -110,8 +110,8 @@ public class DistortedEffects
     final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
     final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader);
 
-    String mainVertHeader= ("#version 100\n");
-    String mainFragHeader= ("#version 100\n");
+    String mainVertHeader= Distorted.glslVersion;
+    String mainFragHeader= Distorted.glslVersion;
 
     EffectNames name;
     EffectTypes type;
@@ -156,10 +156,18 @@ 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= ("#version 100\n#define NUM_VERTEX 0\n"  );
-    String blitFragHeader= ("#version 100\n#define NUM_FRAGMENT 0\n");
+    String blitVertHeader= (Distorted.glslVersion + "#define NUM_VERTEX 0\n"  );
+    String blitFragHeader= (Distorted.glslVersion + "#define NUM_FRAGMENT 0\n");
 
-    mBlitProgram = new DistortedProgram(blitVertStream,blitFragStream,blitVertHeader,blitFragHeader);
+    try
+      {
+      mBlitProgram = new DistortedProgram(blitVertStream,blitFragStream,blitVertHeader,blitFragHeader);
+      }
+    catch(Exception e)
+      {
+      android.util.Log.e("EFFECTS", "exception trying to compile BLIT program: "+e.getMessage());
+      throw new RuntimeException(e.getMessage());
+      }
 
     int blitProgramH = mBlitProgram.getProgramHandle();
     mBlitTextureH  = GLES30.glGetUniformLocation( blitProgramH, "u_Texture");
@@ -169,7 +177,15 @@ public class DistortedEffects
     final InputStream debugVertexStream   = resources.openRawResource(R.raw.test_vertex_shader);
     final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader);
 
-    mDebugProgram = new DistortedProgram(debugVertexStream,debugFragmentStream, "#version 100\n", "#version 100\n");
+    try
+      {
+      mDebugProgram = new DistortedProgram(debugVertexStream,debugFragmentStream, Distorted.glslVersion, Distorted.glslVersion);
+      }
+    catch(Exception e)
+      {
+      android.util.Log.e("EFFECTS", "exception trying to compile DEBUG program: "+e.getMessage());
+      throw new RuntimeException(e.getMessage());
+      }
 
     int debugProgramH = mDebugProgram.getProgramHandle();
     mDebugObjDH = GLES30.glGetUniformLocation( debugProgramH, "u_objD");
diff --git a/src/main/java/org/distorted/library/DistortedFramebuffer.java b/src/main/java/org/distorted/library/DistortedFramebuffer.java
index b33124a..930bcd7 100644
--- a/src/main/java/org/distorted/library/DistortedFramebuffer.java
+++ b/src/main/java/org/distorted/library/DistortedFramebuffer.java
@@ -171,6 +171,21 @@ public class DistortedFramebuffer extends DistortedOutputSurface implements Dist
     super(width,height,NOT_CREATED_YET, (depthEnabled ? NOT_CREATED_YET:DONT_CREATE),NOT_CREATED_YET, type);
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// For setting the Depth texture as input to fragment shaders that merge many planes. (currently: blur2)
+
+  boolean setAsDepth()
+    {
+    if( mDepthH[0]>0 )
+      {
+      GLES30.glActiveTexture(GLES30.GL_TEXTURE1);
+      GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mDepthH[0]);
+      return true;
+      }
+
+    return false;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -211,6 +226,7 @@ public class DistortedFramebuffer extends DistortedOutputSurface implements Dist
     {
     if( mColorH[0]>0 )
       {
+      GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
       GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
       return true;
       }
diff --git a/src/main/java/org/distorted/library/DistortedTexture.java b/src/main/java/org/distorted/library/DistortedTexture.java
index f05d2ed..a777642 100644
--- a/src/main/java/org/distorted/library/DistortedTexture.java
+++ b/src/main/java/org/distorted/library/DistortedTexture.java
@@ -133,6 +133,7 @@ public class DistortedTexture extends DistortedSurface implements DistortedInput
     {
     if( mColorH[0]>0 )
       {
+      GLES30.glActiveTexture(GLES30.GL_TEXTURE0);
       GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, mColorH[0]);
       return true;
       }
diff --git a/src/main/java/org/distorted/library/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/EffectQueuePostprocess.java
index 7706ab5..abe5fb5 100644
--- a/src/main/java/org/distorted/library/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/EffectQueuePostprocess.java
@@ -98,8 +98,9 @@ class EffectQueuePostprocess extends EffectQueue
   private static float[] weightsCache = new float[MAX_BLUR + MAX_BLUR*MAX_BLUR/4];
   private static float[] offsetsCache = new float[MAX_BLUR + MAX_BLUR*MAX_BLUR/4];
 
-  private static DistortedProgram mBlurProgram;
-  private static int mRadiusH,mOffsetsH,mWeightsH,mDepthH;
+  private static DistortedProgram mBlur1Program, mBlur2Program;
+  private static int mRadius1H,mOffsets1H,mWeights1H,mDepth1H, mColorTexture1H;
+  private static int mRadius2H,mOffsets2H,mWeights2H,mDepth2H, mColorTexture2H, mDepthTexture2H;
   private static float[] mWeights = new float[MAX_BLUR];
   private static float[] mOffsets = new float[MAX_BLUR];
   // another effect ....
@@ -116,18 +117,50 @@ class EffectQueuePostprocess extends EffectQueue
   static void createProgram(Resources resources)
   throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
     {
-    final InputStream postVertexStream   = resources.openRawResource(R.raw.blur_vertex_shader);
-    final InputStream postFragmentStream = resources.openRawResource(R.raw.blur_fragment_shader);
-
-    mBlurProgram = new DistortedProgram(postVertexStream,postFragmentStream,
-                                        "#version 100\n",
-                                        "#version 100\n#define MAX_BLUR "+MAX_BLUR);
-
-    int blurProgramH = mBlurProgram.getProgramHandle();
-    mRadiusH    = GLES30.glGetUniformLocation( blurProgramH, "u_Radius");
-    mOffsetsH   = GLES30.glGetUniformLocation( blurProgramH, "u_Offsets");
-    mWeightsH   = GLES30.glGetUniformLocation( blurProgramH, "u_Weights");
-    mDepthH     = GLES30.glGetUniformLocation( blurProgramH, "u_Depth");
+    final InputStream blur1VertexStream   = resources.openRawResource(R.raw.blur_vertex_shader);
+    final InputStream blur1FragmentStream = resources.openRawResource(R.raw.blur1_fragment_shader);
+
+    try
+      {
+      mBlur1Program = new DistortedProgram(blur1VertexStream,blur1FragmentStream,
+                                          Distorted.glslVersion,
+                                          Distorted.glslVersion+"#define MAX_BLUR "+MAX_BLUR);
+      }
+    catch(Exception e)
+      {
+      android.util.Log.e("EFFECTS", "exception trying to compile BLUR1 program: "+e.getMessage());
+      throw new RuntimeException(e.getMessage());
+      }
+
+    int blur1ProgramH = mBlur1Program.getProgramHandle();
+    mRadius1H       = GLES30.glGetUniformLocation( blur1ProgramH, "u_Radius");
+    mOffsets1H      = GLES30.glGetUniformLocation( blur1ProgramH, "u_Offsets");
+    mWeights1H      = GLES30.glGetUniformLocation( blur1ProgramH, "u_Weights");
+    mDepth1H        = GLES30.glGetUniformLocation( blur1ProgramH, "u_Depth");
+    mColorTexture1H = GLES30.glGetUniformLocation( blur1ProgramH, "u_ColorTexture");
+
+    final InputStream blur2VertexStream   = resources.openRawResource(R.raw.blur_vertex_shader);
+    final InputStream blur2FragmentStream = resources.openRawResource(R.raw.blur2_fragment_shader);
+
+    try
+      {
+      mBlur2Program = new DistortedProgram(blur2VertexStream,blur2FragmentStream,
+                                          Distorted.glslVersion,
+                                          Distorted.glslVersion + "#define MAX_BLUR "+MAX_BLUR);
+      }
+    catch(Exception e)
+      {
+      android.util.Log.e("EFFECTS", "exception trying to compile BLUR2 program: "+e.getMessage());
+      throw new RuntimeException(e.getMessage());
+      }
+
+    int blur2ProgramH = mBlur2Program.getProgramHandle();
+    mRadius2H       = GLES30.glGetUniformLocation( blur2ProgramH, "u_Radius");
+    mOffsets2H      = GLES30.glGetUniformLocation( blur2ProgramH, "u_Offsets");
+    mWeights2H      = GLES30.glGetUniformLocation( blur2ProgramH, "u_Weights");
+    mDepth2H        = GLES30.glGetUniformLocation( blur2ProgramH, "u_Depth");
+    mColorTexture2H = GLES30.glGetUniformLocation( blur2ProgramH, "u_ColorTexture");
+    mDepthTexture2H = GLES30.glGetUniformLocation( blur2ProgramH, "u_DepthTexture");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -239,28 +272,39 @@ class EffectQueuePostprocess extends EffectQueue
 
       int offset = radius + radius*radius/4;
       radius = (radius+1)/2;
-      for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h;
 
-      mPostBuffer.resizeFast( (int)w, (int)h);
-      mPostBuffer.setAsOutput(time);
       GLES30.glViewport(0, 0, (int)w, (int)h);
 
-      mBlurProgram.useProgram();
-      GLES30.glUniform1fv( mWeightsH, radius+1, weightsCache,offset);
-      GLES30.glUniform1i( mRadiusH, radius);
-      GLES30.glUniform1f( mDepthH , 1.0f-surface.mNear);
-
       // horizontal blur
-      GLES30.glUniform1fv( mOffsetsH ,radius+1, mOffsets,0);
-      GLES30.glVertexAttribPointer(mBlurProgram.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
-      GLES30.glVertexAttribPointer(mBlurProgram.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTextureInv);
+      mBlur1Program.useProgram();
+      mPostBuffer.resizeFast( (int)w, (int)h);
+      mPostBuffer.setAsOutput(time);
+
+      GLES30.glUniform1fv( mWeights1H, radius+1, weightsCache,offset);
+      GLES30.glUniform1i( mRadius1H, radius);
+      GLES30.glUniform1f( mDepth1H , 1.0f-surface.mNear);
+      GLES30.glUniform1f( mColorTexture1H , 0 );
+      for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/h;
+      GLES30.glUniform1fv( mOffsets1H ,radius+1, mOffsets,0);
+      GLES30.glVertexAttribPointer(mBlur1Program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
+      GLES30.glVertexAttribPointer(mBlur1Program.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTextureInv);
       GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
 
       // vertical blur
+      mBlur2Program.useProgram();
       mPostBuffer.setAsInput();
+      mMainBuffer.setAsDepth();
       surface.setAsOutput(time);
+
+      GLES30.glUniform1fv( mWeights2H, radius+1, weightsCache,offset);
+      GLES30.glUniform1i( mRadius2H, radius);
+      GLES30.glUniform1f( mDepth2H , 1.0f-surface.mNear);
+      GLES30.glUniform1f( mColorTexture2H , 0 );
+      GLES30.glUniform1f( mDepthTexture2H , 1 );
       for(int i=0; i<=radius; i++) mOffsets[i] = offsetsCache[offset+i]/w;
-      GLES30.glUniform1fv( mOffsetsH ,radius+1, mOffsets,0);
+      GLES30.glUniform1fv( mOffsets2H ,radius+1, mOffsets,0);
+      GLES30.glVertexAttribPointer(mBlur2Program.mAttribute[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadPositions);
+      GLES30.glVertexAttribPointer(mBlur2Program.mAttribute[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, 0, mQuadTextureInv);
       GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
       }
 
diff --git a/src/main/java/org/distorted/library/program/DistortedProgram.java b/src/main/java/org/distorted/library/program/DistortedProgram.java
index 4b8f583..249172c 100644
--- a/src/main/java/org/distorted/library/program/DistortedProgram.java
+++ b/src/main/java/org/distorted/library/program/DistortedProgram.java
@@ -105,16 +105,16 @@ public class DistortedProgram
       if( currChar==';') break;
       }
 
-    if( semicolon<len && semicolon-whiteSpace>=11 )   // "attribute a;" --> 11
+    if( semicolon<len && semicolon-whiteSpace>=4 )   // "in a;" --> 4
       {
       String subline = line.substring(whiteSpace,semicolon);
       int subLen = semicolon-whiteSpace;
 
-      if( subline.startsWith("attribute"))
+      if( subline.startsWith("in "))
         {
         //android.util.Log.e("program", "GOOD LINE: " +subline+" subLen="+subLen);
 
-        for(nameBegin=subLen-1; nameBegin>8; nameBegin--)
+        for(nameBegin=subLen-1; nameBegin>1; nameBegin--)
           {
           currChar=subline.charAt(nameBegin);
 
diff --git a/src/main/res/raw/blit_fragment_shader.glsl b/src/main/res/raw/blit_fragment_shader.glsl
index b0de9cd..30094a8 100644
--- a/src/main/res/raw/blit_fragment_shader.glsl
+++ b/src/main/res/raw/blit_fragment_shader.glsl
@@ -19,12 +19,13 @@
 
 precision lowp float;
 
-varying vec2 v_TexCoordinate; // Interpolated texture coordinate per fragment.
+in vec2 v_TexCoordinate;      // Interpolated texture coordinate per fragment.
+out vec4 fragColor;           // The output color
 uniform sampler2D u_Texture;  // The input texture.
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 void main()                    		
   {  
-  gl_FragColor = texture2D(u_Texture,v_TexCoordinate);
+  fragColor = texture(u_Texture,v_TexCoordinate);
   }
\ No newline at end of file
diff --git a/src/main/res/raw/blit_vertex_shader.glsl b/src/main/res/raw/blit_vertex_shader.glsl
index e15b688..f3e6cc4 100644
--- a/src/main/res/raw/blit_vertex_shader.glsl
+++ b/src/main/res/raw/blit_vertex_shader.glsl
@@ -19,9 +19,9 @@
 
 precision lowp float;
 
-uniform float u_Depth;        // distance from the near plane to render plane, in clip coords
-attribute vec2 a_Position;    // Per-vertex position.
-varying vec2 v_TexCoordinate; //
+uniform float u_Depth;    // distance from the near plane to render plane, in clip coords
+in vec2 a_Position;       // Per-vertex position.
+out vec2 v_TexCoordinate; //
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/res/raw/blur1_fragment_shader.glsl b/src/main/res/raw/blur1_fragment_shader.glsl
new file mode 100644
index 0000000..fb12907
--- /dev/null
+++ b/src/main/res/raw/blur1_fragment_shader.glsl
@@ -0,0 +1,42 @@
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                          //
+//                                                                                          //
+// This file is part of Distorted.                                                          //
+//                                                                                          //
+// Distorted is free software: you can redistribute it and/or modify                        //
+// it under the terms of the GNU General Public License as published by                     //
+// the Free Software Foundation, either version 2 of the License, or                        //
+// (at your option) any later version.                                                      //
+//                                                                                          //
+// Distorted is distributed in the hope that it will be useful,                             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
+// GNU General Public License for more details.                                             //
+//                                                                                          //
+// You should have received a copy of the GNU General Public License                        //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+precision lowp float;
+
+in vec2 v_TexCoordinate;
+out vec4 fragColor;
+uniform sampler2D u_ColorTexture;
+uniform float u_Offsets[MAX_BLUR];
+uniform float u_Weights[MAX_BLUR];
+uniform int u_Radius;
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+void main()
+  {
+  vec4 pixel= texture(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
+
+  for (int i=1; i<=u_Radius; i+=1)
+    {
+    pixel += ( texture(u_ColorTexture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
+               texture(u_ColorTexture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
+    }
+
+  fragColor = pixel;
+  }
\ No newline at end of file
diff --git a/src/main/res/raw/blur2_fragment_shader.glsl b/src/main/res/raw/blur2_fragment_shader.glsl
new file mode 100644
index 0000000..309e8b8
--- /dev/null
+++ b/src/main/res/raw/blur2_fragment_shader.glsl
@@ -0,0 +1,45 @@
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                          //
+//                                                                                          //
+// This file is part of Distorted.                                                          //
+//                                                                                          //
+// Distorted is free software: you can redistribute it and/or modify                        //
+// it under the terms of the GNU General Public License as published by                     //
+// the Free Software Foundation, either version 2 of the License, or                        //
+// (at your option) any later version.                                                      //
+//                                                                                          //
+// Distorted is distributed in the hope that it will be useful,                             //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
+// GNU General Public License for more details.                                             //
+//                                                                                          //
+// You should have received a copy of the GNU General Public License                        //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+precision lowp float;
+
+in vec2 v_TexCoordinate;
+out vec4 fragColor;
+uniform sampler2D u_ColorTexture;
+uniform sampler2D u_DepthTexture;
+uniform float u_Offsets[MAX_BLUR];
+uniform float u_Weights[MAX_BLUR];
+uniform int u_Radius;
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+void main()
+  {
+  gl_FragDepth = 0.0;//texture(u_DepthTexture,v_TexCoordinate);
+
+  vec4 pixel= texture(u_ColorTexture,v_TexCoordinate) * u_Weights[0];
+
+  for (int i=1; i<=u_Radius; i+=1)
+    {
+    pixel += ( texture(u_ColorTexture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
+               texture(u_ColorTexture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
+    }
+
+  fragColor = pixel;
+  }
\ No newline at end of file
diff --git a/src/main/res/raw/blur_fragment_shader.glsl b/src/main/res/raw/blur_fragment_shader.glsl
deleted file mode 100644
index 1d00448..0000000
--- a/src/main/res/raw/blur_fragment_shader.glsl
+++ /dev/null
@@ -1,41 +0,0 @@
-//////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                          //
-//                                                                                          //
-// This file is part of Distorted.                                                          //
-//                                                                                          //
-// Distorted is free software: you can redistribute it and/or modify                        //
-// it under the terms of the GNU General Public License as published by                     //
-// the Free Software Foundation, either version 2 of the License, or                        //
-// (at your option) any later version.                                                      //
-//                                                                                          //
-// Distorted is distributed in the hope that it will be useful,                             //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                           //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                            //
-// GNU General Public License for more details.                                             //
-//                                                                                          //
-// You should have received a copy of the GNU General Public License                        //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                       //
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-precision lowp float;
-
-varying vec2 v_TexCoordinate;
-uniform sampler2D u_Texture;
-uniform float u_Offsets[MAX_BLUR];
-uniform float u_Weights[MAX_BLUR];
-uniform int u_Radius;
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-void main()
-  {
-  vec4 pixel= texture2D(u_Texture,v_TexCoordinate) * u_Weights[0];
-
-  for (int i=1; i<=u_Radius; i+=1)
-    {
-    pixel += ( texture2D(u_Texture,vec2(v_TexCoordinate.x+u_Offsets[i],v_TexCoordinate.y)) +
-               texture2D(u_Texture,vec2(v_TexCoordinate.x-u_Offsets[i],v_TexCoordinate.y)) ) * u_Weights[i];
-    }
-
-  gl_FragColor = pixel;
-  }
\ No newline at end of file
diff --git a/src/main/res/raw/blur_vertex_shader.glsl b/src/main/res/raw/blur_vertex_shader.glsl
index 1f5c7be..c3236dc 100644
--- a/src/main/res/raw/blur_vertex_shader.glsl
+++ b/src/main/res/raw/blur_vertex_shader.glsl
@@ -19,10 +19,10 @@
 
 precision lowp float;
 
-uniform float u_Depth;           // distance from the near plane to render plane, in clip coords
-attribute vec2 a_Position;       // Per-vertex position.
-attribute vec2 a_TexCoordinate;  // Per-vertex texture coordinate information we will pass in.
-varying vec2 v_TexCoordinate;    //
+uniform float u_Depth;    // distance from the near plane to render plane, in clip coords
+in vec2 a_Position;       // Per-vertex position.
+in vec2 a_TexCoordinate;  // Per-vertex texture coordinate information we will pass in.
+out vec2 v_TexCoordinate; //
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/res/raw/main_fragment_shader.glsl b/src/main/res/raw/main_fragment_shader.glsl
index 6bea931..895fa58 100644
--- a/src/main/res/raw/main_fragment_shader.glsl
+++ b/src/main/res/raw/main_fragment_shader.glsl
@@ -21,9 +21,10 @@ precision lowp float;
   
 uniform sampler2D u_Texture;            // The input texture.
     
-varying vec3 v_Position;                // Interpolated position for this fragment.
-varying vec3 v_Normal;                  // Interpolated normal for this fragment.
-varying vec2 v_TexCoordinate;           // Interpolated texture coordinate per fragment.
+in vec3 v_Position;                     // Interpolated position for this fragment.
+in vec3 v_Normal;                       // Interpolated normal for this fragment.
+in vec2 v_TexCoordinate;                // Interpolated texture coordinate per fragment.
+out vec4 fragColor;                     // The output color
 
 #if NUM_FRAGMENT>0
 uniform int fNumEffects;                // total number of fragment effects
@@ -92,7 +93,7 @@ void saturation(float degree, int effect, inout vec4 color)
 
 void main()                    		
   {  
-  vec4 pixel = texture2D(u_Texture,v_TexCoordinate);
+  vec4 pixel = texture(u_Texture,v_TexCoordinate);
 
 #if NUM_FRAGMENT>0
   vec2 diff;
@@ -140,5 +141,5 @@ void main()
     }
 #endif
 
-  gl_FragColor = vec4(pixel.rgb * (1.0 + 7.0*v_Normal.z) * 0.125, pixel.a);
+  fragColor = vec4(pixel.rgb * (1.0 + 7.0*v_Normal.z) * 0.125, pixel.a);
   }
\ No newline at end of file
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index 0001ede..0cb708f 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -30,13 +30,13 @@ uniform float u_Depth;               // max absolute value of v.z ; beyond that
 uniform mat4 u_MVPMatrix;            // the combined model/view/projection matrix.
 uniform mat4 u_MVMatrix;             // the combined model/view matrix.
 		 
-attribute vec3 a_Position;           // Per-vertex position.
-attribute vec3 a_Normal;             // Per-vertex normal vector.
-attribute vec2 a_TexCoordinate;      // Per-vertex texture coordinate.
+in vec3 a_Position;                  // Per-vertex position.
+in vec3 a_Normal;                    // Per-vertex normal vector.
+in vec2 a_TexCoordinate;             // Per-vertex texture coordinate.
 		  
-varying vec3 v_Position;             //
-varying vec3 v_Normal;               //
-varying vec2 v_TexCoordinate;        //
+out vec3 v_Position;                 //
+out vec3 v_Normal;                   //
+out vec2 v_TexCoordinate;            //
 
 #if NUM_VERTEX>0
 uniform int vNumEffects;             // total number of vertex effects
diff --git a/src/main/res/raw/test_fragment_shader.glsl b/src/main/res/raw/test_fragment_shader.glsl
index b107bb2..c920cea 100644
--- a/src/main/res/raw/test_fragment_shader.glsl
+++ b/src/main/res/raw/test_fragment_shader.glsl
@@ -19,9 +19,11 @@
 
 precision lowp float;
 
+out vec4 fragColor;
+
 //////////////////////////////////////////////////////////////////////////////////////////////
 
 void main()
   {
-  gl_FragColor = vec4(1.0,0.0,0.0,0.2);
+  fragColor = vec4(1.0,0.0,0.0,0.2);
   }
\ No newline at end of file
diff --git a/src/main/res/raw/test_vertex_shader.glsl b/src/main/res/raw/test_vertex_shader.glsl
index 0bceede..f55c0ef 100644
--- a/src/main/res/raw/test_vertex_shader.glsl
+++ b/src/main/res/raw/test_vertex_shader.glsl
@@ -21,7 +21,7 @@ precision lowp float;
 
 uniform vec2 u_objD;       // object width X object height.
 uniform mat4 u_MVPMatrix;  // the combined model/view/projection matrix.
-attribute vec2 a_Position; // Per-vertex position information we will pass in.
+in vec2 a_Position;        // Per-vertex position information we will pass in.
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 
