commit 77a500b36af1b87a59e058635bc3e9598756e0a7
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Nov 30 14:28:49 2018 +0000

    Progress with Inflate (building block of postprocessing effects: the proper way of marking a halo around a Mesh)
    'Inflate' app testing the machanism. MeshFlat appears to be working, now we only need to fill up the per-vertex Inflate vector in the MeshCubes.

diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 872f56b..802874d 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -50,5 +50,7 @@
         <activity android:name=".stencil.StencilActivity"/>
         <activity android:name=".glow.GlowActivity"/>
         <activity android:name=".movingglow.MovingGlowActivity"/>
+        <activity android:name=".inflate.InflateActivity"/>
+        <activity android:name=".inflate.InflateActivity2"/>
     </application>
 </manifest>
diff --git a/src/main/java/org/distorted/examples/TableOfContents.java b/src/main/java/org/distorted/examples/TableOfContents.java
index 13934c9..40e0a32 100644
--- a/src/main/java/org/distorted/examples/TableOfContents.java
+++ b/src/main/java/org/distorted/examples/TableOfContents.java
@@ -68,6 +68,7 @@ import org.distorted.examples.postprocesstree.PostprocessTreeActivity;
 import org.distorted.examples.stencil.StencilActivity;
 import org.distorted.examples.glow.GlowActivity;
 import org.distorted.examples.movingglow.MovingGlowActivity;
+import org.distorted.examples.inflate.InflateActivity;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -396,6 +397,15 @@ public class TableOfContents extends ListActivity
       activityMapping.put(i++, MovingGlowActivity.class);
    }
 
+   {
+   final Map<String, Object> item = new HashMap<>();
+   item.put(ITEM_IMAGE, R.drawable.icon_example_wip);
+   item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_inflate));
+   item.put(ITEM_SUBTITLE, getText(R.string.example_inflate_subtitle));
+   data.add(item);
+   activityMapping.put(i++, InflateActivity.class);
+   }
+
    final SimpleAdapter dataAdapter = new SimpleAdapter(this, data, R.layout.toc_item, new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, new int[] {R.id.Image, R.id.Title, R.id.SubTitle});
    setListAdapter(dataAdapter);  
       
