commit c5b1451b4b8ee9873b2cc93e51c4c0fc4ca2817f
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Sun Aug 7 22:32:31 2016 +0100

    Remove the 'invert' option from DistortedProjection - this was making the DistortedNode-based apps not show the Objects, because the winding of triangles was wrong.
    Now however the DistortedNode based stuff is inverted top-down :)

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 01a9ae8..b87126e 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -91,7 +91,7 @@ public class Distorted
   static int mTextureCoordH;  // pass in model texture coordinate information.
   static int mProgramH;       // This is a handle to our shading program.  
 
-  static DistortedProjection mProjection = new DistortedProjection(false);
+  static DistortedProjection mProjection = new DistortedProjection();
   static float mFOV = 60.0f;
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/DistortedNode.java b/src/main/java/org/distorted/library/DistortedNode.java
index 4d4fbec..3e0b549 100644
--- a/src/main/java/org/distorted/library/DistortedNode.java
+++ b/src/main/java/org/distorted/library/DistortedNode.java
@@ -248,7 +248,7 @@ public class DistortedNode
 
       if( newList.size()>1 && mData.mProjection==null )
         {     
-        mData.mProjection = new DistortedProjection(true);
+        mData.mProjection = new DistortedProjection();
         mData.mProjection.onSurfaceChanged(mObject.getWidth(), mObject.getHeight());
         mData.mFramebufferID = 0;
         mData.mTextureID = TEXTURE_NOT_CREATED_YET;
diff --git a/src/main/java/org/distorted/library/DistortedProjection.java b/src/main/java/org/distorted/library/DistortedProjection.java
index b9d4002..e04f831 100644
--- a/src/main/java/org/distorted/library/DistortedProjection.java
+++ b/src/main/java/org/distorted/library/DistortedProjection.java
@@ -29,18 +29,11 @@ class DistortedProjection
   {
   int width,height,depth,distance;
   float[] projectionMatrix;
-  
-  private boolean invert;  // invert top with bottom? We don't do that for the projection to the screen,
-                           // but we need that for the projection to FBOs. (that's because each time we
-                           // render to FBO we invert the texture upside down because its vertex coords
-                           // are purposefully set upside down in DistortedBackground; so each time we
-                           // render through FBO we need to invert it once more to counter this effect)
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-  public DistortedProjection(boolean inv) 
+  public DistortedProjection()
    {
-   invert = inv;  
    projectionMatrix = new float[16];   
    }
 
@@ -64,8 +57,7 @@ class DistortedProjection
       distance = (int)(height*near/(top-bottom));
       far = 2*distance-near;
      
-      if( invert ) Matrix.frustumM(projectionMatrix, 0, left, right, top, bottom, near, far);
-      else         Matrix.frustumM(projectionMatrix, 0, left, right, bottom, top, near, far);        
+      Matrix.frustumM(projectionMatrix, 0, left, right, bottom, top, near, far);
       }
     else                      // parallel projection
       {
@@ -73,8 +65,7 @@ class DistortedProjection
       distance = (int)(height*near/(top-bottom));
       far = 2*distance-near;
     
-      if( invert ) Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2, surfaceHeight/2,-surfaceHeight/2, near, far);
-      else         Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2,-surfaceHeight/2, surfaceHeight/2, near, far);
+      Matrix.orthoM(projectionMatrix, 0, -surfaceWidth/2, surfaceWidth/2,-surfaceHeight/2, surfaceHeight/2, near, far);
       }
    
     depth = (int)((far-near)/2);
diff --git a/src/main/java/org/distorted/library/EffectQueueMatrix.java b/src/main/java/org/distorted/library/EffectQueueMatrix.java
index 63ab5aa..4b746f8 100644
--- a/src/main/java/org/distorted/library/EffectQueueMatrix.java
+++ b/src/main/java/org/distorted/library/EffectQueueMatrix.java
@@ -227,7 +227,7 @@ class EffectQueueMatrix extends EffectQueue
         }
       }
    
-    Matrix.translateM(viewMatrix, 0, mObjHalfX,-mObjHalfY, -mObjHalfZ);
+    Matrix.translateM(viewMatrix, 0, mObjHalfX,-mObjHalfY, 0);
     Matrix.multiplyMM(mMVPMatrix, 0, dp.projectionMatrix, 0, viewMatrix, 0);
     
     GLES20.glUniform3f( mObjDH , mObjHalfX, mObjHalfY, mObjHalfZ);
@@ -242,7 +242,7 @@ class EffectQueueMatrix extends EffectQueue
   synchronized void sendNoEffects(DistortedProjection dp) 
     {
     Matrix.setIdentityM(mTmpMatrix, 0);
-    Matrix.translateM(mTmpMatrix, 0, mObjHalfX-dp.width/2, dp.height/2-mObjHalfY, mObjHalfZ-dp.distance);
+    Matrix.translateM(mTmpMatrix, 0, mObjHalfX-dp.width/2, dp.height/2-mObjHalfY, -dp.distance);
     Matrix.multiplyMM(mMVPMatrix, 0, dp.projectionMatrix, 0, mTmpMatrix, 0);
     
     GLES20.glUniform3f( mObjDH , mObjHalfX, mObjHalfY, mObjHalfZ);
