Project

General

Profile

« Previous | Next » 

Revision 9cd1f9b3

Added by Leszek Koltunski over 7 years ago

Revert "This version appears to be fully working on Nexus 5X (it transfers back all the vertices and, if there are no vertex effects, the vertices transferred back are identical to the ones passed)."

This reverts commit 7cf57d72e238092806b3f833d85d16c1a38ac78d.

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
310 310
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
311 311
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
312 312

  
313
    GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
313
    //GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
314 314

  
315
    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
315
//    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
316 316
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
317

  
318
    int error = GLES30.glGetError();
319

  
320
    if (error != GLES30.GL_NO_ERROR)
321
      {
322
      throw new RuntimeException("glError 0x" + Integer.toHexString(error));
323
      }
324

  
325
    GLES30.glEndTransformFeedback();
326
    GLES30.glFlush();
317
  //  GLES30.glEndTransformFeedback();
318
  //  GLES30.glFlush();
327 319

  
328 320
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
329

  
330
int len = 3*(mesh.dataLength-2)*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
321
/*
322
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
331 323

  
332 324
Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT);
333 325
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
334 326
FloatBuffer bb = mesh.mMeshPositions;
335 327

  
336
String msgB = "";
328
String msgB = "BEFORE: ", msgA = "AFTER : ";
337 329
for(int d=0; d<mesh.dataLength; d++)
338 330
  {
339 331
  msgB+="("+(2*halfW*bb.get(3*d+0))+","+(2*halfH*bb.get(3*d+1))+","+(2*halfZ*bb.get(3*d+2))+")";
332
  msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
340 333
  }
341 334
android.util.Log.d( "Feedback", msgB);
342

  
343
String msgA = "";
344
for(int d=0; d<3*(mesh.dataLength-2); d++)
345
  {
346
  if( d==0 || d==1 || ((d-2)%3)==0)
347
     msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
348
  }
349 335
android.util.Log.d( "Feedback", msgA);
350 336

  
351
android.util.Log.e( "Feedback",msgA.equalsIgnoreCase(msgB) ? "identical":"not identical");
352

  
353

  
354 337
    /// DEBUG ONLY //////
355 338
    // displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
356 339
    /// END DEBUG ///////
357 340

  
358 341
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
359

  
342
*/
360 343
    }
361 344

  
362 345
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/MeshObject.java
86 86
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*    TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture  , GLES30.GL_STATIC_READ);
87 87
       }
88 88

  
89
     if( mPosTBO[0]<0 ) // Buffer for Transform Feedback. Since we are rendering with GL_TRIANGLE_STRIP, after passing N vertices
90
                        // we will get (N-2) triangles back, each 3 vertices of 12 bytes.
89
     if( mPosTBO[0]<0 )
91 90
       {
92 91
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mPosTBO[0]);
93
       GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 3*(dataLength-2)*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
92
       GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
94 93
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
95 94
       }
96 95

  

Also available in: Unified diff