commit 66ace7f5b4d901b6f099d5b6d0406d832dc436a8
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Mar 28 18:34:13 2018 +0100

    SSBO: fix problems with endianness.

diff --git a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
index c48e5fc..8be0e01 100644
--- a/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
+++ b/src/main/java/org/distorted/library/main/DistortedOutputSurface.java
@@ -26,6 +26,7 @@ import org.distorted.library.effect.EffectQuality;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.nio.IntBuffer;
 import java.util.ArrayList;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -104,17 +105,15 @@ public static final int DEBUG_FPS = 1;
   private static int mBufferSize     =10;
   private static DistortedObjectCounter mSurfaceCounter = new DistortedObjectCounter();
   private static int[] mSSBO = new int[1];
-  private static ByteBuffer mSSBOBuffer;
+  private static IntBuffer mIntBuffer;
 
   static
     {
-    mSSBO[0]    = -1;
-    mSSBOBuffer = ByteBuffer.allocateDirect(BUFFERING*mBufferSize*4).order(ByteOrder.nativeOrder());
+    mSSBO[0]= -1;
     }
 
   private int mSurfaceID;
   private int mLastIndex;
-
   // end section
   ////////////////////////////////////////////////////////////////////////////////
 
@@ -162,18 +161,6 @@ public static final int DEBUG_FPS = 1;
     createProjection();
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  void error(String msg)
-    {
-    int err = GLES31.glGetError();
-
-    if( err != GLES31.GL_NO_ERROR )
-      {
-      android.util.Log.e("surface", msg+" error: "+err);
-      }
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Must be called from a thread holding OpenGL Context
 
@@ -185,13 +172,10 @@ public static final int DEBUG_FPS = 1;
 
       // here bind the new SSBO and map it
       GLES31.glBindBuffer(GLES31.GL_SHADER_STORAGE_BUFFER, mSSBO[0]);
-      error("pre1");
       GLES31.glBufferData(GLES31.GL_SHADER_STORAGE_BUFFER, BUFFERING*mBufferSize*4 , null, GLES31.GL_DYNAMIC_READ);
-      error("pre2");
-      mSSBOBuffer = (ByteBuffer) GLES31.glMapBufferRange(GLES31.GL_SHADER_STORAGE_BUFFER, 0, BUFFERING*mBufferSize*4, GLES31.GL_MAP_READ_BIT );
-      error("pre3");
+      ByteBuffer buf = (ByteBuffer) GLES31.glMapBufferRange(GLES31.GL_SHADER_STORAGE_BUFFER, 0, BUFFERING*mBufferSize*4, GLES31.GL_MAP_READ_BIT );
+      mIntBuffer = buf.order(ByteOrder.nativeOrder()).asIntBuffer();
       GLES31.glBindBufferBase(GLES31.GL_SHADER_STORAGE_BUFFER,0, mSSBO[0]);
-      error("pre4");
       }
 
     mSurfaceID = mSurfaceCounter.returnNext();
@@ -227,7 +211,7 @@ public static final int DEBUG_FPS = 1;
 
   int resetNewCounter()
     {
-    //mSSBOBuffer.putInt(BUFFERING*mSurfaceID+mLastIndex,0);
+    //mIntBuffer.put(BUFFERING*mSurfaceID+mLastIndex,0);
     return BUFFERING*mSurfaceID + mLastIndex;
     }
 
@@ -235,7 +219,7 @@ public static final int DEBUG_FPS = 1;
 
   int returnOldCounter()
     {
-    int ret = mSSBOBuffer.getInt(BUFFERING*mSurfaceID+mLastIndex);
+    int ret = mIntBuffer.get(BUFFERING*mSurfaceID+mLastIndex);
 
     mLastIndex++;
     if( mLastIndex>=BUFFERING ) mLastIndex-=BUFFERING;
@@ -247,7 +231,7 @@ public static final int DEBUG_FPS = 1;
 
   int returnCounter()
     {
-    return mSSBOBuffer.getInt(0);
+    return mIntBuffer.get(0);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
