Project

General

Profile

« Previous | Next » 

Revision 040cd18c

Added by Leszek Koltunski almost 6 years ago

Port all the 'non-controversial' changes from order-independent-transparency branch.

View differences:

src/main/java/org/distorted/library/main/DistortedEffects.java
31 31
import org.distorted.library.effect.VertexEffect;
32 32
import org.distorted.library.message.EffectListener;
33 33
import org.distorted.library.program.DistortedProgram;
34
import org.distorted.library.program.FragmentCompilationException;
35
import org.distorted.library.program.FragmentUniformsException;
36
import org.distorted.library.program.LinkingException;
37
import org.distorted.library.program.VertexCompilationException;
38
import org.distorted.library.program.VertexUniformsException;
39 34

  
40 35
import java.io.InputStream;
41 36
import java.nio.ByteBuffer;
......
92 87
///////////////////////////////////////////////////////////////////////////////////////////////////
93 88

  
94 89
  static void createProgram(Resources resources)
95
  throws FragmentCompilationException,VertexCompilationException,VertexUniformsException,FragmentUniformsException,LinkingException
96 90
    {
97 91
    // MAIN PROGRAM ////////////////////////////////////
98 92
    final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
......
113 107

  
114 108
    String[] feedback = { "v_Position", "v_endPosition" };
115 109

  
116
    mMainProgram = new DistortedProgram( mainVertStream, mainFragStream, mainVertHeader, mainFragHeader,
117
                                         enabledEffectV, enabledEffectF, Distorted.GLSL, feedback);
110
    try
111
      {
112
      mMainProgram = new DistortedProgram(mainVertStream, mainFragStream, mainVertHeader, mainFragHeader,
113
                                          enabledEffectV, enabledEffectF, Distorted.GLSL, feedback);
114
      }
115
    catch(Exception e)
116
      {
117
      Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile MAIN program: "+e.getMessage());
118
      throw new RuntimeException(e.getMessage());
119
      }
118 120

  
119 121
    int mainProgramH = mMainProgram.getProgramHandle();
120 122
    EffectQueueFragment.getUniforms(mainProgramH);
......
135 137
      }
136 138
    catch(Exception e)
137 139
      {
138
      Log.e("EFFECTS", "exception trying to compile BLIT program: "+e.getMessage());
140
      Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile BLIT program: "+e.getMessage());
139 141
      throw new RuntimeException(e.getMessage());
140 142
      }
141 143

  
......
153 155
      }
154 156
    catch(Exception e)
155 157
      {
156
      Log.e("EFFECTS", "exception trying to compile BLIT DEPTH program: "+e.getMessage());
158
      Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile BLIT DEPTH program: "+e.getMessage());
157 159
      throw new RuntimeException(e.getMessage());
158 160
      }
159 161

  
......
173 175
      }
174 176
    catch(Exception e)
175 177
      {
176
      Log.e("EFFECTS", "exception trying to compile NORMAL program: "+e.getMessage());
178
      Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile NORMAL program: "+e.getMessage());
177 179
      throw new RuntimeException(e.getMessage());
178 180
      }
179 181

  
......
284 286
    mMainProgram.useProgram();
285 287
    GLES31.glUniform1i(mMainTextureH, 0);
286 288

  
287
    if( Distorted.GLSL >= 300 )
288
      {
289
      GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mesh.mAttVBO[0]);
290
      GLES31.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET0);
291
      GLES31.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET1);
292
      GLES31.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET2);
293
      GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
294
      }
295
    else
296
      {
297
      mesh.mVertAttribs.position(0);
298
      GLES31.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
299
      mesh.mVertAttribs.position(MeshObject.POS_DATA_SIZE);
300
      GLES31.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
301
      mesh.mVertAttribs.position(MeshObject.POS_DATA_SIZE+MeshObject.NOR_DATA_SIZE);
302
      GLES31.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, mesh.mVertAttribs);
303
      }
289
    GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, mesh.mAttVBO[0]);
290
    GLES31.glVertexAttribPointer(mMainProgram.mAttribute[0], MeshObject.POS_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET0);
291
    GLES31.glVertexAttribPointer(mMainProgram.mAttribute[1], MeshObject.NOR_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET1);
292
    GLES31.glVertexAttribPointer(mMainProgram.mAttribute[2], MeshObject.TEX_DATA_SIZE, GLES31.GL_FLOAT, false, MeshObject.VERTSIZE, MeshObject.OFFSET2);
293
    GLES31.glBindBuffer(GLES31.GL_ARRAY_BUFFER, 0);
304 294

  
305 295
    mM.send(surface,halfW,halfH,halfZ,marginInPixels);
306 296
    mV.send();

Also available in: Unified diff