Project

General

Profile

« Previous | Next » 

Revision 6e60be83

Added by Leszek Koltunski over 7 years ago

Revert "Progress with Transform Feedback."

This reverts commit e78a30fd53d9463903521921e177028e5c869514.

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
38 38
import org.distorted.library.type.Static3D;
39 39

  
40 40
import java.io.InputStream;
41
import java.nio.Buffer;
42 41
import java.nio.ByteBuffer;
43 42
import java.nio.ByteOrder;
44 43
import java.nio.FloatBuffer;
......
141 140
    //android.util.Log.e("Effects", "vertHeader= "+mainVertHeader);
142 141
    //android.util.Log.e("Effects", "fragHeader= "+mainFragHeader);
143 142

  
144
    String[] feedback = { "v_Position" };
145

  
146
    mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL, feedback);
143
    mMainProgram = new DistortedProgram(mainVertStream,mainFragStream, mainVertHeader, mainFragHeader, Distorted.GLSL);
147 144

  
148 145
    int mainProgramH = mMainProgram.getProgramHandle();
149 146
    EffectQueueFragment.getUniforms(mainProgramH);
......
309 306
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE  , GLES30.GL_FLOAT, false, 0, 0);
310 307
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
311 308
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
312

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

  
315
//    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
316 309
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
317
  //  GLES30.glEndTransformFeedback();
318
  //  GLES30.glFlush();
319

  
320 310
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
321
/*
322
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
323

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

  
328
String msgB = "BEFORE: ", msgA = "AFTER : ";
329
for(int d=0; d<mesh.dataLength; d++)
330
  {
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)+")";
333
  }
334
android.util.Log.d( "Feedback", msgB);
335
android.util.Log.d( "Feedback", msgA);
336 311

  
337 312
    /// DEBUG ONLY //////
338
    // displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
313
    // displayBoundingRect(halfInputW, halfInputH, halfZ, df, mM.getMVP(), mesh.getBoundingVertices() );
339 314
    /// END DEBUG ///////
340

  
341
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
342
*/
343 315
    }
344 316

  
345 317
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/EffectQueueMatrix.java
250 250
    mUniforms[NUM_UNIFORMS*index+6] = mUniforms[NUM_UNIFORMS*(index+1)+6];
251 251
    }
252 252

  
253
///////////////////////////////////////////////////////////////////////////////////////////////////
254

  
255
  float[] getMVP()
256
    {
257
    return mMVPMatrix;
258
    }
259

  
260 253
///////////////////////////////////////////////////////////////////////////////////////////////////
261 254

  
262 255
  synchronized void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ)
src/main/java/org/distorted/library/MeshObject.java
44 44
   int[] mNorVBO = new int[1];
45 45
   int[] mTexVBO = new int[1];
46 46

  
47
   int[] mPosTBO = new int[1]; // Transform Feedback
48

  
49 47
   final float zFactor; // strange workaround for the fact that we need to somehow store the 'depth'
50 48
                        // of the Mesh. Used in DistortedEffects. See DistortedTexture.getDepth().
51 49

  
......
86 84
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*    TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture  , GLES30.GL_STATIC_READ);
87 85
       }
88 86

  
89
     if( mPosTBO[0]<0 )
90
       {
91
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mPosTBO[0]);
92
       GLES30.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
93
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
94
       }
95

  
96 87
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
97 88
     }
98 89

  
......
116 107
       GLES30.glDeleteBuffers(1, mTexVBO, 0);
117 108
       mTexVBO[0] = -1;
118 109
       }
119
     if( mPosTBO[0]>=0 )
120
       {
121
       GLES30.glDeleteBuffers(1, mPosTBO, 0);
122
       mPosTBO[0] = -1;
123
       }
124 110
     }
125 111

  
126 112
///////////////////////////////////////////////////////////////////////////////////////////////////
......
130 116
     mPosVBO[0] = -1;
131 117
     mNorVBO[0] = -1;
132 118
     mTexVBO[0] = -1;
133
     mPosTBO[0] = -1;
134 119
     }
135 120

  
136 121
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff