Project

General

Profile

« Previous | Next » 

Revision 1aedf874

Added by Leszek Koltunski over 7 years ago

Revert "Beginnings of support for DistortedEffects.drawPrivFeedback()"

This reverts commit a22c66287b616833b0ad72d81d40cc321e4bc920.

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
52 52
 */
53 53
public class DistortedEffects
54 54
  {
55
  static final int MAIN_PROGRAM = 0;
56
  static final int FEED_PROGRAM = 1;
57
  static final int NUM_PROGRAMS = 2;
58

  
59
  // THIS IS FOR MAIN AND FEEDBACK PROGRAMS ///
55
  /// MAIN PROGRAM ///
56
  private static DistortedProgram mMainProgram;
57
  private static int mMainTextureH;
60 58
  private static boolean[] mEffectEnabled = new boolean[EffectNames.size()];
61 59

  
62 60
  static
......
69 67
      }
70 68
    }
71 69

  
72
  /// MAIN PROGRAM ///
73
  private static DistortedProgram mMainProgram;
74
  private static int mMainTextureH;
75

  
76 70
  /// BLIT PROGRAM ///
77 71
  private static DistortedProgram mBlitProgram;
78 72
  private static int mBlitTextureH;
......
86 80
    mQuadPositions.put(positionData).position(0);
87 81
    }
88 82

  
89
  /// DEBUG PROGRAM /////
83
  /// DEBUG ONLY /////
90 84
  private static DistortedProgram mDebugProgram;
91 85

  
92 86
  private static int mDebugObjDH;
93 87
  private static int mDebugMVPMatrixH;
94

  
95
  /// FEEDBACK PROGRAM //
96
  private static DistortedProgram mFeedbackProgram;
97

  
88
  /// END DEBUG //////
98 89

  
99 90
  private static float[] mMVPMatrix = new float[16];
100 91
  private static float[] mTmpMatrix = new float[16];
......
113 104
  static void createProgram(Resources resources)
114 105
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
115 106
    {
116
    //// BOTH MAIN AND FEEDBACK PROGRAMS ///////
107
    final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
108
    final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader);
109

  
117 110
    String mainVertHeader= Distorted.GLSL_VERSION;
118 111
    String mainFragHeader= Distorted.GLSL_VERSION;
119 112

  
......
148 141
    //android.util.Log.e("Effects", "vertHeader= "+mainVertHeader);
149 142
    //android.util.Log.e("Effects", "fragHeader= "+mainFragHeader);
150 143

  
151
    //////////////////////////////////////////////////////////////////////////////////////
152
    ////////// MAIN PROGRAM //////////////////////////////////////////////////////////////
153
    //////////////////////////////////////////////////////////////////////////////////////
154
    final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
155
    final InputStream mainFragStream = resources.openRawResource(R.raw.main_fragment_shader);
144
    String[] feedback = { "v_Position" };
156 145

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

  
159 148
    int mainProgramH = mMainProgram.getProgramHandle();
160 149
    EffectQueueFragment.getUniforms(mainProgramH);
161
    EffectQueueVertex.getUniforms(MAIN_PROGRAM,mainProgramH);
162
    EffectQueueMatrix.getUniforms(MAIN_PROGRAM,mainProgramH);
150
    EffectQueueVertex.getUniforms(mainProgramH);
151
    EffectQueueMatrix.getUniforms(mainProgramH);
163 152
    mMainTextureH= GLES30.glGetUniformLocation( mainProgramH, "u_Texture");
164 153

  
165
    //////////////////////////////////////////////////////////////////////////////////////
166
    ////////// FEEDBACK PROGRAM //////////////////////////////////////////////////////////
167
    //////////////////////////////////////////////////////////////////////////////////////
168
    final InputStream feedVertStream = resources.openRawResource(R.raw.main_vertex_shader);
169
    final InputStream feedFragStream = resources.openRawResource(R.raw.feedback_fragment_shader);
170

  
171
    String[] feedback = { "v_Position" };
172

  
173
    mFeedbackProgram = new DistortedProgram(feedVertStream,feedFragStream, mainVertHeader, Distorted.GLSL_VERSION, Distorted.GLSL, feedback);
