From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / morph3d.c
index 73f0be629789edaa5ca9fdb8d7a6aa4fb598979e..e96309acc5817fd2f1f3d2571e481a9f40dc9915 100644 (file)
@@ -55,7 +55,9 @@ static const char sccsid[] = "@(#)morph3d.c   5.01 2001/03/01 xlockmore";
 # define MODE_moebius
 # define DEFAULTS              "*delay:                40000   \n"             \
                                                "*showFPS:      False   \n"             \
-                                               "*count:                0               \n"
+                                               "*count:                0               \n"             \
+                                               "*suppressRotationAnimation: True\n" \
+
 # define refresh_morph3d 0
 # define morph3d_handle_event 0
 # include "xlockmore.h"                /* from the xscreensaver distribution */
@@ -175,6 +177,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL;
       NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ;                                    \
       glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ));                                             \
       glVertex3f(VertX, VertY, VertZ);                                                                           \
+      mi->polygon_count++;                                                                                       \
                                                                                                                  \
       Xf-=Ax; Yf-=Ay; Xa-=Ax; Yb-=Ay;                                                                            \
                                                                                                                  \
@@ -186,6 +189,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL;
       NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ;                                    \
       glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ));                                             \
       glVertex3f(VertX, VertY, VertZ);                                                                           \
+      mi->polygon_count++;                                                                                       \
                                                                                                                  \
       Xf-=Ax; Yf+=Ay; Xa-=Ax; Yb+=Ay;                                                                            \
     }                                                                                                            \
@@ -241,6 +245,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL;
       NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ;                                    \
       glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ));                                             \
       glVertex3f(VertX, VertY, VertZ);                                                                           \
+      mi->polygon_count++;                                                                                       \
     }                                                                                                            \
     glEnd();                                                                                                     \
   }                                                                                                              \
@@ -277,18 +282,20 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL;
         NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ;                                  \
         NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ;                                  \
         glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ));                                           \
-       glVertex3f(VertX, VertY, VertZ);                                                                         \
+               glVertex3f(VertX, VertY, VertZ);                                                                         \
+           mi->polygon_count++;                                                                                     \
                                                                                                                  \
         Xf-=x[Fi]; Yf-=y[Fi]; Xa-=x[Fi]; Yb-=y[Fi];                                                              \
                                                                                                                  \
-       Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2);                                                         \
-       Factor1=1-((sqr(Xa)+Yf2)*AmpVr2);                                                                        \
-       Factor2=1-((Xf2+sqr(Yb))*AmpVr2);                                                                        \
+               Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2);                                                         \
+               Factor1=1-((sqr(Xa)+Yf2)*AmpVr2);                                                                        \
+               Factor2=1-((Xf2+sqr(Yb))*AmpVr2);                                                                        \
         VertX=Factor*Xf;        VertY=Factor*Yf;        VertZ=Factor*Zf;                                         \
         NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ;                                  \
         NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ;                                  \
         glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ));                                           \
-       glVertex3f(VertX, VertY, VertZ);                                                                         \
+               glVertex3f(VertX, VertY, VertZ);                                                                         \
+           mi->polygon_count++;                                                                                     \
                                                                                                                  \
       }                                                                                                          \
       Xf=(float)Ri*x[Fi+1];                                                                                      \
@@ -305,7 +312,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL;
       glEnd();                                                                                                   \
     }                                                                                                            \
   }                                                                                                              \
-  VS=(Factor<0);                                                                                             \
+  VS=(Factor<0);                                                                                                    \
 }
 
 static void
@@ -601,7 +608,6 @@ pinit(ModeInfo * mi)
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
 
        glClearDepth(1.0);
-       glClearColor(0.0, 0.0, 0.0, 1.0);
        glColor3f(1.0, 1.0, 1.0);
 
        glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
@@ -750,6 +756,7 @@ draw_morph3d(ModeInfo * mi)
        if (!mp->glx_context)
                return;
 
+    mi->polygon_count = 0;
        glXMakeCurrent(display, window, *(mp->glx_context));
 
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -765,6 +772,15 @@ draw_morph3d(ModeInfo * mi)
                glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic);
        }
 
+# ifdef HAVE_MOBILE    /* Keep it the same relative size when rotated. */
+    {
+      GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
+      int o = (int) current_device_rotation();
+      if (o != 0 && o != 180 && o != -180)
+        glScalef (1/h, h, 1);
+    }
+# endif
+
        glRotatef(mp->step * 100, 1, 0, 0);
        glRotatef(mp->step * 95, 0, 1, 0);
        glRotatef(mp->step * 90, 0, 0, 1);