commit 75f3272e06f2f870282f2040b86b681b642a1bb7
Author: leszek <leszek@koltunski.pl>
Date:   Sun Apr 20 00:29:38 2025 +0200

    Rename .java to .kt

diff --git a/src/main/java/org/distorted/library/program/DistortedProgram.java b/src/main/java/org/distorted/library/program/DistortedProgram.java
deleted file mode 100644
index df658fc..0000000
--- a/src/main/java/org/distorted/library/program/DistortedProgram.java
+++ /dev/null
@@ -1,592 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// This library is free software; you can redistribute it and/or                                 //
-// modify it under the terms of the GNU Lesser General Public                                    //
-// License as published by the Free Software Foundation; either                                  //
-// version 2.1 of the License, or (at your option) any later version.                            //
-//                                                                                               //
-// This library 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                             //
-// Lesser General Public License for more details.                                               //
-//                                                                                               //
-// You should have received a copy of the GNU Lesser General Public                              //
-// License along with this library; if not, write to the Free Software                           //
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.program;
-
-import android.opengl.GLES30;
-
-import org.distorted.library.main.DistortedLibrary;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * An object which encapsulates a vertex/fragment shader combo, aka Shader Program.
- */
-public class DistortedProgram
-  {
-  public static final int ATTR_LAYOUT_PNTC = 0;
-  public static final int ATTR_LAYOUT_PTC  = 1;
-  public static final int ATTR_LAYOUT_PNT  = 2;
-  public static final int ATTR_LAYOUT_PNC  = 3;
-  public static final int ATTR_LAYOUT_PT   = 4;
-  public static final int ATTR_LAYOUT_P    = 5;
-  public static final int ATTR_LAYOUT_UNK  = 6;
-
-  private String mAttributeStr, mUniformStr, mUniList;
-  private int mAttributeLen, mUniformLen;
-  private int mNumAttributes;
-  private int mNumUniforms;
-  private String[] mAttributeName;
-  private final int mProgramHandle;
-
-/**
- * Various programs have different attributes (because even if the source is the same, some of them might
- * be unused).
- * Main, Full have 4 attributes in the order (position,normal,texcoord, component)
- * Pre has 3 attributes (position,texcoord,component)
- * Maybe there are other possibilities (only position and normal? 3- position,normal,texcoord?)
- */
-  public int mAttributeLayout;
-/**
- * List of Attributes (OpenGL ES 3.0: 'in' variables), in the same order as declared in the shader source.
- */
-  public int[] mAttribute;
-/**
- * List of Uniforms, in the same order as declared in the shader source.
- */
-  public int[] mUniform;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes, final String[] feedbackVaryings)
-  throws LinkingException
-    {
-    int programHandle = GLES30.glCreateProgram();
-
-    if (programHandle != 0)
-      {
-      GLES30.glAttachShader(programHandle, vertexShaderHandle);
-      GLES30.glAttachShader(programHandle, fragmentShaderHandle);
-
-      if( feedbackVaryings!=null )
-        {
-        GLES30.glTransformFeedbackVaryings(programHandle, feedbackVaryings, GLES30.GL_INTERLEAVED_ATTRIBS);
-        }
-
-      if (attributes != null)
-        {
-        final int size = attributes.length;
-
-        for(int i=0; i<size; i++)
-          {
-          GLES30.glBindAttribLocation(programHandle, i, attributes[i]);
-          }
-        }
-
-      GLES30.glLinkProgram(programHandle);
-
-      final int[] linkStatus = new int[1];
-      GLES30.glGetProgramiv(programHandle, GLES30.GL_LINK_STATUS, linkStatus, 0);
-
-      if (linkStatus[0] != GLES30.GL_TRUE )
-        {
-        String error = GLES30.glGetProgramInfoLog(programHandle);
-        GLES30.glDeleteProgram(programHandle);
-        throw new LinkingException(error);
-        }
-
-      //final int[] numberOfUniforms = new int[1];
-      //GLES30.glGetProgramiv(programHandle, GLES30.GL_ACTIVE_UNIFORMS, numberOfUniforms, 0);
-      //DistortedLibrary.logMessage("DistortedProgram: number of active uniforms="+numberOfUniforms[0]);
-      }
-
-    return programHandle;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void init(int glslVersion)
-    {
-    mAttributeStr  = (glslVersion == 100 ? "attribute " : "in ");
-    mAttributeLen  = mAttributeStr.length();
-    mNumAttributes = 0;
-    mUniformStr    = "uniform ";
-    mUniformLen    = mUniformStr.length();
-    mNumUniforms   = 0;
-    mUniList       = "";
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private String parseOutUniform(final String line)
-    {
-    int len = line.length();
-    int whiteSpace, semicolon, nameBegin;
-    char currChar;
-
-    for(whiteSpace=0; whiteSpace<len; whiteSpace++)
-      {
-      currChar = line.charAt(whiteSpace);
-      if( currChar!=' ' && currChar!='\t') break;
-      }
-
-    for(semicolon=whiteSpace; semicolon<len; semicolon++)
-      {
-      currChar = line.charAt(semicolon);
-      if( currChar==';') break;
-      }
-
-    if( semicolon<len && semicolon-whiteSpace>=mUniformLen+1 )
-      {
-      String subline = line.substring(whiteSpace,semicolon);
-      int subLen = semicolon-whiteSpace;
-
-      if( subline.startsWith(mUniformStr))
-        {
-        //DistortedLibrary.logMessage("DistortedProgram: GOOD LINE: " +subline+" subLen="+subLen);
-
-        for(nameBegin=subLen-1; nameBegin>mUniformLen-2; nameBegin--)
-          {
-          currChar=subline.charAt(nameBegin);
-
-          if( currChar==' ' || currChar=='\t' )
-            {
-            mNumUniforms++;
-            String uniform = subline.substring(nameBegin+1,subLen);
-            int brace = uniform.indexOf("[");
-
-            return brace>=0 ? uniform.substring(0,brace) : uniform;
-            }
-          }
-        }
-      }
-
-    return null;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private String parseOutAttribute(final String line)
-    {
-    int len = line.length();
-    int whiteSpace, semicolon, nameBegin;
-    char currChar;
-
-    for(whiteSpace=0; whiteSpace<len; whiteSpace++)
-      {
-      currChar = line.charAt(whiteSpace);
-      if( currChar!=' ' && currChar!='\t') break;
-      }
-
-    for(semicolon=whiteSpace; semicolon<len; semicolon++)
-      {
-      currChar = line.charAt(semicolon);
-      if( currChar==';') break;
-      }
-
-    if( semicolon<len && semicolon-whiteSpace>=mAttributeLen+1 )
-      {
-      String subline = line.substring(whiteSpace,semicolon);
-      int subLen = semicolon-whiteSpace;
-
-      if( subline.startsWith(mAttributeStr))
-        {
-        for(nameBegin=subLen-1; nameBegin>mAttributeLen-2; nameBegin--)
-          {
-          currChar=subline.charAt(nameBegin);
-
-          if( currChar==' ' || currChar=='\t' )
-            {
-            return subline.substring(nameBegin+1,subLen);
-            }
-          }
-        }
-      }
-
-    return null;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void doAttributes(final String shader, boolean doAttributes)
-    {
-    String attribute, attrList="", uniform;
-    String[] lines = shader.split("\n");
-
-    for (String line : lines)
-      {
-      if( doAttributes )
-        {
-        attribute = parseOutAttribute(line);
-
-        if (attribute != null)
-          {
-          if( !attrList.isEmpty() ) attrList += " ";
-          attrList += attribute;
-          }
-        }
-
-      uniform = parseOutUniform(line);
-
-      if (uniform != null)
-        {
-        if( !mUniList.isEmpty() ) mUniList += " ";
-        mUniList += uniform;
-        }
-      }
-
-    if( doAttributes )
-      {
-      mAttributeName = attrList.split(" ");
-      mNumAttributes = mAttributeName.length;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private String readTextFileFromRawResource(final InputStream inputStream, boolean doAttributes)
-    {
-    final InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
-    final BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
-
-    String nextLine, attribute, attrList="";
-    final StringBuilder body = new StringBuilder();
-
-    try
-      {
-      while ((nextLine = bufferedReader.readLine()) != null)
-        {
-        body.append(nextLine);
-        body.append('\n');
-
-        if( doAttributes )
-          {
-          attribute = parseOutAttribute(nextLine);
-
-          if( attribute!=null )
-            {
-            //DistortedLibrary.logMessage("DistortedProgram: new attribute: "+attribute);
-            if( !attrList.isEmpty() ) attrList += " ";
-            attrList += attribute;
-            }
-          }
-        }
-      }
-    catch (IOException e)
-      {
-      return null;
-      }
-
-    if( doAttributes )
-      {
-      mAttributeName = attrList.split(" ");
-      mNumAttributes = mAttributeName.length;
-      }
-
-    return body.toString();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private static int compileShader(final int shaderType, final String shaderSource)
-  throws FragmentCompilationException,VertexCompilationException
-    {
-    int shaderHandle = GLES30.glCreateShader(shaderType);
-
-    if (shaderHandle != 0)
-      {
-      GLES30.glShaderSource(shaderHandle, shaderSource);
-      GLES30.glCompileShader(shaderHandle);
-      final int[] compileStatus = new int[1];
-      GLES30.glGetShaderiv(shaderHandle, GLES30.GL_COMPILE_STATUS, compileStatus, 0);
-
-      if (compileStatus[0] != GLES30.GL_TRUE)
-        {
-        String error = GLES30.glGetShaderInfoLog(shaderHandle);
-
-        GLES30.glDeleteShader(shaderHandle);
-
-        switch (shaderType)
-          {
-          case GLES30.GL_VERTEX_SHADER:   throw new VertexCompilationException(error);
-          case GLES30.GL_FRAGMENT_SHADER: throw new FragmentCompilationException(error);
-          default:                        throw new RuntimeException(error);
-          }
-        }
-      }
-
-    return shaderHandle;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private static String insertEnabledEffects(String code, final String effects)
-    {
-    final String marker = "// ENABLED EFFECTS WILL BE INSERTED HERE";
-    int length = marker.length();
-
-    int place = code.indexOf(marker);
-
-    if( place>=0 )
-      {
-      String begin = code.substring(0,place-1);
-      String end   = code.substring(place+length);
-
-      return begin + effects + end;
-      }
-    else
-      {
-      DistortedLibrary.logMessage("DistortedProgram: Error: marker string not found in SHADER!");
-      }
-
-    return null;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void setUpAttributes()
-    {
-    int[] att = new int[mNumAttributes];
-
-    for(int i=0; i<mNumAttributes; i++)
-      {
-      att[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
-      }
-
-    int emptyAttrs = 0;
-
-    for(int i=0; i<mNumAttributes-emptyAttrs; i++)
-      {
-      if( att[i] < 0 )
-        {
-        emptyAttrs++;
-
-        for(int j=i; j<mNumAttributes-emptyAttrs; j++)
-          {
-          att[j] = att[j+1];
-          mAttributeName[j] = mAttributeName[j+1];
-          }
-        }
-      }
-
-    if( emptyAttrs>0 )
-      {
-      mNumAttributes -= emptyAttrs;
-      mAttribute = new int[mNumAttributes];
-      System.arraycopy(att, 0, mAttribute, 0, mNumAttributes);
-      }
-    else
-      {
-      mAttribute = att;
-      }
-
-    setUpAttributeLayout();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void setUpAttributeLayout()
-    {
-    switch(mNumAttributes)
-      {
-      case 4: mAttributeLayout = ATTR_LAYOUT_PNTC;
-              break;
-      case 3: if( mAttributeName[2].equals("a_TexCoordinate") ) mAttributeLayout = ATTR_LAYOUT_PNT;
-              else if( mAttributeName[2].equals("a_Component") )
-                {
-                if( mAttributeName[1].equals("a_TexCoordinate") ) mAttributeLayout = ATTR_LAYOUT_PTC;
-                else if( mAttributeName[1].equals("a_Normal"  ) ) mAttributeLayout = ATTR_LAYOUT_PNC;
-                else
-                  {
-                  mAttributeLayout = ATTR_LAYOUT_UNK;
-                  DistortedLibrary.logMessage("DistortedProgram: 1 Error in attribute layout: "+mAttributeName[1]);
-                  }
-                }
-              else
-                {
-                mAttributeLayout = ATTR_LAYOUT_UNK;
-                DistortedLibrary.logMessage("DistortedProgram: 2 Error in attribute layout: "+mAttributeName[2]);
-                }
-              break;
-      case 2: if( mAttributeName[1].equals("a_TexCoordinate") ) mAttributeLayout = ATTR_LAYOUT_PT;
-              else
-                {
-                mAttributeLayout = ATTR_LAYOUT_UNK;
-                DistortedLibrary.logMessage("DistortedProgram: 3 Error in attribute layout: "+mAttributeName[1]);
-                }
-              break;
-      case 1: if( mAttributeName[0].equals("a_Position") ) mAttributeLayout = ATTR_LAYOUT_P;
-              else
-                {
-                mAttributeLayout = ATTR_LAYOUT_UNK;
-                DistortedLibrary.logMessage("DistortedProgram: 4 Error in attribute layout: "+mAttributeName[0]);
-                }
-              break;
-      default:mAttributeLayout = ATTR_LAYOUT_UNK;
-              DistortedLibrary.logMessage("DistortedProgram: 5 Error in attribute layout: "+mNumAttributes);
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void setUpUniforms()
-    {
-    if( mNumUniforms>0 )
-      {
-      mUniform = new int[mNumUniforms];
-      String[] uniformName = mUniList.split(" ");
-
-      for(int i=0; i<mNumUniforms; i++)
-        {
-        mUniform[i] = GLES30.glGetUniformLocation( mProgramHandle, uniformName[i]);
-        }
-      }
-    else mUniform = null;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Only for use by the library itself.
- *
- * @y.exclude
- */
-  public DistortedProgram(final InputStream vert, final InputStream frag, final String vertHeader, final String fragHeader,
-                          int glslVersion, final String[] feedback )
-  throws FragmentCompilationException,VertexCompilationException,LinkingException
-    {
-    init(glslVersion);
-
-    final String vertShader = readTextFileFromRawResource(vert, true );
-    final String fragShader = readTextFileFromRawResource(frag, false);
-
-    final int vertShaderHandle = compileShader(GLES30.GL_VERTEX_SHADER  , vertHeader + vertShader);
-    final int fragShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragHeader + fragShader);
-
-    mProgramHandle = createAndLinkProgram(vertShaderHandle, fragShaderHandle, mAttributeName, glslVersion>= 300 ? feedback:null );
-
-    setUpAttributes();
-    setUpUniforms();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Only for use by the library itself.
- *
- * @y.exclude
- */
-  public DistortedProgram(final InputStream vert, final InputStream frag, final String vertHeader, final String fragHeader,
-                          final String enabledVert, final String enabledFrag, int glslVersion, final String[] feedback )
-  throws FragmentCompilationException,VertexCompilationException,LinkingException
-    {
-    init(glslVersion);
-
-    String vertShader = readTextFileFromRawResource( vert, true );
-    String fragShader = readTextFileFromRawResource( frag, false);
-
-    if( enabledVert!=null ) vertShader = insertEnabledEffects(vertShader,enabledVert);
-    if( enabledFrag!=null ) fragShader = insertEnabledEffects(fragShader,enabledFrag);
-
-    final int vertShaderHandle = compileShader(GLES30.GL_VERTEX_SHADER  , vertHeader + vertShader);
-    final int fragShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragHeader + fragShader);
-
-    mProgramHandle = createAndLinkProgram(vertShaderHandle, fragShaderHandle, mAttributeName, glslVersion>= 300 ? feedback:null );
-
-    setUpAttributes();
-    setUpUniforms();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Only for use by the library itself.
- *
- * @y.exclude
- */
-  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion )
-  throws FragmentCompilationException,VertexCompilationException,LinkingException
-    {
-    this(vertex,fragment,vertexHeader,fragmentHeader,glslVersion,null);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Create a new Shader Program from two source strings.
- * <p>
- * Needs to be called from a thread holding the OpenGL context.
- *
- * @param vertex   Vertex shader code.
- * @param fragment Fragment shader code.
- * @throws FragmentCompilationException fragment shader failed to compile
- * @throws VertexCompilationException vertex shader failed to compile
- * @throws LinkingException shaders failed to link
- */
-  public DistortedProgram(final String vertex, final String fragment)
-  throws FragmentCompilationException,VertexCompilationException,LinkingException
-    {
-    init(300);
-
-    doAttributes(vertex  , true );
-    doAttributes(fragment, false);
-
-    final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertex  );
-    final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragment);
-
-    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName, null );
-
-    setUpAttributes();
-    setUpUniforms();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Return the handle of the created program so that we can later, say, call glUseProgram.
- */
-  public int getProgramHandle()
-    {
-    return mProgramHandle;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Use the program and enable all vertex attribute arrays.
- * Needs to be called from a thread holding the OpenGL context.
- */
-  public void useProgram()
-    {
-    GLES30.glUseProgram(mProgramHandle);
-
-    for(int i=0; i<mNumAttributes; i++)
-      {
-      GLES30.glEnableVertexAttribArray(mAttribute[i]);
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Disable all vertex attribute arrays.
- * Needs to be called from a thread holding the OpenGL context.
- */
-  public void stopUsingProgram()
-    {
-    GLES30.glUseProgram(0);
-
-    for(int i=0; i<mNumAttributes; i++)
-      {
-      GLES30.glDisableVertexAttribArray(mAttribute[i]);
-      }
-    }
-  }
-
-
diff --git a/src/main/java/org/distorted/library/program/DistortedProgram.kt b/src/main/java/org/distorted/library/program/DistortedProgram.kt
new file mode 100644
index 0000000..df658fc
--- /dev/null
+++ b/src/main/java/org/distorted/library/program/DistortedProgram.kt
@@ -0,0 +1,592 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// This library is free software; you can redistribute it and/or                                 //
+// modify it under the terms of the GNU Lesser General Public                                    //
+// License as published by the Free Software Foundation; either                                  //
+// version 2.1 of the License, or (at your option) any later version.                            //
+//                                                                                               //
+// This library 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                             //
+// Lesser General Public License for more details.                                               //
+//                                                                                               //
+// You should have received a copy of the GNU Lesser General Public                              //
+// License along with this library; if not, write to the Free Software                           //
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.program;
+
+import android.opengl.GLES30;
+
+import org.distorted.library.main.DistortedLibrary;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * An object which encapsulates a vertex/fragment shader combo, aka Shader Program.
+ */
+public class DistortedProgram
+  {
+  public static final int ATTR_LAYOUT_PNTC = 0;
+  public static final int ATTR_LAYOUT_PTC  = 1;
+  public static final int ATTR_LAYOUT_PNT  = 2;
+  public static final int ATTR_LAYOUT_PNC  = 3;
+  public static final int ATTR_LAYOUT_PT   = 4;
+  public static final int ATTR_LAYOUT_P    = 5;
+  public static final int ATTR_LAYOUT_UNK  = 6;
+
+  private String mAttributeStr, mUniformStr, mUniList;
+  private int mAttributeLen, mUniformLen;
+  private int mNumAttributes;
+  private int mNumUniforms;
+  private String[] mAttributeName;
+  private final int mProgramHandle;
+
+/**
+ * Various programs have different attributes (because even if the source is the same, some of them might
+ * be unused).
+ * Main, Full have 4 attributes in the order (position,normal,texcoord, component)
+ * Pre has 3 attributes (position,texcoord,component)
+ * Maybe there are other possibilities (only position and normal? 3- position,normal,texcoord?)
+ */
+  public int mAttributeLayout;
+/**
+ * List of Attributes (OpenGL ES 3.0: 'in' variables), in the same order as declared in the shader source.
+ */
+  public int[] mAttribute;
+/**
+ * List of Uniforms, in the same order as declared in the shader source.
+ */
+  public int[] mUniform;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private int createAndLinkProgram(final int vertexShaderHandle, final int fragmentShaderHandle, final String[] attributes, final String[] feedbackVaryings)
+  throws LinkingException
+    {
+    int programHandle = GLES30.glCreateProgram();
+
+    if (programHandle != 0)
+      {
+      GLES30.glAttachShader(programHandle, vertexShaderHandle);
+      GLES30.glAttachShader(programHandle, fragmentShaderHandle);
+
+      if( feedbackVaryings!=null )
+        {
+        GLES30.glTransformFeedbackVaryings(programHandle, feedbackVaryings, GLES30.GL_INTERLEAVED_ATTRIBS);
+        }
+
+      if (attributes != null)
+        {
+        final int size = attributes.length;
+
+        for(int i=0; i<size; i++)
+          {
+          GLES30.glBindAttribLocation(programHandle, i, attributes[i]);
+          }
+        }
+
+      GLES30.glLinkProgram(programHandle);
+
+      final int[] linkStatus = new int[1];
+      GLES30.glGetProgramiv(programHandle, GLES30.GL_LINK_STATUS, linkStatus, 0);
+
+      if (linkStatus[0] != GLES30.GL_TRUE )
+        {
+        String error = GLES30.glGetProgramInfoLog(programHandle);
+        GLES30.glDeleteProgram(programHandle);
+        throw new LinkingException(error);
+        }
+
+      //final int[] numberOfUniforms = new int[1];
+      //GLES30.glGetProgramiv(programHandle, GLES30.GL_ACTIVE_UNIFORMS, numberOfUniforms, 0);
+      //DistortedLibrary.logMessage("DistortedProgram: number of active uniforms="+numberOfUniforms[0]);
+      }
+
+    return programHandle;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void init(int glslVersion)
+    {
+    mAttributeStr  = (glslVersion == 100 ? "attribute " : "in ");
+    mAttributeLen  = mAttributeStr.length();
+    mNumAttributes = 0;
+    mUniformStr    = "uniform ";
+    mUniformLen    = mUniformStr.length();
+    mNumUniforms   = 0;
+    mUniList       = "";
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private String parseOutUniform(final String line)
+    {
+    int len = line.length();
+    int whiteSpace, semicolon, nameBegin;
+    char currChar;
+
+    for(whiteSpace=0; whiteSpace<len; whiteSpace++)
+      {
+      currChar = line.charAt(whiteSpace);
+      if( currChar!=' ' && currChar!='\t') break;
+      }
+
+    for(semicolon=whiteSpace; semicolon<len; semicolon++)
+      {
+      currChar = line.charAt(semicolon);
+      if( currChar==';') break;
+      }
+
+    if( semicolon<len && semicolon-whiteSpace>=mUniformLen+1 )
+      {
+      String subline = line.substring(whiteSpace,semicolon);
+      int subLen = semicolon-whiteSpace;
+
+      if( subline.startsWith(mUniformStr))
+        {
+        //DistortedLibrary.logMessage("DistortedProgram: GOOD LINE: " +subline+" subLen="+subLen);
+
+        for(nameBegin=subLen-1; nameBegin>mUniformLen-2; nameBegin--)
+          {
+          currChar=subline.charAt(nameBegin);
+
+          if( currChar==' ' || currChar=='\t' )
+            {
+            mNumUniforms++;
+            String uniform = subline.substring(nameBegin+1,subLen);
+            int brace = uniform.indexOf("[");
+
+            return brace>=0 ? uniform.substring(0,brace) : uniform;
+            }
+          }
+        }
+      }
+
+    return null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private String parseOutAttribute(final String line)
+    {
+    int len = line.length();
+    int whiteSpace, semicolon, nameBegin;
+    char currChar;
+
+    for(whiteSpace=0; whiteSpace<len; whiteSpace++)
+      {
+      currChar = line.charAt(whiteSpace);
+      if( currChar!=' ' && currChar!='\t') break;
+      }
+
+    for(semicolon=whiteSpace; semicolon<len; semicolon++)
+      {
+      currChar = line.charAt(semicolon);
+      if( currChar==';') break;
+      }
+
+    if( semicolon<len && semicolon-whiteSpace>=mAttributeLen+1 )
+      {
+      String subline = line.substring(whiteSpace,semicolon);
+      int subLen = semicolon-whiteSpace;
+
+      if( subline.startsWith(mAttributeStr))
+        {
+        for(nameBegin=subLen-1; nameBegin>mAttributeLen-2; nameBegin--)
+          {
+          currChar=subline.charAt(nameBegin);
+
+          if( currChar==' ' || currChar=='\t' )
+            {
+            return subline.substring(nameBegin+1,subLen);
+            }
+          }
+        }
+      }
+
+    return null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void doAttributes(final String shader, boolean doAttributes)
+    {
+    String attribute, attrList="", uniform;
+    String[] lines = shader.split("\n");
+
+    for (String line : lines)
+      {
+      if( doAttributes )
+        {
+        attribute = parseOutAttribute(line);
+
+        if (attribute != null)
+          {
+          if( !attrList.isEmpty() ) attrList += " ";
+          attrList += attribute;
+          }
+        }
+
+      uniform = parseOutUniform(line);
+
+      if (uniform != null)
+        {
+        if( !mUniList.isEmpty() ) mUniList += " ";
+        mUniList += uniform;
+        }
+      }
+
+    if( doAttributes )
+      {
+      mAttributeName = attrList.split(" ");
+      mNumAttributes = mAttributeName.length;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private String readTextFileFromRawResource(final InputStream inputStream, boolean doAttributes)
+    {
+    final InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
+    final BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
+
+    String nextLine, attribute, attrList="";
+    final StringBuilder body = new StringBuilder();
+
+    try
+      {
+      while ((nextLine = bufferedReader.readLine()) != null)
+        {
+        body.append(nextLine);
+        body.append('\n');
+
+        if( doAttributes )
+          {
+          attribute = parseOutAttribute(nextLine);
+
+          if( attribute!=null )
+            {
+            //DistortedLibrary.logMessage("DistortedProgram: new attribute: "+attribute);
+            if( !attrList.isEmpty() ) attrList += " ";
+            attrList += attribute;
+            }
+          }
+        }
+      }
+    catch (IOException e)
+      {
+      return null;
+      }
+
+    if( doAttributes )
+      {
+      mAttributeName = attrList.split(" ");
+      mNumAttributes = mAttributeName.length;
+      }
+
+    return body.toString();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private static int compileShader(final int shaderType, final String shaderSource)
+  throws FragmentCompilationException,VertexCompilationException
+    {
+    int shaderHandle = GLES30.glCreateShader(shaderType);
+
+    if (shaderHandle != 0)
+      {
+      GLES30.glShaderSource(shaderHandle, shaderSource);
+      GLES30.glCompileShader(shaderHandle);
+      final int[] compileStatus = new int[1];
+      GLES30.glGetShaderiv(shaderHandle, GLES30.GL_COMPILE_STATUS, compileStatus, 0);
+
+      if (compileStatus[0] != GLES30.GL_TRUE)
+        {
+        String error = GLES30.glGetShaderInfoLog(shaderHandle);
+
+        GLES30.glDeleteShader(shaderHandle);
+
+        switch (shaderType)
+          {
+          case GLES30.GL_VERTEX_SHADER:   throw new VertexCompilationException(error);
+          case GLES30.GL_FRAGMENT_SHADER: throw new FragmentCompilationException(error);
+          default:                        throw new RuntimeException(error);
+          }
+        }
+      }
+
+    return shaderHandle;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private static String insertEnabledEffects(String code, final String effects)
+    {
+    final String marker = "// ENABLED EFFECTS WILL BE INSERTED HERE";
+    int length = marker.length();
+
+    int place = code.indexOf(marker);
+
+    if( place>=0 )
+      {
+      String begin = code.substring(0,place-1);
+      String end   = code.substring(place+length);
+
+      return begin + effects + end;
+      }
+    else
+      {
+      DistortedLibrary.logMessage("DistortedProgram: Error: marker string not found in SHADER!");
+      }
+
+    return null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setUpAttributes()
+    {
+    int[] att = new int[mNumAttributes];
+
+    for(int i=0; i<mNumAttributes; i++)
+      {
+      att[i] = GLES30.glGetAttribLocation( mProgramHandle, mAttributeName[i]);
+      }
+
+    int emptyAttrs = 0;
+
+    for(int i=0; i<mNumAttributes-emptyAttrs; i++)
+      {
+      if( att[i] < 0 )
+        {
+        emptyAttrs++;
+
+        for(int j=i; j<mNumAttributes-emptyAttrs; j++)
+          {
+          att[j] = att[j+1];
+          mAttributeName[j] = mAttributeName[j+1];
+          }
+        }
+      }
+
+    if( emptyAttrs>0 )
+      {
+      mNumAttributes -= emptyAttrs;
+      mAttribute = new int[mNumAttributes];
+      System.arraycopy(att, 0, mAttribute, 0, mNumAttributes);
+      }
+    else
+      {
+      mAttribute = att;
+      }
+
+    setUpAttributeLayout();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setUpAttributeLayout()
+    {
+    switch(mNumAttributes)
+      {
+      case 4: mAttributeLayout = ATTR_LAYOUT_PNTC;
+              break;
+      case 3: if( mAttributeName[2].equals("a_TexCoordinate") ) mAttributeLayout = ATTR_LAYOUT_PNT;
+              else if( mAttributeName[2].equals("a_Component") )
+                {
+                if( mAttributeName[1].equals("a_TexCoordinate") ) mAttributeLayout = ATTR_LAYOUT_PTC;
+                else if( mAttributeName[1].equals("a_Normal"  ) ) mAttributeLayout = ATTR_LAYOUT_PNC;
+                else
+                  {
+                  mAttributeLayout = ATTR_LAYOUT_UNK;
+                  DistortedLibrary.logMessage("DistortedProgram: 1 Error in attribute layout: "+mAttributeName[1]);
+                  }
+                }
+              else
+                {
+                mAttributeLayout = ATTR_LAYOUT_UNK;
+                DistortedLibrary.logMessage("DistortedProgram: 2 Error in attribute layout: "+mAttributeName[2]);
+                }
+              break;
+      case 2: if( mAttributeName[1].equals("a_TexCoordinate") ) mAttributeLayout = ATTR_LAYOUT_PT;
+              else
+                {
+                mAttributeLayout = ATTR_LAYOUT_UNK;
+                DistortedLibrary.logMessage("DistortedProgram: 3 Error in attribute layout: "+mAttributeName[1]);
+                }
+              break;
+      case 1: if( mAttributeName[0].equals("a_Position") ) mAttributeLayout = ATTR_LAYOUT_P;
+              else
+                {
+                mAttributeLayout = ATTR_LAYOUT_UNK;
+                DistortedLibrary.logMessage("DistortedProgram: 4 Error in attribute layout: "+mAttributeName[0]);
+                }
+              break;
+      default:mAttributeLayout = ATTR_LAYOUT_UNK;
+              DistortedLibrary.logMessage("DistortedProgram: 5 Error in attribute layout: "+mNumAttributes);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setUpUniforms()
+    {
+    if( mNumUniforms>0 )
+      {
+      mUniform = new int[mNumUniforms];
+      String[] uniformName = mUniList.split(" ");
+
+      for(int i=0; i<mNumUniforms; i++)
+        {
+        mUniform[i] = GLES30.glGetUniformLocation( mProgramHandle, uniformName[i]);
+        }
+      }
+    else mUniform = null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Only for use by the library itself.
+ *
+ * @y.exclude
+ */
+  public DistortedProgram(final InputStream vert, final InputStream frag, final String vertHeader, final String fragHeader,
+                          int glslVersion, final String[] feedback )
+  throws FragmentCompilationException,VertexCompilationException,LinkingException
+    {
+    init(glslVersion);
+
+    final String vertShader = readTextFileFromRawResource(vert, true );
+    final String fragShader = readTextFileFromRawResource(frag, false);
+
+    final int vertShaderHandle = compileShader(GLES30.GL_VERTEX_SHADER  , vertHeader + vertShader);
+    final int fragShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragHeader + fragShader);
+
+    mProgramHandle = createAndLinkProgram(vertShaderHandle, fragShaderHandle, mAttributeName, glslVersion>= 300 ? feedback:null );
+
+    setUpAttributes();
+    setUpUniforms();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Only for use by the library itself.
+ *
+ * @y.exclude
+ */
+  public DistortedProgram(final InputStream vert, final InputStream frag, final String vertHeader, final String fragHeader,
+                          final String enabledVert, final String enabledFrag, int glslVersion, final String[] feedback )
+  throws FragmentCompilationException,VertexCompilationException,LinkingException
+    {
+    init(glslVersion);
+
+    String vertShader = readTextFileFromRawResource( vert, true );
+    String fragShader = readTextFileFromRawResource( frag, false);
+
+    if( enabledVert!=null ) vertShader = insertEnabledEffects(vertShader,enabledVert);
+    if( enabledFrag!=null ) fragShader = insertEnabledEffects(fragShader,enabledFrag);
+
+    final int vertShaderHandle = compileShader(GLES30.GL_VERTEX_SHADER  , vertHeader + vertShader);
+    final int fragShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragHeader + fragShader);
+
+    mProgramHandle = createAndLinkProgram(vertShaderHandle, fragShaderHandle, mAttributeName, glslVersion>= 300 ? feedback:null );
+
+    setUpAttributes();
+    setUpUniforms();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Only for use by the library itself.
+ *
+ * @y.exclude
+ */
+  public DistortedProgram(final InputStream vertex, final InputStream fragment, final String vertexHeader, final String fragmentHeader, int glslVersion )
+  throws FragmentCompilationException,VertexCompilationException,LinkingException
+    {
+    this(vertex,fragment,vertexHeader,fragmentHeader,glslVersion,null);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Create a new Shader Program from two source strings.
+ * <p>
+ * Needs to be called from a thread holding the OpenGL context.
+ *
+ * @param vertex   Vertex shader code.
+ * @param fragment Fragment shader code.
+ * @throws FragmentCompilationException fragment shader failed to compile
+ * @throws VertexCompilationException vertex shader failed to compile
+ * @throws LinkingException shaders failed to link
+ */
+  public DistortedProgram(final String vertex, final String fragment)
+  throws FragmentCompilationException,VertexCompilationException,LinkingException
+    {
+    init(300);
+
+    doAttributes(vertex  , true );
+    doAttributes(fragment, false);
+
+    final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertex  );
+    final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragment);
+
+    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName, null );
+
+    setUpAttributes();
+    setUpUniforms();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Return the handle of the created program so that we can later, say, call glUseProgram.
+ */
+  public int getProgramHandle()
+    {
+    return mProgramHandle;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Use the program and enable all vertex attribute arrays.
+ * Needs to be called from a thread holding the OpenGL context.
+ */
+  public void useProgram()
+    {
+    GLES30.glUseProgram(mProgramHandle);
+
+    for(int i=0; i<mNumAttributes; i++)
+      {
+      GLES30.glEnableVertexAttribArray(mAttribute[i]);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Disable all vertex attribute arrays.
+ * Needs to be called from a thread holding the OpenGL context.
+ */
+  public void stopUsingProgram()
+    {
+    GLES30.glUseProgram(0);
+
+    for(int i=0; i<mNumAttributes; i++)
+      {
+      GLES30.glDisableVertexAttribArray(mAttribute[i]);
+      }
+    }
+  }
+
+
diff --git a/src/main/java/org/distorted/library/program/FragmentCompilationException.java b/src/main/java/org/distorted/library/program/FragmentCompilationException.java
deleted file mode 100644
index 48e1cfc..0000000
--- a/src/main/java/org/distorted/library/program/FragmentCompilationException.java
+++ /dev/null
@@ -1,81 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// This library is free software; you can redistribute it and/or                                 //
-// modify it under the terms of the GNU Lesser General Public                                    //
-// License as published by the Free Software Foundation; either                                  //
-// version 2.1 of the License, or (at your option) any later version.                            //
-//                                                                                               //
-// This library 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                             //
-// Lesser General Public License for more details.                                               //
-//                                                                                               //
-// You should have received a copy of the GNU Lesser General Public                              //
-// License along with this library; if not, write to the Free Software                           //
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.program;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Thrown asynchronously by the library whenever shader compilation fails.
- *  If compilation of the fragment shader fails for some other reason than too many uniforms.
- *  <p>
- *  This can happen on older OpenGL ES 2.0 devices if they, say, do not support variable loops in the shaders.
- *  Theoretically should never happen on devices supporting at least OpenGL ES 3.0.
- */
-
-@SuppressWarnings("serial")
-public class FragmentCompilationException extends Exception 
-  {
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Default empty constructor  
- */
-  public FragmentCompilationException() 
-    {
-   
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why compilation failed.  
- *   
- * @param detailMessage Message describing why compilation failed
- */
-  public FragmentCompilationException(String detailMessage) 
-    {
-    super(detailMessage);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *  
- * @param throwable The parent Throwable.
- */
-  public FragmentCompilationException(Throwable throwable) 
-    {
-    super(throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *   
- * @param detailMessage Message describing why compilation failed
- * @param throwable The parent Throwable.
- */
-  public FragmentCompilationException(String detailMessage, Throwable throwable) 
-    {
-    super(detailMessage, throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-  }
diff --git a/src/main/java/org/distorted/library/program/FragmentCompilationException.kt b/src/main/java/org/distorted/library/program/FragmentCompilationException.kt
new file mode 100644
index 0000000..48e1cfc
--- /dev/null
+++ b/src/main/java/org/distorted/library/program/FragmentCompilationException.kt
@@ -0,0 +1,81 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// This library is free software; you can redistribute it and/or                                 //
+// modify it under the terms of the GNU Lesser General Public                                    //
+// License as published by the Free Software Foundation; either                                  //
+// version 2.1 of the License, or (at your option) any later version.                            //
+//                                                                                               //
+// This library 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                             //
+// Lesser General Public License for more details.                                               //
+//                                                                                               //
+// You should have received a copy of the GNU Lesser General Public                              //
+// License along with this library; if not, write to the Free Software                           //
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.program;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ *  Thrown asynchronously by the library whenever shader compilation fails.
+ *  If compilation of the fragment shader fails for some other reason than too many uniforms.
+ *  <p>
+ *  This can happen on older OpenGL ES 2.0 devices if they, say, do not support variable loops in the shaders.
+ *  Theoretically should never happen on devices supporting at least OpenGL ES 3.0.
+ */
+
+@SuppressWarnings("serial")
+public class FragmentCompilationException extends Exception 
+  {
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Default empty constructor  
+ */
+  public FragmentCompilationException() 
+    {
+   
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why compilation failed.  
+ *   
+ * @param detailMessage Message describing why compilation failed
+ */
+  public FragmentCompilationException(String detailMessage) 
+    {
+    super(detailMessage);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *  
+ * @param throwable The parent Throwable.
+ */
+  public FragmentCompilationException(Throwable throwable) 
+    {
+    super(throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *   
+ * @param detailMessage Message describing why compilation failed
+ * @param throwable The parent Throwable.
+ */
+  public FragmentCompilationException(String detailMessage, Throwable throwable) 
+    {
+    super(detailMessage, throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+  }
diff --git a/src/main/java/org/distorted/library/program/FragmentUniformsException.java b/src/main/java/org/distorted/library/program/FragmentUniformsException.java
deleted file mode 100644
index fa097b4..0000000
--- a/src/main/java/org/distorted/library/program/FragmentUniformsException.java
+++ /dev/null
@@ -1,108 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// This library is free software; you can redistribute it and/or                                 //
-// modify it under the terms of the GNU Lesser General Public                                    //
-// License as published by the Free Software Foundation; either                                  //
-// version 2.1 of the License, or (at your option) any later version.                            //
-//                                                                                               //
-// This library 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                             //
-// Lesser General Public License for more details.                                               //
-//                                                                                               //
-// You should have received a copy of the GNU Lesser General Public                              //
-// License along with this library; if not, write to the Free Software                           //
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.program;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-import org.distorted.library.main.DistortedLibrary;
-
-/**
- *  Thrown asynchronously by the library whenever shader compilation fails.
- *  If compilation of the fragment shader fails because of too many uniforms there, i.e. because
- *  we have set {@link DistortedLibrary#setMax(org.distorted.library.effect.EffectType, int)}
- *  to too high value.
- */
-
-@SuppressWarnings("serial")
-public class FragmentUniformsException extends Exception 
-  {
-  private int max=0;
-    
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Default empty constructor  
- */   
-  public FragmentUniformsException() 
-    {
-   
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why compilation failed.  
- *   
- * @param detailMessage Message describing why compilation failed
- */  
-  public FragmentUniformsException(String detailMessage) 
-    {
-    super(detailMessage);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *  
- * @param throwable The parent Throwable.
- */ 
-  public FragmentUniformsException(Throwable throwable) 
-    {
-    super(throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *   
- * @param detailMessage Message describing why compilation failed
- * @param throwable The parent Throwable.
- */  
-  public FragmentUniformsException(String detailMessage, Throwable throwable) 
-    {
-    super(detailMessage, throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why compilation failed and integer holding the maximum
- * number of uniforms in Fragment Shader supported by current hardware.   
- *   
- * @param detailMessage Message describing why compilation failed
- * @param m maximum number of uniforms in Fragment Shader supported by current hardware.   
- */   
-  public FragmentUniformsException(String detailMessage, int m) 
-    {
-    super(detailMessage);
-    max = m;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-/**
- * Gets the maximum number of uniforms in fragment shader supported by current hardware.
- * 
- * @return Maximum number of uniforms in fragment shader supported by current hardware.   
- */
-  public int getMax()
-    {
-    return max;  
-    }
-  
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-  }
diff --git a/src/main/java/org/distorted/library/program/FragmentUniformsException.kt b/src/main/java/org/distorted/library/program/FragmentUniformsException.kt
new file mode 100644
index 0000000..fa097b4
--- /dev/null
+++ b/src/main/java/org/distorted/library/program/FragmentUniformsException.kt
@@ -0,0 +1,108 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// This library is free software; you can redistribute it and/or                                 //
+// modify it under the terms of the GNU Lesser General Public                                    //
+// License as published by the Free Software Foundation; either                                  //
+// version 2.1 of the License, or (at your option) any later version.                            //
+//                                                                                               //
+// This library 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                             //
+// Lesser General Public License for more details.                                               //
+//                                                                                               //
+// You should have received a copy of the GNU Lesser General Public                              //
+// License along with this library; if not, write to the Free Software                           //
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.program;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+import org.distorted.library.main.DistortedLibrary;
+
+/**
+ *  Thrown asynchronously by the library whenever shader compilation fails.
+ *  If compilation of the fragment shader fails because of too many uniforms there, i.e. because
+ *  we have set {@link DistortedLibrary#setMax(org.distorted.library.effect.EffectType, int)}
+ *  to too high value.
+ */
+
+@SuppressWarnings("serial")
+public class FragmentUniformsException extends Exception 
+  {
+  private int max=0;
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Default empty constructor  
+ */   
+  public FragmentUniformsException() 
+    {
+   
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why compilation failed.  
+ *   
+ * @param detailMessage Message describing why compilation failed
+ */  
+  public FragmentUniformsException(String detailMessage) 
+    {
+    super(detailMessage);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *  
+ * @param throwable The parent Throwable.
+ */ 
+  public FragmentUniformsException(Throwable throwable) 
+    {
+    super(throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *   
+ * @param detailMessage Message describing why compilation failed
+ * @param throwable The parent Throwable.
+ */  
+  public FragmentUniformsException(String detailMessage, Throwable throwable) 
+    {
+    super(detailMessage, throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why compilation failed and integer holding the maximum
+ * number of uniforms in Fragment Shader supported by current hardware.   
+ *   
+ * @param detailMessage Message describing why compilation failed
+ * @param m maximum number of uniforms in Fragment Shader supported by current hardware.   
+ */   
+  public FragmentUniformsException(String detailMessage, int m) 
+    {
+    super(detailMessage);
+    max = m;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+/**
+ * Gets the maximum number of uniforms in fragment shader supported by current hardware.
+ * 
+ * @return Maximum number of uniforms in fragment shader supported by current hardware.   
+ */
+  public int getMax()
+    {
+    return max;  
+    }
+  
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+  }
diff --git a/src/main/java/org/distorted/library/program/LinkingException.java b/src/main/java/org/distorted/library/program/LinkingException.java
deleted file mode 100644
index 1305ee3..0000000
--- a/src/main/java/org/distorted/library/program/LinkingException.java
+++ /dev/null
@@ -1,81 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// This library is free software; you can redistribute it and/or                                 //
-// modify it under the terms of the GNU Lesser General Public                                    //
-// License as published by the Free Software Foundation; either                                  //
-// version 2.1 of the License, or (at your option) any later version.                            //
-//                                                                                               //
-// This library 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                             //
-// Lesser General Public License for more details.                                               //
-//                                                                                               //
-// You should have received a copy of the GNU Lesser General Public                              //
-// License along with this library; if not, write to the Free Software                           //
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.program;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-import org.distorted.library.main.DistortedLibrary;
-
-/**
- *  Thrown asynchronously by the library whenever shader compilation fails.
- *  If linking of the Shaders fails.
- *  <p>
- *  Theoretically this should never happen.
- */
-@SuppressWarnings("serial")
-public class LinkingException extends Exception 
-  {
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Default empty constructor  
- */      
-  public LinkingException() 
-    {
-   
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why linking failed.  
- *   
- * @param detailMessage Message describing why linking failed
- */    
-  public LinkingException(String detailMessage) 
-    {
-    super(detailMessage);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *  
- * @param throwable The parent Throwable.
- */  
-  public LinkingException(Throwable throwable) 
-    {
-    super(throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *   
- * @param detailMessage Message describing why linking failed
- * @param throwable The parent Throwable.
- */      
-  public LinkingException(String detailMessage, Throwable throwable) 
-    {
-    super(detailMessage, throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-  }
diff --git a/src/main/java/org/distorted/library/program/LinkingException.kt b/src/main/java/org/distorted/library/program/LinkingException.kt
new file mode 100644
index 0000000..1305ee3
--- /dev/null
+++ b/src/main/java/org/distorted/library/program/LinkingException.kt
@@ -0,0 +1,81 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// This library is free software; you can redistribute it and/or                                 //
+// modify it under the terms of the GNU Lesser General Public                                    //
+// License as published by the Free Software Foundation; either                                  //
+// version 2.1 of the License, or (at your option) any later version.                            //
+//                                                                                               //
+// This library 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                             //
+// Lesser General Public License for more details.                                               //
+//                                                                                               //
+// You should have received a copy of the GNU Lesser General Public                              //
+// License along with this library; if not, write to the Free Software                           //
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.program;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+import org.distorted.library.main.DistortedLibrary;
+
+/**
+ *  Thrown asynchronously by the library whenever shader compilation fails.
+ *  If linking of the Shaders fails.
+ *  <p>
+ *  Theoretically this should never happen.
+ */
+@SuppressWarnings("serial")
+public class LinkingException extends Exception 
+  {
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Default empty constructor  
+ */      
+  public LinkingException() 
+    {
+   
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why linking failed.  
+ *   
+ * @param detailMessage Message describing why linking failed
+ */    
+  public LinkingException(String detailMessage) 
+    {
+    super(detailMessage);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *  
+ * @param throwable The parent Throwable.
+ */  
+  public LinkingException(Throwable throwable) 
+    {
+    super(throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *   
+ * @param detailMessage Message describing why linking failed
+ * @param throwable The parent Throwable.
+ */      
+  public LinkingException(String detailMessage, Throwable throwable) 
+    {
+    super(detailMessage, throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+  }
diff --git a/src/main/java/org/distorted/library/program/VertexCompilationException.java b/src/main/java/org/distorted/library/program/VertexCompilationException.java
deleted file mode 100644
index 5756f94..0000000
--- a/src/main/java/org/distorted/library/program/VertexCompilationException.java
+++ /dev/null
@@ -1,81 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// This library is free software; you can redistribute it and/or                                 //
-// modify it under the terms of the GNU Lesser General Public                                    //
-// License as published by the Free Software Foundation; either                                  //
-// version 2.1 of the License, or (at your option) any later version.                            //
-//                                                                                               //
-// This library 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                             //
-// Lesser General Public License for more details.                                               //
-//                                                                                               //
-// You should have received a copy of the GNU Lesser General Public                              //
-// License along with this library; if not, write to the Free Software                           //
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.program;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-/**
- *  Thrown asynchronously by the library whenever shader compilation fails.
- *  If compilation of the vertex shader fails for some other reason than too many uniforms.
- *  <p>
- *  This can happen on older OpenGL ES 2.0 devices if they, say, do not support variable loops in the shaders.
- *  Theoretically should never happen on devices supporting at least OpenGL ES 3.0.
- */
-
-@SuppressWarnings("serial")
-public class VertexCompilationException extends Exception 
-  {
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Default empty constructor  
- */   
-  public VertexCompilationException() 
-    {
-   
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why compilation failed.  
- *   
- * @param detailMessage Message describing why compilation failed
- */  
-  public VertexCompilationException(String detailMessage) 
-    {
-    super(detailMessage);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *  
- * @param throwable The parent Throwable.
- */ 
-  public VertexCompilationException(Throwable throwable) 
-    {
-    super(throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *   
- * @param detailMessage Message describing why compilation failed
- * @param throwable The parent Throwable.
- */  
-  public VertexCompilationException(String detailMessage, Throwable throwable) 
-    {
-    super(detailMessage, throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-  }
diff --git a/src/main/java/org/distorted/library/program/VertexCompilationException.kt b/src/main/java/org/distorted/library/program/VertexCompilationException.kt
new file mode 100644
index 0000000..5756f94
--- /dev/null
+++ b/src/main/java/org/distorted/library/program/VertexCompilationException.kt
@@ -0,0 +1,81 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// This library is free software; you can redistribute it and/or                                 //
+// modify it under the terms of the GNU Lesser General Public                                    //
+// License as published by the Free Software Foundation; either                                  //
+// version 2.1 of the License, or (at your option) any later version.                            //
+//                                                                                               //
+// This library 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                             //
+// Lesser General Public License for more details.                                               //
+//                                                                                               //
+// You should have received a copy of the GNU Lesser General Public                              //
+// License along with this library; if not, write to the Free Software                           //
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.program;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+/**
+ *  Thrown asynchronously by the library whenever shader compilation fails.
+ *  If compilation of the vertex shader fails for some other reason than too many uniforms.
+ *  <p>
+ *  This can happen on older OpenGL ES 2.0 devices if they, say, do not support variable loops in the shaders.
+ *  Theoretically should never happen on devices supporting at least OpenGL ES 3.0.
+ */
+
+@SuppressWarnings("serial")
+public class VertexCompilationException extends Exception 
+  {
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Default empty constructor  
+ */   
+  public VertexCompilationException() 
+    {
+   
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why compilation failed.  
+ *   
+ * @param detailMessage Message describing why compilation failed
+ */  
+  public VertexCompilationException(String detailMessage) 
+    {
+    super(detailMessage);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *  
+ * @param throwable The parent Throwable.
+ */ 
+  public VertexCompilationException(Throwable throwable) 
+    {
+    super(throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *   
+ * @param detailMessage Message describing why compilation failed
+ * @param throwable The parent Throwable.
+ */  
+  public VertexCompilationException(String detailMessage, Throwable throwable) 
+    {
+    super(detailMessage, throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+  }
diff --git a/src/main/java/org/distorted/library/program/VertexUniformsException.java b/src/main/java/org/distorted/library/program/VertexUniformsException.java
deleted file mode 100644
index 0833a01..0000000
--- a/src/main/java/org/distorted/library/program/VertexUniformsException.java
+++ /dev/null
@@ -1,108 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// This library is free software; you can redistribute it and/or                                 //
-// modify it under the terms of the GNU Lesser General Public                                    //
-// License as published by the Free Software Foundation; either                                  //
-// version 2.1 of the License, or (at your option) any later version.                            //
-//                                                                                               //
-// This library 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                             //
-// Lesser General Public License for more details.                                               //
-//                                                                                               //
-// You should have received a copy of the GNU Lesser General Public                              //
-// License along with this library; if not, write to the Free Software                           //
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.program;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-import org.distorted.library.main.DistortedLibrary;
-
-/**
- *  Thrown asynchronously by the library whenever shader compilation fails.
- *  If compilation of the Vertex Shader fails because of too many uniforms there, i.e. because
- *  we have set {@link DistortedLibrary#setMax(org.distorted.library.effect.EffectType, int)}
- *  to too high value.
- */
-
-@SuppressWarnings("serial")
-public class VertexUniformsException extends Exception 
-  {
-  private int max=0;
-  
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Default empty constructor  
- */      
-  public VertexUniformsException() 
-    {
-   
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why compilation failed.  
- *   
- * @param detailMessage Message describing why compilation failed
- */   
-  public VertexUniformsException(String detailMessage) 
-    {
-    super(detailMessage);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *  
- * @param throwable The parent Throwable.
- */ 
-  public VertexUniformsException(Throwable throwable) 
-    {
-    super(throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor necessary to make Chained Exceptions working.
- *   
- * @param detailMessage Message describing why compilation failed
- * @param throwable The parent Throwable.
- */    
-  public VertexUniformsException(String detailMessage, Throwable throwable) 
-    {
-    super(detailMessage, throwable);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Constructor with a message describing why compilation failed and integer holding the maximum
- * number of uniforms in Vertex Shader supported by current hardware.   
- *   
- * @param detailMessage Message describing why compilation failed
- * @param m maximum number of uniforms in Vertex Shader supported by current hardware.   
- */     
-  public VertexUniformsException(String detailMessage, int m) 
-    {
-    super(detailMessage);
-    max = m;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-/**
- * Gets the maximum number of uniforms in Vertex Shader supported by current hardware.
- * 
- * @return Maximum number of uniforms in Vertex Shader supported by current hardware.   
- */
-  public int getMax()
-    {
-    return max;  
-    }
-  
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-  }
diff --git a/src/main/java/org/distorted/library/program/VertexUniformsException.kt b/src/main/java/org/distorted/library/program/VertexUniformsException.kt
new file mode 100644
index 0000000..0833a01
--- /dev/null
+++ b/src/main/java/org/distorted/library/program/VertexUniformsException.kt
@@ -0,0 +1,108 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski  leszek@koltunski.pl                                          //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// This library is free software; you can redistribute it and/or                                 //
+// modify it under the terms of the GNU Lesser General Public                                    //
+// License as published by the Free Software Foundation; either                                  //
+// version 2.1 of the License, or (at your option) any later version.                            //
+//                                                                                               //
+// This library 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                             //
+// Lesser General Public License for more details.                                               //
+//                                                                                               //
+// You should have received a copy of the GNU Lesser General Public                              //
+// License along with this library; if not, write to the Free Software                           //
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA                //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.program;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+import org.distorted.library.main.DistortedLibrary;
+
+/**
+ *  Thrown asynchronously by the library whenever shader compilation fails.
+ *  If compilation of the Vertex Shader fails because of too many uniforms there, i.e. because
+ *  we have set {@link DistortedLibrary#setMax(org.distorted.library.effect.EffectType, int)}
+ *  to too high value.
+ */
+
+@SuppressWarnings("serial")
+public class VertexUniformsException extends Exception 
+  {
+  private int max=0;
+  
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Default empty constructor  
+ */      
+  public VertexUniformsException() 
+    {
+   
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why compilation failed.  
+ *   
+ * @param detailMessage Message describing why compilation failed
+ */   
+  public VertexUniformsException(String detailMessage) 
+    {
+    super(detailMessage);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *  
+ * @param throwable The parent Throwable.
+ */ 
+  public VertexUniformsException(Throwable throwable) 
+    {
+    super(throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor necessary to make Chained Exceptions working.
+ *   
+ * @param detailMessage Message describing why compilation failed
+ * @param throwable The parent Throwable.
+ */    
+  public VertexUniformsException(String detailMessage, Throwable throwable) 
+    {
+    super(detailMessage, throwable);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Constructor with a message describing why compilation failed and integer holding the maximum
+ * number of uniforms in Vertex Shader supported by current hardware.   
+ *   
+ * @param detailMessage Message describing why compilation failed
+ * @param m maximum number of uniforms in Vertex Shader supported by current hardware.   
+ */     
+  public VertexUniformsException(String detailMessage, int m) 
+    {
+    super(detailMessage);
+    max = m;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+/**
+ * Gets the maximum number of uniforms in Vertex Shader supported by current hardware.
+ * 
+ * @return Maximum number of uniforms in Vertex Shader supported by current hardware.   
+ */
+  public int getMax()
+    {
+    return max;  
+    }
+  
+///////////////////////////////////////////////////////////////////////////////////////////////////  
+  }
