commit 80508ef501e99997d3be9f378fa2dd96a70038c2
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Sat Nov 12 00:03:02 2016 +0000

    Progress with AroundTheWorld

diff --git a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
index b9f3637..2ade2ea 100644
--- a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
+++ b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
@@ -27,10 +27,8 @@ import android.opengl.GLSurfaceView;
 import org.distorted.examples.R;
 import org.distorted.library.Distorted;
 import org.distorted.library.DistortedBitmap;
-import org.distorted.library.DistortedCubes;
 import org.distorted.library.DistortedObject;
 import org.distorted.library.EffectTypes;
-import org.distorted.library.type.Static1D;
 import org.distorted.library.type.Static3D;
 
 import java.io.IOException;
@@ -59,7 +57,7 @@ class AroundTheWorldRenderer implements GLSurfaceView.Renderer
    
    public void onDrawFrame(GL10 glUnused) 
       {
-      GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+      GLES20.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
       GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
      
       mObject.draw(System.currentTimeMillis());
@@ -109,7 +107,6 @@ class AroundTheWorldRenderer implements GLSurfaceView.Renderer
         catch(IOException e) { }
         }
 
-
       mObject = new DistortedBitmap(bitmap.getWidth(),bitmap.getHeight(),30);
       mEffects = new AroundTheWorldEffectsManager(mObject);
 
diff --git a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRendererPicker.java b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRendererPicker.java
index 111fd1e..5ab3f24 100644
--- a/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRendererPicker.java
+++ b/src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRendererPicker.java
@@ -34,16 +34,15 @@ import android.opengl.Matrix;
 
 class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
   {
-	private float[] mModelMatrix      = new float[16];
 	private float[] mViewMatrix       = new float[16];
 	private float[] mProjectionMatrix = new float[16];
 	private float[] mMVPMatrix        = new float[16];
 
 	private final FloatBuffer mTriangleVertices;
 
-  private int mMVPMatrixHandle;
-  private int mPositionHandle;
-	private int mColorHandle;
+  private int mMVPMatrixH;
+  private int mPositionH;
+	private int mColorH;
 
 	private final int mBytesPerFloat    = 4;
 	private final int mStrideBytes      = 7 * mBytesPerFloat;
@@ -57,14 +56,14 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 	AroundTheWorldRendererPicker()
 	  {
 		final float[] triangle1VerticesData = {
-				      -0.25f, 0.5f, 0.0f,      // x,y,z
-	            1.0f, 1.0f, 1.0f, 1.0f,  // r,g,b
+				      -0.865f, 1.5f, 0.0f,      // x,y,z
+	            1.0f, 1.0f, 1.0f, 1.0f,   // r,g,b
 
-	            -0.25f, -0.5f, 0.0f,
+	            -0.865f,-1.5f, 0.0f,
 	            0.0f, 0.0f, 0.0f, 1.0f,
 
-	            0.559f, 0.0f, 0.0f,
-	            0.3f, 0.3f, 0.0f, 1.0f };
+	            1.73f, 0.0f, 0.0f,
+	            0.5f, 0.5f, 0.0f, 1.0f };
 
 		mTriangleVertices = ByteBuffer.allocateDirect(triangle1VerticesData.length * mBytesPerFloat).order(ByteOrder.nativeOrder()).asFloatBuffer();
     mTriangleVertices.put(triangle1VerticesData).position(0);
@@ -74,7 +73,7 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 
 	@Override public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
 	  {
-		GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
+		GLES20.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
 
 		final float eyeX = 0.0f;
 		final float eyeY = 0.0f;
@@ -82,7 +81,7 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 
 		final float lookX = 0.0f;
 		final float lookY = 0.0f;
-		final float lookZ = -5.0f;
+		final float lookZ = 0.0f;
 
 		final float upX = 0.0f;
 		final float upY = 1.0f;
@@ -91,25 +90,25 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 		Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
 
 		final String vertexShader =
-			  "uniform mat4 u_MVPMatrix;                 \n"
-		  + "attribute vec4 a_Position;                \n"
-		  + "attribute vec4 a_Color;                   \n"
-		  + "varying vec4 v_Color;                     \n"
+			  "uniform mat4 u_MVPMatrix;                \n"
+		  + "attribute vec4 a_Position;               \n"
+		  + "attribute vec4 a_Color;                  \n"
+		  + "varying vec4 v_Color;                    \n"
 
-		  + "void main()                               \n"
-		  + "{                                         \n"
-		  + "   v_Color = a_Color;                     \n"
-		  + "   gl_Position = u_MVPMatrix* a_Position; \n"
-		  + "}                                         \n";
+		  + "void main()                              \n"
+		  + "  {                                      \n"
+		  + "  v_Color = a_Color;                     \n"
+		  + "  gl_Position = u_MVPMatrix* a_Position; \n"
+		  + "  }                                      \n";
 
 		final String fragmentShader =
-			  "precision mediump float;       \n"
-		  + "varying vec4 v_Color;          \n"
+			  "precision mediump float;     \n"
+		  + "varying vec4 v_Color;        \n"
 
-		  + "void main()                    \n"
-		  + "{                              \n"
-		  + "   gl_FragColor = v_Color;     \n"
-		  + "}                              \n";
+		  + "void main()                  \n"
+		  + "  {                          \n"
+		  + "  gl_FragColor = v_Color;    \n"
+		  + "  }                          \n";
 
 		int vertexShaderHandle = GLES20.glCreateShader(GLES20.GL_VERTEX_SHADER);
 
@@ -180,9 +179,9 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 			throw new RuntimeException("Error creating program.");
 		  }
 
-    mMVPMatrixHandle = GLES20.glGetUniformLocation(programHandle, "u_MVPMatrix");
-    mPositionHandle = GLES20.glGetAttribLocation(programHandle, "a_Position");
-    mColorHandle = GLES20.glGetAttribLocation(programHandle, "a_Color");
+    mMVPMatrixH = GLES20.glGetUniformLocation(programHandle, "u_MVPMatrix");
+    mPositionH  = GLES20.glGetAttribLocation(programHandle, "a_Position");
+    mColorH     = GLES20.glGetAttribLocation(programHandle, "a_Color");
 
     GLES20.glUseProgram(programHandle);
 	  }
