commit 8ac4c0bc7b3e03917df46b23cb239a7f77ec058d
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sun Jun 14 11:30:30 2020 +0100

    Progress with the MeshFile app.

diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
index 93b451a..b0fecde 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
@@ -26,6 +26,7 @@ import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.opengl.GLSurfaceView;
 
+import org.distorted.examples.R;
 import org.distorted.library.effect.MatrixEffectQuaternion;
 import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.main.DistortedEffects;
@@ -108,7 +109,6 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
     public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
       {
       if( mTexture==null ) mTexture = new DistortedTexture();
-      mTexture.setTexture( createTexture(0) );
 
       try
         {
@@ -124,6 +124,8 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
 
     void open(int resourceID)
       {
+      mTexture.setTexture( createTexture(resourceID) );
+
       long t1 = System.currentTimeMillis();
       mMesh = createMesh(resourceID);
       long t2 = System.currentTimeMillis();
@@ -138,8 +140,94 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
 
     private Bitmap createTexture(int resourceID)
       {
-      final int[] FACE_COLORS = new int[] { 0xffffff00, 0xff00ff00, 0xff0000ff, 0xffff0000 };
-      final int FACES=FACE_COLORS.length;
+      switch(resourceID)
+          {
+          case  R.raw.deferredjob:
+          case  R.raw.meshjoin   : final int[] TET_COLORS4 = new int[] { 0xffffff00,
+                                                                         0xff00ff00,
+                                                                         0xff0000ff,
+                                                                         0xffff0000 };
+                                   return createTetrahedrenTexture(TET_COLORS4);
+          case  R.raw.predeform  : return createGridTexture(3);
+          case  R.raw.cube2      :
+          case  R.raw.cube3      :
+          case  R.raw.cube4      :
+          case  R.raw.cube5      : final int[] CUBE_COLORS = new int[] { 0xffffff00,
+                                                                         0xffffffff,
+                                                                         0xff0000ff,
+                                                                         0xff00ff00,
+                                                                         0xffff0000,
+                                                                         0xffb5651d };
+                                   return createCubeTexture(CUBE_COLORS);
+          case  R.raw.pyra3      :
+          case  R.raw.pyra4      :
+          case  R.raw.pyra5      : final int[] TET_COLORS5 = new int[] { 0xffffff00,
+                                                                         0xff00ff00,
+                                                                         0xff0000ff,
+                                                                         0xffff0000,
+                                                                         0xff000000 };
+                                   return createTetrahedrenTexture(TET_COLORS5);
+          }
+
+      return null;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private Bitmap createCubeTexture(int[] faceColors)
+      {
+      final int FACES=faceColors.length;
+      int SIZE = 200;
+      final float R = SIZE*0.10f;
+      final float M = SIZE*0.05f;
+
+      Bitmap bitmap;
+      Paint paint = new Paint();
+      bitmap = Bitmap.createBitmap( (FACES+1)*SIZE, SIZE, Bitmap.Config.ARGB_8888);
+      Canvas canvas = new Canvas(bitmap);
+
+      paint.setStyle(Paint.Style.FILL);
+      paint.setColor(0xff000000);
+      canvas.drawRect(0, 0, (FACES+1)*SIZE, SIZE, paint);
+
+      for(int face=0; face<FACES; face++)
+        {
+        paint.setColor(faceColors[face]);
+        canvas.drawRoundRect( face*SIZE+M, M, (face+1)*SIZE-M, SIZE-M, R, R, paint);
+        }
+
+      return bitmap;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private Bitmap createGridTexture(int lines)
+      {
+      int SIZE = 200;
+      Bitmap bitmap = Bitmap.createBitmap(SIZE,SIZE, Bitmap.Config.ARGB_8888);
+      Canvas canvas = new Canvas(bitmap);
+
+      Paint paint = new Paint();
+      paint.setColor(0xff008800);
+      paint.setStyle(Paint.Style.FILL);
+      canvas.drawRect(0, 0, SIZE, SIZE, paint);
+      paint.setColor(0xffffffff);
+
+      for(int i=0; i<=lines ; i++ )
+        {
+        int x = (SIZE*i)/lines;
+        canvas.drawRect(x-1,   0,  x+1, SIZE, paint);
+        canvas.drawRect(  0, x-1, SIZE,  x+1, paint);
+        }
+
+      return bitmap;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private Bitmap createTetrahedrenTexture(int[] faceColors)
+      {
+      final int FACES=faceColors.length;
       int SIZE = 200;
       float STROKE = 0.05f*SIZE;
       float OFF = STROKE/2 -1;
@@ -160,7 +248,7 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
 
       for(int i=0; i<FACES; i++)
         {
-        paint.setColor(FACE_COLORS[i]);
+        paint.setColor(faceColors[i]);
         paint.setStyle(Paint.Style.FILL);
 
         canvas.drawRect(i*SIZE,0,(i+1)*SIZE,SIZE,paint);
