From http://www.jwz.org/xscreensaver/xscreensaver-5.15.tar.gz
[xscreensaver] / hacks / glx / juggler3d.c
index 5697ed263af32c44e98aed77dde5e2e6320627c5..6349d9df2cc5bf0fbcdb6514326120bc91b2f86a 100644 (file)
@@ -1696,6 +1696,8 @@ show_arms(ModeInfo * mi)
   int soffx = 10;
   int soffy = 11;
 
+  glFrontFace(GL_CCW);
+
   j = 1;
   for(side = LEFT; side <= RIGHT; side = (Hand)((int)side + 1)) {
        /* Translate into device coords */
@@ -1799,6 +1801,8 @@ show_figure(ModeInfo * mi, Bool init)
 
   glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, gcolor);
 
+  glFrontFace(GL_CCW);
+
   {
     GLfloat scale = ((GLfloat) a[10].x - a[9].x) / 2;
     int slices = 12;
@@ -2065,6 +2069,8 @@ show_ball(ModeInfo *mi, unsigned long color, Trace *s)
   gcolor2[1] = gcolor1[1] / 3;
   gcolor2[2] = gcolor1[2] / 3;
 
+  glFrontFace(GL_CCW);
+
   {
     GLfloat scale = BALLRADIUS;
     glPushMatrix();
@@ -2120,6 +2126,8 @@ show_europeanclub(ModeInfo *mi, unsigned long color, Trace *s)
   gcolor1[1] = mi->colors[color].green / 65536.0;
   gcolor1[2] = mi->colors[color].blue  / 65536.0;
 
+  glFrontFace(GL_CCW);
+
   {
     GLfloat scale = radius;
     glPushMatrix();
@@ -2241,6 +2249,8 @@ show_knife(ModeInfo *mi, unsigned long color, Trace *s)
   gcolor1[1] = mi->colors[color].green / 65536.0;
   gcolor1[2] = mi->colors[color].blue  / 65536.0;
 
+  glFrontFace(GL_CCW);
+
   glPushMatrix();
   glTranslatef(x, y, 0);
   glScalef (2, 2, 2);
@@ -2299,6 +2309,8 @@ show_ring(ModeInfo *mi, unsigned long color, Trace *s)
   gcolor2[1] = gcolor1[1] / 3;
   gcolor2[2] = gcolor1[2] / 3;
 
+  glFrontFace(GL_CCW);
+
   glPushMatrix();
   glTranslatef(0, 0, 12);  /* back of ring in hand */
 
@@ -2318,11 +2330,12 @@ show_ring(ModeInfo *mi, unsigned long color, Trace *s)
       glNormal3f (0, 0, j*1);
       glBegin (wire_p ? GL_LINES : GL_QUAD_STRIP);
       for (i = 0; i < slices + (wire_p ? 0 : 1); i++) {
+        GLfloat th, cth, sth;
         glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
                       (i % (slices/3) ? gcolor1 : gcolor2));
-        GLfloat th = i * width;
-        GLfloat cth = cos(th);
-        GLfloat sth = sin(th);
+        th = i * width;
+        cth = cos(th);
+        sth = sin(th);
         glVertex3f (cth * ra, sth * ra, z);
         glVertex3f (cth * rb, sth * rb, z);
         polys++;
@@ -2387,6 +2400,8 @@ show_bball(ModeInfo *mi, unsigned long color, Trace *s)
   gcolor1[1] = mi->colors[color].green / 65536.0;
   gcolor1[2] = mi->colors[color].blue  / 65536.0;
 
+  glFrontFace(GL_CCW);
+
   {
     GLfloat scale = radius;
     glPushMatrix();
@@ -2653,6 +2668,7 @@ init_juggle (ModeInfo * mi)
   load_font (mi->dpy, "titleFont",  &sp->mode_font, &sp->font_dlist);
 
   reshape_juggle (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
+  clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */
 
   if (!wire)
     {