Project

General

Profile

« Previous | Next » 

Revision 1fc23462

Added by Leszek Koltunski almost 5 years ago

Port Dynamic to the new setStretch-less API.

View differences:

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

  
31
import org.distorted.library.effect.MatrixEffectScale;
31 32
import org.distorted.library.main.DistortedEffects;
32 33
import org.distorted.library.main.DistortedScreen;
33 34
import org.distorted.library.mesh.MeshRectangles;
34 35
import org.distorted.library.main.DistortedTexture;
35 36
import org.distorted.library.main.DistortedLibrary;
37
import org.distorted.library.type.Static3D;
36 38

  
37 39
///////////////////////////////////////////////////////////////////////////////////////////////////
38 40

  
......
46 48
   private Canvas mCanvas;
47 49
   private Bitmap mBitmap;
48 50
   private Paint mPaint;
49

  
51
   private Static3D mScale;
50 52
   private static int texW, texH;
51 53
    
52 54
///////////////////////////////////////////////////////////////////////////////////////////////////
......
63 65
     mMesh    = new MeshRectangles(1,1);
64 66
     mScreen  = new DistortedScreen();
65 67
     mEffects = new DistortedEffects();
68
     mTexture = new DistortedTexture();
69

  
70
     mScale = new Static3D(1,1,1);
71
     mEffects.apply( new MatrixEffectScale(mScale) );
66 72
     }
67 73

  
68 74
///////////////////////////////////////////////////////////////////////////////////////////////////
......
86 92
     texW = width;
87 93
     texH = height;
88 94

  
89
     DynamicSurfaceView.setHalfHeight(texH/2);
90
     DynamicSurfaceView.setHalfWidth(texW/2);
95
     mScale.set(width,height,1);
91 96

  
92
     if( mTexture!=null ) mTexture.markForDeletion();
93
     mTexture= new DistortedTexture();
94
     mMesh.setStretch(texW,texH,0);
95 97
     mBitmap = Bitmap.createBitmap(texW,texH, Bitmap.Config.ARGB_8888);
96 98
     mCanvas = new Canvas(mBitmap);
97 99

  
......
99 101
     mScreen.attach(mTexture,mEffects,mMesh);
100 102
     mScreen.resize(texW,texH);
101 103
     mView.onSurfaceChanged(texW,texH);
104
     DynamicSurfaceView.surfaceChanged(texW,texH);
102 105
     }
103 106
   
104 107
///////////////////////////////////////////////////////////////////////////////////////////////////
......
112 115
     mTexture.setTexture(mBitmap);
113 116
     mScreen.render( System.currentTimeMillis() );
114 117
     }
115

  
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117 118
  }
src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java
179 179

  
180 180
///////////////////////////////////////////////////////////////////////////////////////////////////
181 181

  
182
    public static void setHalfWidth(int hw)
182
    public static void surfaceChanged(int w, int h)
183 183
      {
184
      halfScreenWidth = hw;
185
      }
186

  
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

  
189
    public static void setHalfHeight(int hh)
190
      {
191
      halfScreenHeight = hh;
184
      halfScreenWidth = w/2;
185
      halfScreenHeight= h/2;
192 186
      }
193 187

  
194 188
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff