From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / glsnake.c
index 094b12a0c4fd0459d1417c26529d7986c98b54b5..1d8ef965a10a73c398d5125e300d8ebd0d5cec13 100644 (file)
 #ifdef HAVE_GLUT
 # include <GL/glut.h>
 #else
-# ifdef HAVE_COCOA
+# ifdef HAVE_JWXYZ
 #  define HAVE_GETTIMEOFDAY
 # else
 #  include <GL/gl.h>
 #  include <GL/glu.h>
 # endif
 #endif
+# ifdef HAVE_ANDROID
+# include <GLES/gl.h>
+#endif
 
 #ifdef HAVE_JWZGLES
 # include "jwzgles.h"
@@ -149,6 +152,7 @@ static GLfloat angvel;
 #define DEFAULTS "*delay:          30000                      \n" \
                  "*count:          30                         \n" \
                  "*showFPS:        False                      \n" \
+               "*suppressRotationAnimation: True\n" \
          "*labelfont:   -*-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*\n" \
 
 
@@ -1457,13 +1461,7 @@ ModeInfo * mi
     struct glsnake_cfg * bp;
 
     /* set up the conf struct and glx contexts */
-    if (!glc) {
-       glc = (struct glsnake_cfg *) calloc(MI_NUM_SCREENS(mi), sizeof(struct glsnake_cfg));
-       if (!glc) {
-           fprintf(stderr, "%s: out of memory\n", progname);
-           exit(1);
-       }
-    }
+    MI_INIT(mi, glc, NULL);
     bp = &glc[MI_SCREEN(mi)];
 
     if ((bp->glx_context = init_GL(mi)) != NULL) {
@@ -2263,6 +2261,15 @@ ENTRYPOINT void glsnake_display(
     glRotatef(yspin, 0.0, 1.0, 0.0); 
     glRotatef(zspin, 0.0, 0.0, 1.0); 
 
+# 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, 1/h, 1/h);
+    }
+# endif
+
     /* now draw each node along the snake -- this is quite ugly :p */
     mi->polygon_count = 0;
     for (i = 0; i < NODE_COUNT; i++) {