174

  
175
    int feedProgramH = mFeedbackProgram.getProgramHandle();
176
    EffectQueueFragment.getUniforms(feedProgramH);
177
    EffectQueueVertex.getUniforms(FEED_PROGRAM,feedProgramH);
178
    EffectQueueMatrix.getUniforms(FEED_PROGRAM,feedProgramH);
179

  
180
    //////////////////////////////////////////////////////////////////////////////////////
181
    ////////// BLIT PROGRAM //////////////////////////////////////////////////////////////
182
    //////////////////////////////////////////////////////////////////////////////////////
154
    // BLIT PROGRAM ////////////////////////////////////
183 155
    final InputStream blitVertStream = resources.openRawResource(R.raw.blit_vertex_shader);
184 156
    final InputStream blitFragStream = resources.openRawResource(R.raw.blit_fragment_shader);
185 157

  
......
200 172
    mBlitTextureH  = GLES30.glGetUniformLocation( blitProgramH, "u_Texture");
201 173
    mBlitDepthH    = GLES30.glGetUniformLocation( blitProgramH, "u_Depth");
202 174

  
203
    //////////////////////////////////////////////////////////////////////////////////////
204
    ////////// DEBUG PROGRAM /////////////////////////////////////////////////////////////
205
    //////////////////////////////////////////////////////////////////////////////////////
175
    // DEBUG ONLY //////////////////////////////////////
206 176
    final InputStream debugVertexStream   = resources.openRawResource(R.raw.test_vertex_shader);
207 177
    final InputStream debugFragmentStream = resources.openRawResource(R.raw.test_fragment_shader);
208 178

  
......
219 189
    int debugProgramH = mDebugProgram.getProgramHandle();
220 190
    mDebugObjDH = GLES30.glGetUniformLocation( debugProgramH, "u_objD");
221 191
    mDebugMVPMatrixH = GLES30.glGetUniformLocation( debugProgramH, "u_MVPMatrix");
192
    // END DEBUG  //////////////////////////////////////
222 193
    }
223 194

  
224 195
///////////////////////////////////////////////////////////////////////////////////////////////////
......
311 282
    GLES30.glVertexAttribPointer(mDebugProgram.mAttribute[0], 2, GLES30.GL_FLOAT, false, 0, mQuadPositions);
312 283
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, 4);
313 284
    }
285

  
314 286
///////////////////////////////////////////////////////////////////////////////////////////////////
315 287

  
316 288
  void drawPriv(float halfW, float halfH, MeshObject mesh, DistortedOutputSurface surface, long currTime)
317 289
    {
290
    int error;
291

  
318 292
    mM.compute(currTime);
319 293
    mV.compute(currTime);
320 294
    mF.compute(currTime);
......
326 300
    mMainProgram.useProgram();
327 301
    GLES30.glUniform1i(mMainTextureH, 0);
328 302
    surface.setAsOutput(currTime);
329
    mM.send(MAIN_PROGRAM,surface,halfW,halfH,halfZ);
330
    mV.send(MAIN_PROGRAM,halfW,halfH,halfZ);
303
    mM.send(surface,halfW,halfH,halfZ);
304
    mM.send(surface,halfW,halfH,halfZ);
305
    mV.send(halfW,halfH,halfZ);
331 306
    mF.send(halfW,halfH);
332 307

  
333 308
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosVBO[0]);
......
337 312
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
338 313
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
339 314

  
340
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
341
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
342
    }
343

  
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

  
346
  void drawPrivFeedback(float halfW, float halfH, MeshObject mesh, DistortedOutputSurface surface, long currTime)
347
    {
348
    mM.compute(currTime);
349
    mV.compute(currTime);
350
    mF.compute(currTime);
351

  
352
    float halfZ = halfW*mesh.zFactor;
353

  
354
    GLES30.glViewport(0, 0, surface.mWidth, surface.mHeight );
315
    GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
355 316

  
356
    mFeedbackProgram.useProgram();
357
    surface.setAsOutput(currTime);
358
    mM.send(FEED_PROGRAM,surface,halfW,halfH,halfZ);
359
    mV.send(FEED_PROGRAM,halfW,halfH,halfZ);
317
    GLES30.glBeginTransformFeedback(GLES30.GL_TRIANGLES);
360 318

  
361
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosVBO[0]);
362
    GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[0], MeshObject.POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
