Project

General

Profile

« Previous | Next » 

Revision e4577791

Added by Leszek Koltunski over 1 year ago

fix detection of not used attributes.

View differences:

src/main/java/org/distorted/library/mesh/MeshBase.java
813 813
     int index2 = mVBO2.createImmediatelyFloat(mNumVertices*VERT2_SIZE, mVertAttribs2);
814 814
     int[] attr = program.mAttribute;
815 815

  
816
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index1 );
817
     GLES30.glVertexAttribPointer(attr[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
818
     GLES30.glVertexAttribPointer(attr[1], NOR_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_NOR);
819
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 );
820
     GLES30.glVertexAttribPointer(attr[2], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX);
821

  
822
     // if we are not using component centers and there are no vertex effects enabled,
823
     // then this attribute does not exist in the Vertex Shader
824
     if( attr.length>=4 )
816
     switch( attr.length )
825 817
       {
826
       GLES30.glVertexAttribPointer(attr[3], COM_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_COM);
818
       // 'normal' case
819
       case 4: GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index1 );
820
               GLES30.glVertexAttribPointer(attr[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
821
               GLES30.glVertexAttribPointer(attr[1], NOR_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_NOR);
822
               GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 );
823
               GLES30.glVertexAttribPointer(attr[2], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX);
824
               GLES30.glVertexAttribPointer(attr[3], COM_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_COM);
825
               break;
826
       // if we are not using component centers and there are no vertex effects enabled,
827
       // then component attribute does not exist in the Vertex Shader
828
       case 3: GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index1 );
829
               GLES30.glVertexAttribPointer(attr[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
830
               GLES30.glVertexAttribPointer(attr[1], NOR_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_NOR);
831
               GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 );
832
               GLES30.glVertexAttribPointer(attr[2], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX);
833
               break;
834
       // pre program used in EffectQueuePostprocessing does not have v_Normal attribute
835
       // (it is not used in the fragment shader)
836
       case 2: GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index1 );
837
               GLES30.glVertexAttribPointer(attr[0], POS_DATA_SIZE, GLES30.GL_FLOAT, false, VERT1_SIZE, OFFSET_POS);
838
               GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, index2 );
839
               GLES30.glVertexAttribPointer(attr[1], TEX_DATA_SIZE, GLES30.GL_FLOAT, false, VERT2_SIZE, OFFSET_TEX);
840
               break;
827 841
       }
828 842

  
829 843
     GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
src/main/java/org/distorted/library/program/DistortedProgram.java
349 349

  
350 350
    int emptyAttrs = 0;
351 351

  
352
    for(int i=0; i<mNumAttributes; i++)
352
    for(int i=0; i<mNumAttributes-emptyAttrs; i++)
353 353
      {
354 354
      if( att[i] < 0 )
355 355
        {
356 356
        emptyAttrs++;
357 357

  
358
        for(int j=i; j<mNumAttributes-1; j++)
358
        for(int j=i; j<mNumAttributes-emptyAttrs; j++)
359 359
          {
360 360
          att[j] = att[j+1];
361 361
          mAttributeName[j] = mAttributeName[j+1];

Also available in: Unified diff