Project

General

Profile

« Previous | Next » 

Revision 16b22aab

Added by Leszek Koltunski about 5 years ago

Fix several more apps for the 'center-of-matrix-effects-in-screen-center' change.

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
27 27
import org.distorted.library.effect.EffectType;
28 28
import org.distorted.library.effect.FragmentEffectChroma;
29 29
import org.distorted.library.effect.FragmentEffectContrast;
30
import org.distorted.library.effect.MatrixEffectMove;
31 30
import org.distorted.library.effect.MatrixEffectScale;
32 31
import org.distorted.library.effect.VertexEffectDistort;
33 32
import org.distorted.library.effect.VertexEffectPinch;
......
56 55
   private DistortedScreen mScreen;
57 56
   private MeshFlat mMesh;
58 57
   private AroundTheWorldEffectsManager mManager;
59
   private int mObjWidth, mObjHeight;
60
   private Static3D mMove, mScale;
58
   private Static3D mScale;
61 59

  
62 60
///////////////////////////////////////////////////////////////////////////////////////////////////
63 61

  
64 62
   AroundTheWorldRenderer(GLSurfaceView view)
65 63
      {
66
      mMove = new Static3D(0,0,0);
67 64
      mScale= new Static3D(1,1,1);
68 65

  
69 66
      mView = view;
70 67
      mManager = new AroundTheWorldEffectsManager();
71 68
      mEffects = new DistortedEffects();
72
      mEffects.apply(new MatrixEffectMove(mMove));
73 69
      mEffects.apply(new MatrixEffectScale(mScale));
74 70

  
75 71
      mManager.apply(mEffects);
......
95 91
    
96 92
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
97 93
      {
98
      if( (float)mObjHeight/mObjWidth > (float)height/width )
99
        {
100
        int w = (height*mObjWidth)/mObjHeight;
101
        float factor = (float)height/mObjHeight;
102
        mMove.set((width-w)/2,0,0);
103
        mScale.set(factor,factor,factor);
104
        }
105
      else
106
        {
107
        int h = (width*mObjHeight)/mObjWidth;
108
        float factor = (float)width/mObjWidth;
109
        mMove.set(0,(height-h)/2,0);
110
        mScale.set(factor,factor,factor);
111
        }
94
      float horiRatio = (float)width / mTexture.getWidth();
95
      float vertRatio = (float)height/ mTexture.getHeight();
96
      float factor    = horiRatio > vertRatio ? vertRatio : horiRatio;
112 97

  
98
      mScale.set( factor,factor,factor );
113 99
      mScreen.resize(width,height);
114 100
      }
115 101

  
......
133 119
        catch(IOException e) { }
134 120
        }
135 121

  
136
      mObjWidth = bitmap.getWidth();
137
      mObjHeight= bitmap.getHeight();
122
      int objWidth = bitmap.getWidth();
123
      int objHeight= bitmap.getHeight();
138 124

  
139
      if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
125
      if( mTexture==null ) mTexture = new DistortedTexture(objWidth,objHeight);
140 126
      mTexture.setTexture(bitmap);
141 127

  
142
      if( mMesh==null ) mMesh = new MeshFlat(30,30*mObjHeight/mObjWidth);
128
      if( mMesh==null ) mMesh = new MeshFlat(30,30*objHeight/objWidth);
143 129

  
144 130
      mScreen.detachAll();
145 131
      mScreen.attach(mTexture, mEffects, mMesh);

Also available in: Unified diff