363
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mNorVBO[0]);
364
    GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE  , GLES30.GL_FLOAT, false, 0, 0);
365
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
366
    GLES30.glVertexAttribPointer(mFeedbackProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
319
    error = GLES30.glGetError();
320
    if (error != GLES30.GL_NO_ERROR)
321
      {
322
      throw new RuntimeException("1 glError 0x" + Integer.toHexString(error));
323
      }
367 324

  
368
    GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, mesh.mPosTBO[0]);
369
    GLES30.glEnable(GLES30.GL_RASTERIZER_DISCARD);
370
    GLES30.glBeginTransformFeedback(GLES30.GL_POINTS);
371
    GLES30.glDrawArrays(GLES30.GL_POINTS, 0, mesh.dataLength);
325
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
372 326

  
373
    int error = GLES30.glGetError();
327
    error = GLES30.glGetError();
374 328
    if (error != GLES30.GL_NO_ERROR)
375 329
      {
376 330
      throw new RuntimeException("2 glError 0x" + Integer.toHexString(error));
377 331
      }
378 332

  
379 333
    GLES30.glEndTransformFeedback();
380
    GLES30.glDisable(GLES30.GL_RASTERIZER_DISCARD);
334
    GLES30.glFlush();
335

  
381 336
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
382
/*
383
int len = mesh.dataLength*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
337

  
338
int len = 3*(mesh.dataLength-2)*MeshObject.BYTES_PER_FLOAT*MeshObject.POSITION_DATA_SIZE;
384 339

  
385 340
Buffer mappedBuffer =  GLES30.glMapBufferRange(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, len, GLES30.GL_MAP_READ_BIT);
386 341
FloatBuffer fb = ((ByteBuffer) mappedBuffer).order(ByteOrder.nativeOrder()).asFloatBuffer();
......
394 349
android.util.Log.d( "Feedback", msgB);
395 350

  
396 351
String msgA = "";
397
for(int d=0; d<mesh.dataLength; d++)
352
for(int d=0; d<3*(mesh.dataLength-2); d++)
398 353
  {
399
  msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
354
  if( d==0 || d==1 || ((d-2)%3)==0)
355
     msgA+="("+fb.get(3*d+0)+","+fb.get(3*d+1)+","+fb.get(3*d+2)+")";
400 356
  }
401 357
android.util.Log.d( "Feedback", msgA);
402 358

  
403 359
android.util.Log.e( "Feedback",msgA.equalsIgnoreCase(msgB) ? "identical":"not identical");
404 360

  
405
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
406
*/
407 361

  
408 362
    /// DEBUG ONLY //////
409 363
    // displayBoundingRect(halfW, halfH, halfZ, surface, mM.getMVP(), fb, currTime );
410 364
    /// END DEBUG ///////
411 365

  
412
GLES30.glBindBufferBase(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0);
413

  
414

  
415

  
416

  
417
    mMainProgram.useProgram();
418
    GLES30.glUniform1i(mMainTextureH, 0);
419
    mM.sendFeedback(MAIN_PROGRAM,surface,halfW,halfH,halfZ);
420
    mV.sendZero(MAIN_PROGRAM);
421
    mF.send(halfW,halfH);
422

  
423
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mPosTBO[0]);
424
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POSITION_DATA_SIZE, GLES30.GL_FLOAT, false, 0, 0);
425
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mNorVBO[0]);
426
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NORMAL_DATA_SIZE  , GLES30.GL_FLOAT, false, 0, 0);
427
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mTexVBO[0]);
428
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE     , GLES30.GL_FLOAT, false, 0, 0);
366
GLES30.glUnmapBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER);
429 367

  
430
    GLES30.glDrawArrays(GLES30.GL_TRIANGLE_STRIP, 0, mesh.dataLength);
431
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
432 368
    }
433 369

  
434 370
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/DistortedNode.java
264 264
    if( input.setAsInput() )
