commit 3d804c9154b9a0cc1bbdbdc406a858c29df75474
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Dec 19 15:11:57 2016 +0000

    Minor stuff in DistortedProgram.

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index b31ed45..646059c 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -72,7 +72,7 @@ public class Distorted
 
   private static boolean mInitialized = false;
 
-  static int[] mAttributes;
+  static int[] mMainProgramAttributes;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -114,7 +114,7 @@ public class Distorted
     int programH = mainProgram.getProgramHandle();
     GLES20.glUseProgram(programH);
     mainProgram.bindAndEnableAttributes();
-    mAttributes = mainProgram.getAttributes();
+    mMainProgramAttributes = mainProgram.getAttributes();
 
     int textureUniformH = GLES20.glGetUniformLocation(programH, "u_Texture");
 
diff --git a/src/main/java/org/distorted/library/GridObject.java b/src/main/java/org/distorted/library/GridObject.java
index c0b9ccd..3d0973c 100644
--- a/src/main/java/org/distorted/library/GridObject.java
+++ b/src/main/java/org/distorted/library/GridObject.java
@@ -55,9 +55,9 @@ public abstract class GridObject
 
    void draw()
      { 
-     GLES20.glVertexAttribPointer(Distorted.mAttributes[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mGridPositions);
-     GLES20.glVertexAttribPointer(Distorted.mAttributes[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mGridNormals  );
-     GLES20.glVertexAttribPointer(Distorted.mAttributes[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mGridTexture  );
+     GLES20.glVertexAttribPointer(Distorted.mMainProgramAttributes[0], POSITION_DATA_SIZE, GLES20.GL_FLOAT, false, 0, mGridPositions);
+     GLES20.glVertexAttribPointer(Distorted.mMainProgramAttributes[1], NORMAL_DATA_SIZE  , GLES20.GL_FLOAT, false, 0, mGridNormals  );
+     GLES20.glVertexAttribPointer(Distorted.mMainProgramAttributes[2], TEX_DATA_SIZE     , GLES20.GL_FLOAT, false, 0, mGridTexture  );
 
      GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, dataLength); 
      }
diff --git a/src/main/java/org/distorted/library/program/DistortedProgram.java b/src/main/java/org/distorted/library/program/DistortedProgram.java
index 5950848..80c6fb3 100644
--- a/src/main/java/org/distorted/library/program/DistortedProgram.java
+++ b/src/main/java/org/distorted/library/program/DistortedProgram.java
@@ -42,7 +42,6 @@ public class DistortedProgram
   private int mNumAttributes;
   private int[] mAttribute;
   private String[] mAttributeName;
-  private String mAttributeTmp;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -89,7 +88,7 @@ public class DistortedProgram
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private void doAttributes(final String line)
+  private String parseOutAttribute(final String line)
     {
     int len = line.length();
     int whiteSpace, semicolon, nameBegin;
@@ -122,17 +121,14 @@ public class DistortedProgram
 
           if( currChar==' ' || currChar=='\t' )
             {
-            subline = subline.substring(nameBegin+1,subLen);
-            //android.util.Log.d("program", "new attribute: "+subline);
-
-            if( mAttributeTmp.length()>0 ) mAttributeTmp+=" ";
-            mAttributeTmp += subline;
             mNumAttributes++;
-            break;
+            return subline.substring(nameBegin+1,subLen);
             }
           }
         }
       }
+
+    return null;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -142,7 +138,7 @@ public class DistortedProgram
     final InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
     final BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
 
-    String nextLine;
+    String nextLine, attribute, attrList="";
     final StringBuilder body = new StringBuilder();
 
     try
@@ -152,7 +148,17 @@ public class DistortedProgram
         body.append(nextLine);
         body.append('\n');
 
-        if( doAttributes ) doAttributes(nextLine);
+        if( doAttributes )
+          {
+          attribute = parseOutAttribute(nextLine);
+
+          if( attribute!=null )
+            {
+            //android.util.Log.d("program", "new attribute: "+attribute);
+            if( attrList.length()>0 ) attrList+=" ";
+            attrList += attribute;
+            }
+          }
         }
       }
     catch (IOException e)
@@ -163,18 +169,7 @@ public class DistortedProgram
     if( doAttributes )
       {
       mAttribute = new int[mNumAttributes];
-      mAttributeName = mAttributeTmp.split(" ");
-      mAttributeTmp = "";
-/*
-      int len = mAttributeName.length;
-
-      for(int i=0; i<len; i++)
-        {
-        android.util.Log.e("program","ATTRIBUTE "+i+" :" + mAttributeName[i]);
-        }
-
-      android.util.Log.e("program","mNumAttributes: "+mNumAttributes);
-*/
+      mAttributeName = attrList.split(" ");
       }
 
     return body.toString();
@@ -274,7 +269,7 @@ public class DistortedProgram
                                       break;
      }
 
-    //Log.d(TAG,""+header);
+    //android.util.Log.d("program",""+header);
 
     return header;
     }
@@ -289,14 +284,17 @@ public class DistortedProgram
    *
    * @param vertex   InputStream containing the opened Resource file from where to read vertex shader code.
    * @param fragment InputStream containing the opened Resource file from where to read fragment shader code.
-   *
+   * @throws FragmentCompilationException
+   * @throws VertexCompilationException
+   * @throws VertexUniformsException
+   * @throws FragmentUniformsException
+   * @throws LinkingException
    */
 
   public DistortedProgram(final InputStream vertex, final InputStream fragment)
   throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
     {
     mNumAttributes = 0;
-    mAttributeTmp  = "";
 
     final String vertexShader   = readTextFileFromRawResource(vertex  , true );
     final String fragmentShader = readTextFileFromRawResource(fragment, false);
@@ -310,28 +308,39 @@ public class DistortedProgram
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
+/**
+ * Return the indexes off all attributes.
+ */
   public int[] getAttributes()
     {
     return mAttribute;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
+/**
+ * Return the names of all vertex attributes.
+ */
   public String[] getAttributeNames()
     {
     return mAttributeName;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
+/**
+ * Return the handle of the created program so that we can later, say, call glUseProgram.
+ */
   public int getProgramHandle()
     {
     return mProgramHandle;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// glUseProgram first; needs to be called from a thread holding the OpenGL context
+/**
+ * Bind all vertex attributes and enable them.
+ * <p>
+ * This assumes Program is in use. Call glUseProgram first.
+ * Needs to be called from a thread holding the OpenGL context.
+ */
 
   public void bindAndEnableAttributes()
     {
