commit 40122d036bcbcc08f21f9794cc9d8edd423889d7
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed May 6 00:10:00 2020 +0100

    Convert DifferentEffects app to the stretch-less API.

diff --git a/src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java b/src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
index 2359523..a4f635f 100644
--- a/src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
+++ b/src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java
@@ -31,6 +31,7 @@ import org.distorted.library.effect.FragmentEffectChroma;
 import org.distorted.library.effect.MatrixEffectMove;
 import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.effect.VertexEffectDistort;
+import org.distorted.library.effect.VertexEffectScale;
 import org.distorted.library.effect.VertexEffectSink;
 import org.distorted.library.main.DistortedLibrary;
 import org.distorted.library.main.DistortedEffects;
@@ -58,8 +59,9 @@ class DifferentEffectsRenderer implements GLSurfaceView.Renderer
    private DistortedTexture mTexture;
    private MeshRectangles mMesh;
    private DistortedScreen mScreen;
-   private Static3D mScale;
+   private Static3D mScale, mScaleBitmap;
    private Static3D[] mMove;
+   private int mBmpWidth, mBmpHeight;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -85,6 +87,13 @@ class DifferentEffectsRenderer implements GLSurfaceView.Renderer
 
       for(int i=0; i<NUM; i++) mEffects[i] = new DistortedEffects();
 
+      mScaleBitmap = new Static3D(1,1,1);
+      VertexEffectScale scale = new VertexEffectScale(mScaleBitmap);
+
+      mEffects[0].apply(scale);
+      mEffects[1].apply(scale);
+      mEffects[2].apply(scale);
+
       Dynamic1D sink = new Dynamic1D(2000,0.0f);
       sink.add(new Static1D( 1));
       sink.add(new Static1D(10));
@@ -131,9 +140,9 @@ class DifferentEffectsRenderer implements GLSurfaceView.Renderer
     
    public void onSurfaceChanged(GL10 glUnused, int width, int height)
      {
-     float horiRatio = (float)width / (NUM*mMesh.getStretchX());
-     float vertRatio = (float)height/ (    mMesh.getStretchY());
-     float factor    = horiRatio > vertRatio ? vertRatio : horiRatio;
+     float horiRatio = (float)width / (NUM*mBmpWidth);
+     float vertRatio = (float)height/ (    mBmpHeight);
+     float factor    = Math.min(horiRatio, vertRatio);
 
      mScale.set( factor,factor,factor );
 
@@ -162,21 +171,19 @@ class DifferentEffectsRenderer implements GLSurfaceView.Renderer
        catch(IOException e) { }
        }
       
-     int bmpHeight = bitmap.getHeight();
-     int bmpWidth  = bitmap.getWidth();
+     mBmpHeight = bitmap.getHeight();
+     mBmpWidth  = bitmap.getWidth();
 
-     if( mMesh==null )
-       {
-       mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth);
-       mMesh.setStretch(bmpWidth, bmpHeight, 0);
-       }
+     mScaleBitmap.set(mBmpWidth,mBmpHeight,0);
 
+     if( mMesh   ==null ) mMesh = new MeshRectangles(30,30*mBmpHeight/mBmpWidth);
      if( mTexture==null ) mTexture  = new DistortedTexture();
      mTexture.setTexture(bitmap);
 
      mScreen.detachAll();
      for(int i=NUM-1; i>=0; i--) mScreen.attach(mTexture, mEffects[i], mMesh);
 
+     VertexEffectScale.enable();
      VertexEffectSink.enable();
      VertexEffectDistort.enable();
      FragmentEffectChroma.enable();
