Project

General

Profile

« Previous | Next » 

Revision 51554e47

Added by Leszek Koltunski about 7 years ago

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

View differences:

src/main/java/org/distorted/examples/girl/GirlRenderer.java
157 157

  
158 158
///////////////////////////////////////////////////////////////////////////////////////////////////
159 159
    
160
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
161
      { 
162
      float qx = (float)width /bmpWidth;
163
      float qy = (float)height/bmpHeight;
160
   public void onSurfaceChanged(GL10 glUnused, int width, int height)
161
     {
162
     float qx = (float)width /bmpWidth;
163
     float qy = (float)height/bmpHeight;
164 164

  
165
      mEffects.abortEffects(EffectTypes.MATRIX);
166
      mEffects.scale(  qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) );
165
     mEffects.abortEffects(EffectTypes.MATRIX);
166
     mEffects.scale(  qx<qy ? (new Static3D(1,qx/qy,1)) : (new Static3D(qy/qx,1,1)) );
167 167
      
168
      mScreen.resize(width, height);
169
      }
168
     mScreen.resize(width, height);
169
     }
170 170

  
171 171
///////////////////////////////////////////////////////////////////////////////////////////////////
172 172
    
173
    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
174
      {
175
      InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl);
176
      Bitmap bitmap;
173
   public void onSurfaceCreated(GL10 glUnused, EGLConfig config)
174
     {
175
     InputStream is = mView.getContext().getResources().openRawResource(R.raw.girl);
176
     Bitmap bitmap;
177 177
        
178
      try 
179
        {
180
        bitmap = BitmapFactory.decodeStream(is);
181
        } 
182
      finally 
183
        {
184
        try 
185
          {
186
          is.close();
187
          } 
188
        catch(IOException e) { }
189
        }  
178
     try
179
       {
180
       bitmap = BitmapFactory.decodeStream(is);
181
       }
182
     finally
183
       {
184
       try
185
         {
186
         is.close();
187
         }
188
       catch(IOException e) { }
189
       }
190 190
      
191
      bmpHeight = bitmap.getHeight();
192
      bmpWidth  = bitmap.getWidth();
193

  
194
      if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
195
      mTexture.setTexture(bitmap);
196

  
197
      mScreen.detachAll();
198
      mScreen.attach(mTexture,mEffects,new MeshFlat(30,30*bmpHeight/bmpWidth));
199

  
200
      DistortedEffects.enableEffect(EffectNames.DISTORT);
201
      DistortedEffects.enableEffect(EffectNames.SINK);
202
      DistortedEffects.enableEffect(EffectNames.SWIRL);
203

  
204
      try
205
        {
206
        Distorted.onCreate(mView.getContext());
207
        }
208
      catch(Exception ex)
209
        {
210
        android.util.Log.e("Renderer", ex.getMessage() );
211
        }
212
      }
191
     bmpHeight = bitmap.getHeight();
192
     bmpWidth  = bitmap.getWidth();
193

  
194
     if( mTexture==null ) mTexture = new DistortedTexture(bmpWidth,bmpHeight);
195
     mTexture.setTexture(bitmap);
196

  
197
     mScreen.detachAll();
198
     mScreen.attach(mTexture,mEffects,new MeshFlat(30,30*bmpHeight/bmpWidth));
199

  
200
     DistortedEffects.enableEffect(EffectNames.DISTORT);
201
     DistortedEffects.enableEffect(EffectNames.SINK);
202
     DistortedEffects.enableEffect(EffectNames.SWIRL);
203

  
204
     try
205
       {
206
       Distorted.onCreate(mView.getContext());
207
       }
208
     catch(Exception ex)
209
       {
210
       android.util.Log.e("Renderer", ex.getMessage() );
211
       }
212
     }
213 213
}

Also available in: Unified diff