265 265
      {
266 266
      mState.apply();
267
      mEffects.drawPrivFeedback(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
267
      mEffects.drawPriv(mSurface.getWidth()/2.0f, mSurface.getHeight()/2.0f, mMesh, surface, currTime);
268 268
      return 1;
269 269
      }
270 270

  
src/main/java/org/distorted/library/EffectQueueMatrix.java
46 46
  private static float[] mTmpMatrix = new float[16];
47 47
  private static float[] mViewMatrix= new float[16];
48 48

  
49
  private static int[] mObjDH       = new int[DistortedEffects.NUM_PROGRAMS];
50
  private static int[] mMVPMatrixH  = new int[DistortedEffects.NUM_PROGRAMS];
51
  private static int[] mMVMatrixH   = new int[DistortedEffects.NUM_PROGRAMS];
49
  private static int mObjDH;      // This is a handle to half a Object dimensions
50
  private static int mMVPMatrixH; // pass in the transformation matrix
51
  private static int mMVMatrixH;  // pass in the modelview matrix.
52 52
  
53 53
///////////////////////////////////////////////////////////////////////////////////////////////////
54 54
   
......
191 191

  
192 192
///////////////////////////////////////////////////////////////////////////////////////////////////
193 193

  
194
  static void getUniforms(int index,int mProgramH)
194
  static void getUniforms(int mProgramH)
195 195
    {
196
    mObjDH[index]     = GLES30.glGetUniformLocation(mProgramH, "u_objD");
197
    mMVPMatrixH[index]= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix");
198
    mMVMatrixH[index] = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix");
196
    mObjDH     = GLES30.glGetUniformLocation(mProgramH, "u_objD");
197
    mMVPMatrixH= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix");
198
    mMVMatrixH = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix"); 
199 199
    }
200 200

  
201 201
///////////////////////////////////////////////////////////////////////////////////////////////////
......
259 259

  
260 260
///////////////////////////////////////////////////////////////////////////////////////////////////
261 261

  
262
  synchronized void send(int index,DistortedOutputSurface projection, float halfX, float halfY, float halfZ)
262
  synchronized void send(DistortedOutputSurface projection, float halfX, float halfY, float halfZ)
263 263
    {
264 264
    constructMatrices(projection,halfX,halfY,halfZ);
265 265

  
266
    GLES30.glUniform3f( mObjDH[index] , halfX, halfY, halfZ);
267
    GLES30.glUniformMatrix4fv(mMVMatrixH[index] , 1, false, mViewMatrix, 0);
268
    GLES30.glUniformMatrix4fv(mMVPMatrixH[index], 1, false, mMVPMatrix , 0);
269
    }
270

  
271
///////////////////////////////////////////////////////////////////////////////////////////////////
272

  
273
  synchronized void sendFeedback(int index,DistortedOutputSurface projection, float halfX, float halfY, float halfZ)
274
    {
275
    constructMatrices(projection,halfX,halfY,halfZ);
276

  
277
    GLES30.glUniform3f( mObjDH[index] , 0.5f, 0.5f, 0.5f);
278
    GLES30.glUniformMatrix4fv(mMVMatrixH[index] , 1, false, mViewMatrix, 0);
279
    GLES30.glUniformMatrix4fv(mMVPMatrixH[index], 1, false, mMVPMatrix , 0);
266
    GLES30.glUniform3f( mObjDH , halfX, halfY, halfZ);
267
    GLES30.glUniformMatrix4fv(mMVMatrixH , 1, false, mViewMatrix, 0);
268
    GLES30.glUniformMatrix4fv(mMVPMatrixH, 1, false, mMVPMatrix , 0);
280 269
    }
281 270

  
282 271
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/EffectQueueVertex.java
45 45
  private static final int NUM_UNIFORMS = 12;
46 46
  private static final int NUM_CACHE    =  3;
47 47
  private static final int INDEX = EffectTypes.VERTEX.ordinal();
48
  private static int[] mNumEffectsH = new int[DistortedEffects.NUM_PROGRAMS];
49
  private static int[] mTypeH       = new int[DistortedEffects.NUM_PROGRAMS];
50
  private static int[] mUniformsH   = new int[DistortedEffects.NUM_PROGRAMS];
48
  private static int mNumEffectsH;
49
  private static int mTypeH;
50
  private static int mUniformsH;
51 51
  
52 52
///////////////////////////////////////////////////////////////////////////////////////////////////
53 53
   
......
58 58

  
59 59
///////////////////////////////////////////////////////////////////////////////////////////////////
60 60

  
61
  static void getUniforms(int index, int mProgramH)
61
  static void getUniforms(int mProgramH)
62 62
    {
63
    mNumEffectsH[index]= GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
64
    mTypeH[index]      = GLES30.glGetUniformLocation( mProgramH, "vType");
65
    mUniformsH[index]  = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
63
    mNumEffectsH= GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
64
    mTypeH      = GLES30.glGetUniformLocation( mProgramH, "vType");
65
    mUniformsH  = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
66 66
    }
67 67

  
68 68
///////////////////////////////////////////////////////////////////////////////////////////////////
......
133 133
   
134 134
///////////////////////////////////////////////////////////////////////////////////////////////////
135 135

  
136
  synchronized void send(int index, float halfX, float halfY, float halfZ)
136
  synchronized void send(float halfX, float halfY, float halfZ)
137 137
    {
138
    GLES30.glUniform1i( mNumEffectsH[index], mNumEffects);
138
    GLES30.glUniform1i( mNumEffectsH, mNumEffects);
139 139
      
140 140
    if( mNumEffects>0 )
141 141
      {
......
146 146
        mUniforms[NUM_UNIFORMS*i+7] = mCache[NUM_CACHE*i+2]-halfZ;
147 147
        }
148 148

  
149
      GLES30.glUniform1iv( mTypeH[index]    ,                 mNumEffects, mName    ,0);
150
      GLES30.glUniform4fv( mUniformsH[index],(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
149
      GLES30.glUniform1iv( mTypeH    ,                 mNumEffects, mName    ,0);
150
      GLES30.glUniform4fv( mUniformsH,(NUM_UNIFORMS/4)*mNumEffects, mUniforms,0);
151 151
      }
152 152
    }
153 153

  
154
///////////////////////////////////////////////////////////////////////////////////////////////////
155

  
156
  synchronized void sendZero(int index)
157
    {
158
    GLES30.glUniform1i( mNumEffectsH[index], 0);
159
    }
160

  
161 154
///////////////////////////////////////////////////////////////////////////////////////////////////
162 155
// Do various post-processing on already computed effects.
163 156
// 1) here unlike in the fragment queue, we don't have to multiply the points by ModelView matrix because that gets done in the shader.
src/main/java/org/distorted/library/MeshObject.java
71 71
       {
72 72
       GLES30.glGenBuffers(1, mPosVBO, 0);
73 73
       GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mPosVBO[0]);
74
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, mMeshPositions, GLES30.GL_STATIC_DRAW);
74
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*POSITION_DATA_SIZE*BYTES_PER_FLOAT, mMeshPositions, GLES30.GL_STATIC_READ);
75 75
       }
76 76
     if( mNorVBO[0]<0 )
77 77
       {
78 78
       GLES30.glGenBuffers(1, mNorVBO, 0);
79 79
       GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mNorVBO[0]);
80
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*  NORMAL_DATA_SIZE*BYTES_PER_FLOAT, mMeshNormals  , GLES30.GL_STATIC_DRAW);
80
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*  NORMAL_DATA_SIZE*BYTES_PER_FLOAT, mMeshNormals  , GLES30.GL_STATIC_READ);
81 81
       }
82 82
     if( mTexVBO[0]<0 )
83 83
       {
84 84
       GLES30.glGenBuffers(1, mTexVBO, 0);
85 85
       GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mTexVBO[0]);
86
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, dataLength*    TEX_DATA_SIZE*BYTES_PER_FLOAT, mMeshTexture  , GLES30.GL_STATIC_DRAW);
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 )
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.
90 91
       {
91 92
       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.glBufferData(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 3*(dataLength-2)*POSITION_DATA_SIZE*BYTES_PER_FLOAT, null, GLES30.GL_STATIC_READ);
93 94
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, 0);
94 95
       }
95 96

  

Also available in: Unified diff