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 |
|
// GLES30.glEndTransformFeedback();
|
318 |
|
// GLES30.glFlush();
|
|
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();
|
319 |
327 |
|
320 |
328 |
GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
|
321 |
|
/*
|
322 |
|
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
|
|
329 |
|
|
330 |
int len = 3*(mesh.dataLength-2)*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
|
323 |
331 |
|
324 |
332 |
Buffer mappedBuffer = GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT);
|
325 |
333 |
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
326 |
334 |
FloatBuffer bb = mesh.mMeshPositions;
|
327 |
335 |
|
328 |
|
String msgB = "BEFORE: ", msgA = "AFTER : ";
|
|
336 |
String msgB = "";
|
329 |
337 |
for(int d=0; d<mesh.dataLength; d++)
|
330 |
338 |
{
|
331 |
339 |
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)+")";
|
333 |
340 |
}
|
334 |
341 |
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 |
}
|
335 |
349 |
android.util.Log.d( "Feedback", msgA);
|
336 |
350 |
|
|
351 |
android.util.Log.e( "Feedback",msgA.equalsIgnoreCase(msgB) ? "identical":"not identical");
|
|
352 |
|
|
353 |
|
337 |
354 |
/// DEBUG ONLY //////
|
338 |
355 |
// displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
|
339 |
356 |
/// END DEBUG ///////
|
340 |
357 |
|
341 |
358 |
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
|
342 |
|
*/
|
|
359 |
|
343 |
360 |
}
|
344 |
361 |
|
345 |
362 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 however crashes with GL_INVALID_OPERATION during glDrawArrays() when run on Nexus 4.