Project

General

Profile

« Previous | Next » 

Revision 67c3a83b

Added by Leszek Koltunski about 7 years ago

Revert "Convert a few more APPs to the new resolution-independent Matrix Effects."

This reverts commit 51554e4700774b72e18e97c7cc72ef887dfbf551.

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldRenderer.java
21 21

  
22 22
import android.graphics.Bitmap;
23 23
import android.graphics.BitmapFactory;
24
import android.opengl.GLES30;
24 25
import android.opengl.GLSurfaceView;
25 26

  
26 27
import org.distorted.examples.R;
......
48 49
   private DistortedTexture mTexture;
49 50
   private DistortedScreen mScreen;
50 51
   private AroundTheWorldEffectsManager mManager;
51
   private int bmpWidth, bmpHeight;
52
   private int mObjWidth, mObjHeight;
52 53

  
53 54
///////////////////////////////////////////////////////////////////////////////////////////////////
54 55

  
......
83 84
    
84 85
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
85 86
      {
86
      float qx = (float)width /bmpWidth;
87
      float qy = (float)height/bmpHeight;
88

  
89 87
      mEffects.abortEffects(EffectTypes.MATRIX);
90
      mEffects.scale(  qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) );
88

  
89
      if( (float)mObjHeight/mObjWidth > (float)height/width )
90
        {
91
        int w = (height*mObjWidth)/mObjHeight;
92
        float factor = (float)height/mObjHeight;
93
        mEffects.move( new Static3D((width-w)/2,0,0) );
94
        mEffects.scale(factor);
95
        }
96
      else
97
        {
98
        int h = (width*mObjHeight)/mObjWidth;
99
        float factor = (float)width/mObjWidth;
100
        mEffects.move( new Static3D(0,(height-h)/2,0) );
101
        mEffects.scale(factor);
102
        }
91 103

  
92 104
      mScreen.resize(width,height);
93 105
      }
......
112 124
        catch(IOException e) { }
113 125
        }
114 126

  
115
      bmpWidth = bitmap.getWidth();
116
      bmpHeight= bitmap.getHeight();
127
      mObjWidth = bitmap.getWidth();
128
      mObjHeight= bitmap.getHeight();
117 129

  
118
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
130
      if( mTexture==null ) mTexture = new DistortedTexture(mObjWidth,mObjHeight);
119 131
      mTexture.setTexture(bitmap);
120 132

  
121 133
      mScreen.detachAll();
122
      mScreen.attach(mTexture, mEffects, new MeshFlat(30,30*bmpHeight/bmpWidth));
134
      mScreen.attach(mTexture, mEffects, new MeshFlat(30,30*mObjHeight/mObjWidth));
123 135

  
124 136
      DistortedEffects.enableEffect(EffectNames.DISTORT);
125 137
      DistortedEffects.enableEffect(EffectNames.SINK);

Also available in: Unified diff