From http://www.jwz.org/xscreensaver/xscreensaver-5.18.tar.gz
[xscreensaver] / hacks / glx / juggler3d.c
index 5697ed263af32c44e98aed77dde5e2e6320627c5..1a7fe36b0a1a47ca939d3b3208a54a2adce03cf4 100644 (file)
@@ -580,8 +580,12 @@ typedef struct {
   Object       *objects;
   struct patternindex patternindex;
 
+# ifdef HAVE_GLBITMAP
   XFontStruct *mode_font;
   GLuint font_dlist;
+# else
+  texture_font_data *font_data;
+# endif
 } jugglestruct;
 
 static jugglestruct *juggles = (jugglestruct *) NULL;
@@ -658,10 +662,12 @@ free_juggle(jugglestruct *sp) {
        free(sp->pattern);
        sp->pattern = NULL;
   }
+# ifdef HAVE_GLBITMAP
   if (sp->mode_font!=None) {
        XFreeFontInfo(NULL,sp->mode_font,1);
        sp->mode_font = None;
   }
+# endif /* HAVE_GLBITMAP */
 }
 
 static Bool
@@ -1696,6 +1702,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 +1807,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 +2075,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 +2132,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 +2255,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 +2315,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 +2336,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 +2406,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();
@@ -2650,9 +2671,14 @@ init_juggle (ModeInfo * mi)
 
   sp->glx_context = init_GL(mi);
 
+# ifdef HAVE_GLBITMAP
   load_font (mi->dpy, "titleFont",  &sp->mode_font, &sp->font_dlist);
+# else /* !HAVE_GLBITMAP */
+  sp->font_data = load_texture_font (mi->dpy, "titleFont");
+# endif /* !HAVE_GLBITMAP */
 
   reshape_juggle (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
+  clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */
 
   if (!wire)
     {
@@ -2882,6 +2908,7 @@ draw_juggle (ModeInfo *mi)
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
   glPushMatrix ();
+  glRotatef(current_device_rotation(), 0, 0, 1);
 
   glTranslatef(0,-3,0);
 
@@ -3035,12 +3062,15 @@ draw_juggle (ModeInfo *mi)
        }
   }
 
-  if(sp->mode_font != None) {
-    print_gl_string (mi->dpy, sp->mode_font, sp->font_dlist,
-                     mi->xgwa.width, mi->xgwa.height,
-                     10, mi->xgwa.height - 10,
-                     sp->pattern, False);
-  }
+  print_gl_string (mi->dpy, 
+# ifdef HAVE_GLBITMAP
+                   sp->mode_font, sp->font_dlist,
+# else /* !HAVE_GLBITMAP */
+                   sp->font_data,
+# endif /* !HAVE_GLBITMAP */
+                   mi->xgwa.width, mi->xgwa.height,
+                   10, mi->xgwa.height - 10,
+                   sp->pattern, False);
 
 #ifdef MEMTEST
   if((int)(sp->time/10) % 1000 == 0)