Project

General

Profile

« Previous | Next » 

Revision 420836fc

Added by Leszek Koltunski over 7 years ago

Some corrections so that most apps still work on the Android emulator (OpenGL ES 2.0-based)

View differences:

src/main/java/org/distorted/library/DistortedEffects.java
259 259
    surface.setAsOutput(currTime);
260 260
    GLES30.glUniform1i(mMainTextureH, 0);
261 261

  
262
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mAttVBO[0]);
263
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET0);
264
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET1);
265
    GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET2);
266
    GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0 );
262
    if( Distorted.GLSL >= 300 )
263
      {
264
      GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, mesh.mAttVBO[0]);
265
      GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET0);
266
      GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET1);
267
      GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET2);
268
      GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
269
      }
270
    else
271
      {
272
      mesh.mVertAttribs.position(0);
273
      GLES30.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
274
      mesh.mVertAttribs.position(MeshObject.POS_DATA_SIZE);
275
      GLES30.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
276
      mesh.mVertAttribs.position(MeshObject.POS_DATA_SIZE+MeshObject.NOR_DATA_SIZE);
277
      GLES30.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES30.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
278
      }
267 279

  
268 280
    mM.send(surface,halfW,halfH,halfZ);
269 281
    mV.send(halfW,halfH,halfZ);
src/main/java/org/distorted/library/MeshObject.java
82 82
       GLES30.glBufferData(GLES30.GL_ARRAY_BUFFER, numVertices*VERTSIZE, mVertAttribs, GLES30.GL_STATIC_READ);
83 83
       GLES30.glBindBuffer(GLES30.GL_ARRAY_BUFFER, 0);
84 84
       }
85
     if( mAttTFO[0]<0 )
85
     if( mAttTFO[0]<0 && Distorted.GLSL >= 300 )
86 86
       {
87 87
       GLES30.glGenBuffers(1, mAttTFO, 0);
88 88
       GLES30.glBindBuffer(GLES30.GL_TRANSFORM_FEEDBACK_BUFFER, mAttTFO[0]);
......
138 138
///////////////////////////////////////////////////////////////////////////////////////////////////
139 139
/**
140 140
 * When rendering this Mesh, do we want to render the Normal vectors as well?
141
 * <p>
142
 * Will work only on OpenGL ES >= 3.0 devices.
141 143
 *
142 144
 * @param show Controls if we render the Normal vectors or not.
143 145
 */
144 146
   public void setShowNormals(boolean show)
145 147
     {
146
     mShowNormals = show;
148
     mShowNormals = (Distorted.GLSL >= 300 && show);
147 149
     }
148 150
   }
149 151

  
src/main/java/org/distorted/library/program/DistortedProgram.java
270 270
    final int vertexShaderHandle   = compileShader(GLES30.GL_VERTEX_SHADER  , vertexHeader   + vertexShader  );
271 271
    final int fragmentShaderHandle = compileShader(GLES30.GL_FRAGMENT_SHADER, fragmentHeader + fragmentShader);
272 272

  
273
    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName, feedback);
273
    mProgramHandle = createAndLinkProgram(vertexShaderHandle, fragmentShaderHandle, mAttributeName, glslVersion>= 300 ? feedback:null );
274 274

  
275 275
    mAttribute = new int[mNumAttributes];
276 276

  

Also available in: Unified diff