Project

General

Profile

« Previous | Next » 

Revision c25273e0

Added by Leszek Koltunski almost 6 years ago

Standarize GLSL version across the whole library.

View differences:

src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
21 21

  
22 22
import android.opengl.GLES31;
23 23

  
24
import org.distorted.library.main.Distorted;
24 25
import org.distorted.library.main.DistortedFramebuffer;
25 26
import org.distorted.library.main.DistortedOutputSurface;
26 27
import org.distorted.library.main.DistortedRenderState;
......
233 234
    {
234 235
    final String blurVertex =
235 236

  
236
      "#version 300 es        \n"+
237
        Distorted.GLSL_VERSION   +
237 238
      "precision lowp float;  \n"+
238 239
      "in vec2 a_Position;    \n"+
239 240
      "in vec2 a_TexCoord;    \n"+
......
249 250

  
250 251
    final String blurFragment1 =
251 252

  
252
      "#version 300 es                    \n"+
253
        Distorted.GLSL_VERSION               +
253 254
      "#define MAX_BLUR "+MAX_HALO+      "\n"+
254 255
      "precision lowp float;              \n"+
255 256
      "in vec2 v_TexCoord;                \n"+
......
272 273

  
273 274
    final String blurFragment2 =
274 275

  
275
      "#version 300 es                    \n"+
276
        Distorted.GLSL_VERSION               +
276 277
      "#define MAX_BLUR "+MAX_HALO+      "\n"+
277 278
      "precision lowp float;              \n"+
278 279
      "in vec2 v_TexCoord;                \n"+
src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
21 21

  
22 22
import android.opengl.GLES31;
23 23

  
24
import org.distorted.library.main.Distorted;
24 25
import org.distorted.library.main.DistortedEffects;
25 26
import org.distorted.library.main.DistortedFramebuffer;
26 27
import org.distorted.library.main.DistortedOutputSurface;
......
249 250
    {
250 251
    final String glowVertex =
251 252

  
252
      "#version 300 es        \n"+
253
        Distorted.GLSL_VERSION   +
253 254
      "precision lowp float;  \n"+
254 255
      "in vec2 a_Position;    \n"+
255 256
      "in vec2 a_TexCoord;    \n"+
......
265 266

  
266 267
    final String glowFragment1 =
267 268

  
268
      "#version 300 es                    \n"+
269
        Distorted.GLSL_VERSION               +
269 270
      "#define MAX_BLUR "+MAX_HALO+      "\n"+
270 271
      "precision lowp float;              \n"+
271 272
      "in vec2 v_TexCoord;                \n"+
......
289 290

  
290 291
    final String glowFragment2 =
291 292

  
292
      "#version 300 es                    \n"+
293
        Distorted.GLSL_VERSION               +
293 294
      "#define MAX_BLUR "+MAX_HALO+      "\n"+
294 295
      "precision lowp float;              \n"+
295 296
      "in vec2 v_TexCoord;                \n"+
src/main/java/org/distorted/library/main/Distorted.java
35 35
 */
36 36
public class Distorted 
37 37
  {
38
  static int GLSL;
39
  static String GLSL_VERSION;
38
  public static final int GLSL = 310;
39
  public static final String GLSL_VERSION= "#version 310 es\n";
40 40
  /**
41 41
   * When creating an instance of a DistortedTexture from another instance, clone the Bitmap that's
42 42
   * backing up our DistortedTexture.
......
128 128
    android.util.Log.e("DISTORTED", "GL Vendor "   +GLES31.glGetString(GLES31.GL_VENDOR));
129 129
    android.util.Log.e("DISTORTED", "GL Renderer " +GLES31.glGetString(GLES31.GL_RENDERER));
130 130
    */
131
    GLSL = ( (configurationInfo.reqGlEsVersion>>16)>=3 ? 310 : 100 );
132
    GLSL_VERSION= (GLSL==100 ? "#version 100\n" : "#version 310 es\n");
133

  
134 131
    EffectMessageSender.startSending();
135 132

  
136 133
    final Resources resources = context.getResources();
137
    DistortedEffects.createProgram(resources);
134
    DistortedEffects.createPrograms(resources);
135
    DistortedEffects.createProgramsOIT(resources);
138 136
    PostprocessEffect.createPrograms();
139 137

  
140 138
    mInitialized = true;
src/main/java/org/distorted/library/main/DistortedEffects.java
130 130

  
131 131
///////////////////////////////////////////////////////////////////////////////////////////////////
132 132

  
133
  static void createProgram(Resources resources)
133
  static void createPrograms(Resources resources)
134 134
    {
135 135
    // MAIN PROGRAM ////////////////////////////////////
136 136
    final InputStream mainVertStream = resources.openRawResource(R.raw.main_vertex_shader);
......
206 206
    mBlitDepthDepthH        = GLES31.glGetUniformLocation( blitDepthProgramH, "u_Depth");
207 207
    mBlitDepthTexCorrH      = GLES31.glGetUniformLocation( blitDepthProgramH, "u_TexCorr");
208 208

  
209
    // NORMAL PROGRAM //////////////////////////////////////
210
    final InputStream normalVertexStream   = resources.openRawResource(R.raw.normal_vertex_shader);
211
    final InputStream normalFragmentStream = resources.openRawResource(R.raw.normal_fragment_shader);
212

  
213
    try
214
      {
215
      mNormalProgram = new DistortedProgram(normalVertexStream,normalFragmentStream, Distorted.GLSL_VERSION, Distorted.GLSL_VERSION, Distorted.GLSL);
216
      }
217
    catch(Exception e)
218
      {
219
      Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile NORMAL program: "+e.getMessage());
220
      throw new RuntimeException(e.getMessage());
221
      }
222

  
223
    int normalProgramH = mNormalProgram.getProgramHandle();
224
    mNormalMVPMatrixH  = GLES31.glGetUniformLocation( normalProgramH, "u_MVPMatrix");
225
    }
226

  
227
  ///////////////////////////////////////////////////////////////////////////////////////////////////
228

  
229
  static void createProgramsOIT(Resources resources)
230
    {
209 231
    // OIT CLEAR PROGRAM ////////////////////////////////////
210 232
    final InputStream oitClearVertStream = resources.openRawResource(R.raw.oit_vertex_shader);
211 233
    final InputStream oitClearFragStream = resources.openRawResource(R.raw.oit_clear_fragment_shader);
......
303 325
    mOITRenderDepthH        = GLES31.glGetUniformLocation( oitRenderProgramH, "u_Depth");
304 326
    mOITRenderTexCorrH      = GLES31.glGetUniformLocation( oitRenderProgramH, "u_TexCorr");
305 327
    mOITRenderSizeH         = GLES31.glGetUniformLocation( oitRenderProgramH, "u_Size");
306

  
307
    // NORMAL PROGRAM //////////////////////////////////////
308
    final InputStream normalVertexStream   = resources.openRawResource(R.raw.normal_vertex_shader);
309
    final InputStream normalFragmentStream = resources.openRawResource(R.raw.normal_fragment_shader);
310

  
311
    try
312
      {
313
      mNormalProgram = new DistortedProgram(normalVertexStream,normalFragmentStream, Distorted.GLSL_VERSION, Distorted.GLSL_VERSION, Distorted.GLSL);
314
      }
315
    catch(Exception e)
316
      {
317
      Log.e("EFFECTS", e.getClass().getSimpleName()+" trying to compile NORMAL program: "+e.getMessage());
318
      throw new RuntimeException(e.getMessage());
319
      }
320

  
321
    int normalProgramH = mNormalProgram.getProgramHandle();
322
    mNormalMVPMatrixH  = GLES31.glGetUniformLocation( normalProgramH, "u_MVPMatrix");
323 328
    }
324 329

  
325 330
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff