Project

General

Profile

« Previous | Next » 

Revision 42d910b3

Added by Leszek Koltunski almost 4 years ago

Convert AroundTheWorld to stretchless API.

View differences:

src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java
28 28
import android.graphics.Paint.Style;
29 29
import android.opengl.GLSurfaceView;
30 30

  
31
import org.distorted.library.effect.Effect;
32
import org.distorted.library.effect.EffectType;
31 33
import org.distorted.library.effect.FragmentEffectAlpha;
32 34
import org.distorted.library.effect.FragmentEffectChroma;
33 35
import org.distorted.library.effect.MatrixEffectScale;
34 36
import org.distorted.library.effect.VertexEffectDeform;
37
import org.distorted.library.effect.VertexEffectScale;
35 38
import org.distorted.library.effect.VertexEffectSink;
36 39
import org.distorted.library.effect.VertexEffectSwirl;
37 40
import org.distorted.library.main.DistortedLibrary;
......
56 59
   private DistortedScreen mScreen;
57 60
   private MeshRectangles mMesh;
58 61
   private boolean mRefresh;
59
   private Static3D mScale;
62
   private Static3D mScaleMatrix, mScaleVertex;
60 63

  
61 64
///////////////////////////////////////////////////////////////////////////////////////////////////
62 65

  
......
73 76
     mTexture= new DistortedTexture();
74 77
     mRefresh= true;
75 78

  
76
     mScale = new Static3D(1,1,1);
77
     mEffects.apply( new MatrixEffectScale(mScale));
79
     mScaleMatrix = new Static3D(1,1,1);
80
     mScaleVertex = new Static3D(1,1,1);
81
     mEffects.apply( new MatrixEffectScale(mScaleMatrix));
82
     mEffects.apply( new VertexEffectScale(mScaleVertex));
78 83
     }
79 84

  
80 85
///////////////////////////////////////////////////////////////////////////////////////////////////
......
104 109
   
105 110
///////////////////////////////////////////////////////////////////////////////////////////////////
106 111

  
107
   DistortedEffects getEffects()
112
   void apply(Effect effect)
108 113
     {
109
     return mEffects;
114
     mEffects.abortByType(EffectType.VERTEX);
115
     mEffects.abortByType(EffectType.FRAGMENT);
116

  
117
     mEffects.apply( new VertexEffectScale(mScaleVertex));
118

  
119
     if( effect!=null ) mEffects.apply(effect);
110 120
     }
111 121

  
112 122
///////////////////////////////////////////////////////////////////////////////////////////////////
......
120 130

  
121 131
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
122 132
     {
133
     VertexEffectScale.enable();
123 134
     VertexEffectSwirl.enable();
124 135
     VertexEffectDeform.enable();
125 136
     VertexEffectSink.enable();
......
143 154
     texW = width;
144 155
     texH = height;
145 156

  
146
     mScale.set(width,width,width);
157
     mScaleMatrix.set(width,width,width);
158
     mScaleVertex.set(1.0f, (float)texH/texW, 1.0f);
147 159

  
148 160
     mBitmap  = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888);
149 161
     mCanvas  = new Canvas(mBitmap);
150 162

  
151 163
     if( mMesh!=null ) mMesh.markForDeletion();
152 164
     mMesh = new MeshRectangles(80,80*texH/texW);
153
     mMesh.setStretch(1.0f, (float)texH/texW, 1.0f);
154 165

  
155 166
     mScreen.detachAll();
156 167
     mScreen.attach(mTexture,mEffects,mMesh);

Also available in: Unified diff