diff --git a/src/main/java/org/distorted/examples/inflate/InflateActivity.java b/src/main/java/org/distorted/examples/inflate/InflateActivity.java
new file mode 100644
index 0000000..e0a5dd1
--- /dev/null
+++ b/src/main/java/org/distorted/examples/inflate/InflateActivity.java
@@ -0,0 +1,288 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.inflate;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.NumberPicker;
+import android.widget.Spinner;
+import android.widget.TableRow;
+
+import org.distorted.examples.R;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class InflateActivity extends Activity
+                               implements View.OnClickListener, AdapterView.OnItemSelectedListener
+  {
+  private static final int COLOR_OFF = 0xffffe81f;
+  private static final int COLOR_ON  = 0xff0000ff;
+  private static final int COLOR_INAC= 0xff00ff00;
+
+  private int mNumCols = 1;
+  private int mNumRows = 1;
+  private int mNumSlic = 1;
+  private boolean mGridInitialized;
+  private NumberPicker mColsPicker, mRowsPicker, mSlicPicker;
+  private boolean[] mShape;
+  private int mObjectType;
+  private int mBitmapID;
+  private LinearLayout mLay;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @Override
+  protected void onCreate(Bundle savedState)
+    {
+    super.onCreate(savedState);
+
+    setContentView(R.layout.objectpickerlayout);
+
+    mLay = findViewById(R.id.objectpicker_buttongrid);
+
+    mColsPicker = findViewById(R.id.objectpicker_cols);
+    mRowsPicker = findViewById(R.id.objectpicker_rows);
+    mSlicPicker = findViewById(R.id.objectpicker_slices);
+
+    mColsPicker.setMaxValue(40);
+    mColsPicker.setMinValue( 0);
+    mRowsPicker.setMaxValue(40);
+    mRowsPicker.setMinValue( 0);
+    mSlicPicker.setMaxValue(40);
+    mSlicPicker.setMinValue( 0);
+
+    mColsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
+         {
+         @Override
+         public void onValueChange(NumberPicker picker, int oldVal, int newVal)
+           {
+           setGrid();
+           }
+         });
+
+    mRowsPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
+         {
+         @Override
+         public void onValueChange(NumberPicker picker, int oldVal, int newVal)
+           {
+           setGrid();
+           }
+         });
+
+    mSlicPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
+         {
+         @Override
+         public void onValueChange(NumberPicker picker, int oldVal, int newVal)
+           {
+           mNumSlic = mSlicPicker.getValue();
+           }
+         });
+
+    mObjectType = 0;
+    mGridInitialized = false;
+
+    Spinner typeSpinner  = findViewById(R.id.objectpicker_spinnerType);
+    typeSpinner.setOnItemSelectedListener(this);
+
+    String[] objectType = new String[] {"Mesh: Cubes", "Mesh: Flat"};
+
+    ArrayAdapter<String> adapterType = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectType);
+    adapterType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+    typeSpinner.setAdapter(adapterType);
+
+    Spinner bitmapSpinner  = findViewById(R.id.objectpicker_spinnerBitmap);
+    bitmapSpinner.setOnItemSelectedListener(this);
+
+    String[] objectBitmap = new String[] { "Texture: Grid", "Texture: Girl", "Texture: Dog", "Texture: Cat",
+                                           "Texture: Squares", "Texture: Bean", "Texture: Lisa" };
+
+    ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectBitmap);
+    adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+    bitmapSpinner.setAdapter(adapterBitmap);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setGrid()
+    {
+    mGridInitialized = true;
+
+    mNumCols = mColsPicker.getValue();
+    mNumRows = mRowsPicker.getValue();
+
+    int width = mLay.getWidth();
+    int height= mLay.getHeight();
+    int w = mNumCols>0 ? (int)( 0.9f*width / mNumCols) : 0;
+    int h = mNumRows>0 ? (int)( 0.9f*height/ mNumRows) : 0;
+    int size= w<h ? w:h;
+    int pad = size<20 ? 1 : size/20;
+
+    mLay.removeAllViews();
+
+    mShape = new boolean[mNumRows*mNumCols];
+
+    TableRow.LayoutParams p = new TableRow.LayoutParams();
+
+    p.rightMargin  = pad;
+    p.leftMargin   = pad;
+    p.topMargin    = pad;
+    p.bottomMargin = pad;
+    p.height       = size;
+    p.width        = size;
+
+    for (int rows=0; rows<mNumRows; rows++)
+      {
+      TableRow tr = new TableRow(this);
+      tr.setGravity(Gravity.CENTER);
+
+      for(int cols=0; cols<mNumCols; cols++)
+        {
+        Button b = new Button(this);
+        b.setOnClickListener(this);
+        b.setId(rows*mNumCols+cols);
+        b.setLayoutParams(p);
+        b.setBackgroundColor(mObjectType==1 ? COLOR_INAC : COLOR_ON);
+        tr.addView(b, p);
+        mShape[rows*mNumCols+cols] = true;
+        }
+
+      mLay.addView(tr);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onClick(View view)
+    {
+    if( mObjectType!=1 )
+      {
+      Button tmp = (Button)view;
+      int id = tmp.getId();
+      mShape[id] = !mShape[id];
+      tmp.setBackgroundColor(mShape[id] ? COLOR_ON:COLOR_OFF);
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void uncheckAll()
+    {
+    TableRow tr;
+    Button butt;
+
+    for (int row=0; row<mNumRows; row++)
+      {
+      tr = (TableRow)mLay.getChildAt(row);
+
+      for(int col=0; col<mNumCols; col++)
+        {
+        butt = (Button)tr.getVirtualChildAt(col);
+        butt.setBackgroundColor(mObjectType==1 ? COLOR_INAC : COLOR_ON);
+        mShape[row*mNumCols+col] = true;
+        }
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void Create(View v)
+    {
+    Intent mainInt = new Intent( getApplicationContext(), InflateActivity2.class);
+    Bundle b = new Bundle();
+
+    b.putInt("type", mObjectType);
+    b.putInt("cols", mNumCols);
+    b.putInt("rows", mNumRows);
+    b.putInt("slices", mNumSlic);
+    b.putInt("bitmap", mBitmapID);
+
+    if( mObjectType==1 )
+      {
+      b.putString("string", "");
+      }
+    else
+      {
+      String str = "";
+
+      for(int i=0; i<mNumRows*mNumCols; i++)
+        str += mShape[i] ? "1" : "0";
+
+      b.putString("string", str);
+      }
+
+    mainInt.putExtras(b);
+    startActivity(mainInt);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
+    {
+    switch(parent.getId())
+      {
+      case R.id.objectpicker_spinnerType  : if( mObjectType!=pos )
+                                              {
+                                              mObjectType = pos;
+                                              uncheckAll();
+                                              }
+                                            break;
+      case R.id.objectpicker_spinnerBitmap: switch(pos)
+                                              {
+                                              case 0: mBitmapID = -1        ; break;
+                                              case 1: mBitmapID = R.raw.face; break;
+                                              case 2: mBitmapID = R.raw.dog ; break;
+                                              case 3: mBitmapID = R.raw.cat ; break;
+                                              case 4: mBitmapID = R.raw.grid; break;
+                                              case 5: mBitmapID = R.raw.bean; break;
+                                              case 6: mBitmapID = R.raw.monalisa; break;
+                                              }
+                                            break;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onNothingSelected(AdapterView<?> parent)
+    {
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Overrides
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @Override
+  public void onWindowFocusChanged(boolean hasFocus)
+    {
+    super.onWindowFocusChanged(hasFocus);
+
+    mColsPicker.setValue(mNumCols);
+    mRowsPicker.setValue(mNumRows);
+    mSlicPicker.setValue(mNumSlic);
+
+    if( !mGridInitialized ) setGrid();
+    }
+  }
diff --git a/src/main/java/org/distorted/examples/inflate/InflateActivity2.java b/src/main/java/org/distorted/examples/inflate/InflateActivity2.java
new file mode 100644
index 0000000..2b7dc80
--- /dev/null
+++ b/src/main/java/org/distorted/examples/inflate/InflateActivity2.java
@@ -0,0 +1,202 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.inflate;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+import org.distorted.examples.R;
+import org.distorted.library.main.Distorted;
+import org.distorted.library.main.DistortedTexture;
+import org.distorted.library.mesh.MeshBase;
+import org.distorted.library.mesh.MeshCubes;
+import org.distorted.library.mesh.MeshFlat;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class InflateActivity2 extends Activity implements SeekBar.OnSeekBarChangeListener
+{
+    private DistortedTexture mTexture;
+    private MeshBase mMesh;
+    private TextView mTextLevel;
+    private int mBitmapID;
+    private Bitmap mBitmap;
+    private int mNumCols;
+    private int mNumRows;
+    private int mNumSlic;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onPause() 
+      {
+      GLSurfaceView mView = this.findViewById(R.id.inflateSurfaceView);
+      if( mView!=null ) mView.onPause();
+
+      Distorted.onPause();
+      super.onPause();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onResume() 
+      {
+      super.onResume();
+      
+      GLSurfaceView mView = this.findViewById(R.id.inflateSurfaceView);
+      if( mView!=null ) mView.onResume();  
+      }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onDestroy() 
+      {
+      Distorted.onDestroy();  
+      super.onDestroy();
+      }
+ 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    @Override
+    protected void onCreate(Bundle savedState)
+      {
+      super.onCreate(savedState);
+
+      Bundle b = getIntent().getExtras();
+
+      String str     = b.getString("string");
+      int objectType = b.getInt("type");
+      mNumCols       = b.getInt("cols");
+      mNumRows       = b.getInt("rows");
+      mNumSlic       = b.getInt("slices");
+      mBitmapID      = b.getInt("bitmap");
+
+      if( objectType==1 ) mMesh = new MeshFlat(mNumCols,mNumRows);
+      else                mMesh = new MeshCubes(mNumCols, str, mNumSlic);
+
+      mTexture= new DistortedTexture(mNumCols,mNumRows);
+
+      setContentView(R.layout.inflatelayout);
+
+      mTextLevel = (TextView)findViewById(R.id.inflateText);
+      SeekBar levelBar = findViewById(R.id.inflateLevel);
+      levelBar.setOnSeekBarChangeListener(this);
+
+      InflateSurfaceView view = this.findViewById(R.id.inflateSurfaceView);
+      float level = view.getRenderer().setLevel(50);
+      mTextLevel.setText(getString(R.string.inflate_placeholder, level));
+      levelBar.setProgress(50);
+      }
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public Bitmap getBitmap()
+      {
+      if( mBitmap==null )
+        {
+        if( mBitmapID!=-1)
+          {
+          InputStream is = getResources().openRawResource(mBitmapID);
+
+          try
+            {
+            mBitmap = BitmapFactory.decodeStream(is);
+            }
+          finally
+            {
+            try
+              {
+              is.close();
+              }
+            catch(IOException e) { }
+            }
+          }
+        else
+          {
+          final int W = 64*mNumCols;
+          final int H = 64*mNumRows;
+
+          Paint paint = new Paint();
+          mBitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
+          Canvas canvas = new Canvas(mBitmap);
+
+          paint.setAntiAlias(true);
+          paint.setTextAlign(Paint.Align.CENTER);
+          paint.setColor(0xff008800);
+          paint.setStyle(Paint.Style.FILL);
+          canvas.drawRect(0, 0, W, H, paint);
+          paint.setColor(0xffffffff);
+
+          for(int i=0; i<=mNumCols ; i++ ) canvas.drawRect(W*i/mNumCols-1, 0, W*i/mNumCols + 1, H, paint);
+          for(int i=0; i<=mNumRows ; i++ ) canvas.drawRect( 0, H*i/mNumRows-1, W,  H*i/mNumRows+1, paint);
+          }
+        }
+
+      return mBitmap;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
+      {
+      switch (bar.getId())
+        {
+        case R.id.inflateLevel: InflateSurfaceView view = this.findViewById(R.id.inflateSurfaceView);
+                                float level = view.getRenderer().setLevel(progress);
+                                mTextLevel.setText(getString(R.string.inflate_placeholder, level));
+                                break;
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onStartTrackingTouch(SeekBar bar) { }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onStopTrackingTouch(SeekBar bar)  { }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public DistortedTexture getTexture()
+      {
+      return mTexture;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public MeshBase getMesh()
+      {
+      return mMesh;
+      }
+}
diff --git a/src/main/java/org/distorted/examples/inflate/InflateRenderer.java b/src/main/java/org/distorted/examples/inflate/InflateRenderer.java
new file mode 100644
index 0000000..ac42e2d
--- /dev/null
+++ b/src/main/java/org/distorted/examples/inflate/InflateRenderer.java
@@ -0,0 +1,141 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.inflate;
+
+import android.opengl.GLSurfaceView;
+
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectQuaternion;
+import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.main.Distorted;
+import org.distorted.library.main.DistortedEffects;
+import org.distorted.library.main.DistortedScreen;
+import org.distorted.library.main.DistortedTexture;
+import org.distorted.library.mesh.MeshBase;
+import org.distorted.library.type.DynamicQuat;
+import org.distorted.library.type.Static3D;
+import org.distorted.library.type.Static4D;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class InflateRenderer implements GLSurfaceView.Renderer
+{
+    private GLSurfaceView mView;
+    private DistortedTexture mTexture;
+    private DistortedEffects mEffects;
+    private MeshBase mMesh;
+    private DistortedScreen mScreen;
+    private int mObjWidth, mObjHeight, mObjDepth;
+    private Static3D mMove, mScale, mCenter;
+
+    Static4D mQuat1, mQuat2;
+    int mScreenMin;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    InflateRenderer(GLSurfaceView v)
+      {
+      mView = v;
+
+      mMove = new Static3D(0,0,0);
+      mScale= new Static3D(1,1,1);
+      mCenter=new Static3D(0,0,0);
+
+      InflateActivity2 act = (InflateActivity2)v.getContext();
+
+      mTexture = act.getTexture();
+      mMesh    = act.getMesh();
+
+      mObjWidth = mTexture.getWidth();
+      mObjHeight= mTexture.getHeight();
+      mObjDepth = mTexture.getDepth(mMesh);
+
+      mQuat1 = new Static4D(0,0,0,1);  // unity
+      mQuat2 = new Static4D(0,0,0,1);  // quaternions
+      
+      DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
+      DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
+
+      quatInt1.add(mQuat1);
+      quatInt2.add(mQuat2);
+
+      mEffects = new DistortedEffects();
+      mEffects.apply( new MatrixEffectMove(mMove) );
+      mEffects.apply( new MatrixEffectScale(mScale));
+      mEffects.apply( new MatrixEffectQuaternion(quatInt1, mCenter) );
+      mEffects.apply( new MatrixEffectQuaternion(quatInt2, mCenter) );
+
+      mScreen = new DistortedScreen();
+      mScreen.glClearColor(1.0f,1.0f,1.0f,0.0f);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+   
+    public void onDrawFrame(GL10 glUnused) 
+      {
+      mScreen.render( System.currentTimeMillis() );
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
+      {
+      mScreenMin = width<height ? width:height;
+      float factor = ( width*mObjHeight > height*mObjWidth ) ? (0.75f*height)/mObjHeight :  (0.75f*width)/mObjWidth;
+      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
+      mScale.set(factor,factor,factor);
+      mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, -(float)mObjDepth/2 );
+      mScreen.resize(width, height);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    float setLevel(int level)
+      {
+      float inflateLevel = (level-50)/50.0f;
+      mMesh.setInflate(inflateLevel);
+
+      return inflateLevel;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
+      {
+      InflateActivity2 act = (InflateActivity2)mView.getContext();
+
+      mTexture.setTexture( act.getBitmap() );
+
+      mScreen.detachAll();
+      mScreen.attach(mTexture,mEffects,mMesh);
+
+      try
+        {
+        Distorted.onCreate(mView.getContext());
+        }
+      catch(Exception ex)
+        {
+        android.util.Log.e("Inflate", ex.getMessage() );
+        }
+      }
+}
diff --git a/src/main/java/org/distorted/examples/inflate/InflateSurfaceView.java b/src/main/java/org/distorted/examples/inflate/InflateSurfaceView.java
new file mode 100644
index 0000000..4501911
--- /dev/null
+++ b/src/main/java/org/distorted/examples/inflate/InflateSurfaceView.java
@@ -0,0 +1,139 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.inflate;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.ConfigurationInfo;
+import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.Toast;
+
+import org.distorted.examples.R;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class InflateSurfaceView extends GLSurfaceView
+{
+    private int mX, mY;
+    private InflateRenderer mRenderer;
+	
+///////////////////////////////////////////////////////////////////////////////////////////////////
+   
+    public InflateSurfaceView(Context context, AttributeSet attrs)
+      {
+      super(context,attrs);
+    
+      mX = -1;
+      mY = -1;
+      
+      if(!isInEditMode())
+        {
+        mRenderer = new InflateRenderer(this);
+        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
+        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
+        setRenderer(mRenderer);
+        Toast.makeText(context, R.string.example_rotate_toast , Toast.LENGTH_SHORT).show();
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public InflateRenderer getRenderer()
+      {
+      return mRenderer;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override public boolean onTouchEvent(MotionEvent event) 
+      {
+      int action = event.getAction();
+      int x = (int)event.getX();
+      int y = (int)event.getY();
+           
+      switch(action)
+         {
+         case MotionEvent.ACTION_DOWN: mX = x;
+                                       mY = y;
+                                       break;
+                                       
+         case MotionEvent.ACTION_MOVE: if( mX>=0 && mY>= 0 )
+                                         {
+                                         float px = mY-y;
+                                         float py = mX-x;
+                                         float pz = 0;
+                                         float plen = (float)Math.sqrt(px*px + py*py + pz*pz);
+                                         
+                                         if( plen>0 )
+                                           {
+                                           px /= plen;
+                                           py /= plen;
+                                           pz /= plen;
+
+                                           float cosA = (float)Math.cos(plen*3.14f/mRenderer.mScreenMin);
+                                           float sinA = (float)Math.sqrt(1-cosA*cosA);
+                                         
+                                           mRenderer.mQuat1.set(px*sinA, py*sinA, pz*sinA, cosA);
+                                           }
+                                         }                             
+                                       break;
+                                       
+         case MotionEvent.ACTION_UP  : mX = -1;
+                                       mY = -1;
+        	                           
+                                       float qx = mRenderer.mQuat1.get1();
+                                       float qy = mRenderer.mQuat1.get2();
+                                       float qz = mRenderer.mQuat1.get3();
+                                       float qw = mRenderer.mQuat1.get4();
+
+                                       float rx = mRenderer.mQuat2.get1();
+                                       float ry = mRenderer.mQuat2.get2();
+                                       float rz = mRenderer.mQuat2.get3();
+                                       float rw = mRenderer.mQuat2.get4();
+
+                                       // This is quaternion multiplication. (tx,ty,tz,tw)
+                                       // is now equal to (qx,qy,qz,qw)*(rx,ry,rz,rw)
+                                       float tx = rw*qx - rz*qy + ry*qz + rx*qw;
+                                       float ty = rw*qy + rz*qx + ry*qw - rx*qz;
+                                       float tz = rw*qz + rz*qw - ry*qx + rx*qy;
+                                       float tw = rw*qw - rz*qz - ry*qy - rx*qx;
+
+                                       // The point of this is so that there are always
+                                       // exactly 2 quaternions: Quat1 representing the rotation
+                                       // accumulating only since the last screen touch, and Quat2
+                                       // which remembers the combined effect of all previous
+                                       // swipes.
+                                       // We cannot be accumulating an ever-growing list of quaternions
+                                       // and add a new one every time user swipes the screen - there
+                                       // is a limited number of slots in the EffectQueueMatrix!
+                                       mRenderer.mQuat1.set(0f, 0f, 0f, 1f);
+                                       mRenderer.mQuat2.set(tx, ty, tz, tw);
+                                       
+                                       break;
+         }
+             
+      return true;
+      }
+         
+}
+
diff --git a/src/main/res/layout/inflatelayout.xml b/src/main/res/layout/inflatelayout.xml
new file mode 100644
index 0000000..9fbdfeb
--- /dev/null
+++ b/src/main/res/layout/inflatelayout.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:gravity="center_horizontal"
+    android:orientation="vertical" >
+
+    <org.distorted.examples.inflate.InflateSurfaceView
+        android:id="@+id/inflateSurfaceView"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1.00" />
+
+    <LinearLayout
+        android:id="@+id/linearLayout"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center|fill_horizontal"
+        android:orientation="horizontal"
+        android:background="@color/blue">
+
+        <TextView
+            android:id="@+id/inflateText"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="0.3"
+            android:paddingLeft="10dp"
+            android:text="@string/inflate" />
+
+        <SeekBar
+            android:id="@+id/inflateLevel"
+            android:layout_weight="0.7"
+            android:layout_width="0dp"
+            android:layout_height="50dp"
+            android:paddingLeft="10dp"
+            android:paddingRight="10dp" />
+
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 1d6c850..0d7bc9a 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -75,6 +75,7 @@
     <string name="screen">Screen</string>
     <string name="framebuffer">Framebuffer</string>
     <string name="matrixautomatic">Automatic Matrix Effects</string>
+    <string name="inflate">Inflate</string>
 
     <string name="quality0">Highest</string>
     <string name="quality1">High</string>
@@ -104,6 +105,7 @@
     <string name="blur_placeholder">Blur: %1$d</string>
     <string name="glow_radius_placeholder">Radius: %1$d</string>
     <string name="glow_alpha_placeholder">Alpha: %1$.2f</string>
+    <string name="inflate_placeholder">Inflate: %1$.2f</string>
 
     <string name="example_monalisa">Mona Lisa</string>
     <string name="example_monalisa_subtitle">The basics of Distortions.</string>
@@ -173,8 +175,8 @@
     <string name="example_glow_subtitle">Leaf glowing with light.</string>
     <string name="example_moving_glow">Glow Effect</string>
     <string name="example_moving_glow_subtitle">See moving objects glowing with light.</string>
-    <string name="example_mali">Debug Mali GPU</string>
-    <string name="example_mali_subtitle">Self-contained app to try and debug issues on Mali GPU</string>
+    <string name="example_inflate">Debug Inflating the Mesh</string>
+    <string name="example_inflate_subtitle">Just a test appliacation for the developers of the library to test the Inflate mechanism.</string>
 
     <string name="example_movingeffects_toast">Click on \'RESET\' and define your path by touching the screen. Then click on one of the effects and see it move along your path.</string>
     <string name="example_rotate_toast">Rotate the scene by swiping the screen</string>
