From http://www.jwz.org/xscreensaver/xscreensaver-5.30.tar.gz
[xscreensaver] / hacks / glx / juggler3d.c
index b83a3aba3c77ebb532c1da3444684e0d7b014d26..f6b5ce7850377f958dc7f28db597ea757571d0a9 100644 (file)
@@ -579,9 +579,7 @@ typedef struct {
   ObjType       objtypes;
   Object       *objects;
   struct patternindex patternindex;
-
-  XFontStruct *mode_font;
-  GLuint font_dlist;
+  texture_font_data *font_data;
 } jugglestruct;
 
 static jugglestruct *juggles = (jugglestruct *) NULL;
@@ -658,10 +656,6 @@ free_juggle(jugglestruct *sp) {
        free(sp->pattern);
        sp->pattern = NULL;
   }
-  if (sp->mode_font!=None) {
-       XFreeFontInfo(NULL,sp->mode_font,1);
-       sp->mode_font = None;
-  }
 }
 
 static Bool
@@ -1696,6 +1690,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 +1795,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 +2063,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 +2120,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 +2243,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 +2303,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 */
 
@@ -2388,6 +2394,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();
@@ -2651,9 +2659,10 @@ init_juggle (ModeInfo * mi)
 
   sp->glx_context = init_GL(mi);
 
-  load_font (mi->dpy, "titleFont",  &sp->mode_font, &sp->font_dlist);
+  sp->font_data = load_texture_font (mi->dpy, "titleFont");
 
   reshape_juggle (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
+  clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */
 
   if (!wire)
     {
@@ -2683,7 +2692,7 @@ init_juggle (ModeInfo * mi)
     double spin_accel   = 0.05;
     sp->rot = make_rotator (0, spin_speed, 0, 
                             spin_accel, wander_speed, False);
-    sp->trackball = gltrackball_init ();
+    sp->trackball = gltrackball_init (False);
   }
 
   if (only && *only && strcmp(only, " ")) {
@@ -2807,51 +2816,15 @@ juggle_handle_event (ModeInfo *mi, XEvent *event)
 {
   jugglestruct *sp = &juggles[MI_SCREEN(mi)];
 
-  if (event->xany.type == ButtonPress &&
-      event->xbutton.button == Button1)
-    {
-      sp->button_down_p = True;
-      gltrackball_start (sp->trackball,
-                         event->xbutton.x, event->xbutton.y,
-                         MI_WIDTH (mi), MI_HEIGHT (mi));
-      return True;
-    }
-  else if (event->xany.type == ButtonRelease &&
-           event->xbutton.button == Button1)
+  if (gltrackball_event_handler (event, sp->trackball,
+                                 MI_WIDTH (mi), MI_HEIGHT (mi),
+                                 &sp->button_down_p))
+    return True;
+  else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
     {
-      sp->button_down_p = False;
+      change_juggle (mi);
       return True;
     }
-  else if (event->xany.type == ButtonPress &&
-           (event->xbutton.button == Button4 ||
-            event->xbutton.button == Button5 ||
-            event->xbutton.button == Button6 ||
-            event->xbutton.button == Button7))
-    {
-      gltrackball_mousewheel (sp->trackball, event->xbutton.button, 10,
-                              !!event->xbutton.state);
-      return True;
-    }
-  else if (event->xany.type == MotionNotify &&
-           sp->button_down_p)
-    {
-      gltrackball_track (sp->trackball,
-                         event->xmotion.x, event->xmotion.y,
-                         MI_WIDTH (mi), MI_HEIGHT (mi));
-      return True;
-    }
-  else if (event->xany.type == KeyPress)
-    {
-      KeySym keysym;
-      char c = 0;
-      XLookupString (&event->xkey, &c, 1, &keysym, 0);
-      if (c == ' ' || c == '\n' || c == '\r' || c == '\t')
-        {
-          change_juggle (mi);
-          return True;
-        }
-    }
-
 
   return False;
 }
@@ -2883,6 +2856,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);
 
@@ -3036,12 +3010,10 @@ 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, sp->font_data,
+                   mi->xgwa.width, mi->xgwa.height,
+                   10, mi->xgwa.height - 10,
+                   sp->pattern, False);
 
 #ifdef MEMTEST
   if((int)(sp->time/10) % 1000 == 0)