@@ -193,15 +192,16 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 	  {
 		GLES20.glViewport(0, 0, width, height);
 
-		final float ratio = (float) width / height;
-		final float left = -ratio;
-		final float right = ratio;
-		final float bottom = -1.0f;
-		final float top = 1.0f;
-		final float near = 1.0f;
-		final float far = 10.0f;
+		final float ratio  = (float) width / height;
+		final float left   =-ratio;
+		final float right  = ratio;
+		final float bottom =-1.0f;
+		final float top    = 1.0f;
+		final float near   = 1.0f;
+		final float far    = 2.0f;
 
 		Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
+		Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
 	  }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -210,19 +210,15 @@ class AroundTheWorldRendererPicker implements GLSurfaceView.Renderer
 	  {
 		GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
 
-    Matrix.setIdentityM(mModelMatrix, 0);
-
     mTriangleVertices.position(mPositionOffset);
-    GLES20.glVertexAttribPointer(mPositionHandle, mPositionDataSize, GLES20.GL_FLOAT, false, mStrideBytes, mTriangleVertices);
-    GLES20.glEnableVertexAttribArray(mPositionHandle);
+    GLES20.glVertexAttribPointer(mPositionH, mPositionDataSize, GLES20.GL_FLOAT, false, mStrideBytes, mTriangleVertices);
+    GLES20.glEnableVertexAttribArray(mPositionH);
 
     mTriangleVertices.position(mColorOffset);
-    GLES20.glVertexAttribPointer(mColorHandle, mColorDataSize, GLES20.GL_FLOAT, false, mStrideBytes, mTriangleVertices);
-    GLES20.glEnableVertexAttribArray(mColorHandle);
+    GLES20.glVertexAttribPointer(mColorH, mColorDataSize, GLES20.GL_FLOAT, false, mStrideBytes, mTriangleVertices);
+    GLES20.glEnableVertexAttribArray(mColorH);
 
-		Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
-    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
-    GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
+		GLES20.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix, 0);
     GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
 	  }
   }
