From http://www.jwz.org/xscreensaver/xscreensaver-5.27.tar.gz
[xscreensaver] / hacks / glx / jigglypuff.c
index 2c1ed3309928cbfaa937490b790e04495187e38f..d23b82171b8b8f8fa3beb4bdf6e3f8743de2cef8 100644 (file)
@@ -286,10 +286,12 @@ static inline void vector_scale(vector v, coord s)
     v[2] *= s;
 }
 
+/*
 static inline coord dot(vector v1, vector v2)
 {
     return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
 }
+*/
 
 static inline void cross(vector v1, vector v2, vector v)
 {
@@ -434,11 +436,10 @@ static vertex *vertex_split(hedge *h, vector v)
     hedge *h2, *hn1, *hn2;
     vertex *vtxn;
     edge *en;
-    face *f1, *f2;
+    face *f1;
 
     f1 = h->f;
     h2 = partner(h);
-    f2 = h2->f;
     
     vtxn = vertex_new(f1->s, v);
     hn1 = hedge_new(h, vtxn);
@@ -785,7 +786,6 @@ static void setup_opengl(ModeInfo *mi, jigglystruct *js)
     const GLfloat scolor[4]= {0.9f, 0.9f, 0.9f, 0.5f};
 
     glDrawBuffer(GL_BACK);
-    glClearColor(0, 0, 0, 0);
     glShadeModel(GL_SMOOTH);
     glEnable(GL_DEPTH_TEST);
 
@@ -840,10 +840,12 @@ static int parse_color(jigglystruct *js)
        js->color_style = COLOR_STYLE_FLOWERBOX;
        return 1;
     }
+# ifndef HAVE_JWZGLES  /* SPHERE_MAP unimplemented */
     else if(!strcmp(color, "chrome")) {
        js->color_style = COLOR_STYLE_CHROME;
        return 1;
     }
+# endif
     else if(!strcmp(color, "cycle")) {
        js->color_style = COLOR_STYLE_CYCLE;
        js->jiggly_color[0] = ((float)random()) / REAL_RAND_MAX * 0.7 + 0.3;
@@ -872,8 +874,14 @@ static int parse_color(jigglystruct *js)
 
 static void randomize_parameters(jigglystruct *js) {
     do_tetrahedron = random() & 1;
+# ifndef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
     js->do_wireframe = !(random() & 3);
+# endif
     js->color_style = random() % 5;
+# ifdef HAVE_JWZGLES  /* #### SPHERE_MAP unimplemented */
+    while (js->color_style == COLOR_STYLE_CHROME)
+      js->color_style = random() % 5;;
+# endif
     if(js->color_style == COLOR_STYLE_NORMAL
        || js->color_style == COLOR_STYLE_CYCLE) {
        js->jiggly_color[0] = ((float)random()) / REAL_RAND_MAX * 0.5 + 0.5;
@@ -984,7 +992,11 @@ ENTRYPOINT void draw_jigglypuff(ModeInfo *mi)
            js->axis -= 2*M_PI;
        }
     }
+
+    /* Do it twice because we don't track the device's orientation. */
+    glRotatef( current_device_rotation(), 0, 0, 1);
     gltrackball_rotate(js->trackball);
+    glRotatef(-current_device_rotation(), 0, 0, 1);
 
     if(js->color_style == COLOR_STYLE_CYCLE) {
        int i;
@@ -1024,6 +1036,9 @@ ENTRYPOINT void init_jigglypuff(ModeInfo *mi)
     js = &jss[MI_SCREEN(mi)];
 
     js->do_wireframe = MI_IS_WIREFRAME(mi);
+# ifdef HAVE_JWZGLES
+    js->do_wireframe = 0; /* GL_LINE unimplemented */
+# endif
 
     js->shininess = shininess;