From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver] / hacks / glx / circuit.c
index 3a848d195e7178925979925875daa64f416801a7..a0b9c161bf41746e99bd2012d9ee62e906c50967 100644 (file)
@@ -32,6 +32,7 @@
 #ifdef STANDALONE
 #define DEFAULTS        "*delay:   20000 \n" \
                         "*showFPS: False \n" \
+                       "*suppressRotationAnimation: True\n" \
                "*componentFont: -*-courier-bold-r-normal-*-*-140-*-*-*-*-*-*"
 
 # define refresh_circuit 0
@@ -1037,7 +1038,6 @@ static int DrawIC(Circuit *ci, IC *c)
   GLfloat lspec[] = {0.6, 0.6, 0.6, 0};
   GLfloat lcol[] = {0.4, 0.4, 0.4, 0};
   GLfloat lshine = 40;
-  float th, size;
 
   glPushMatrix();
   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, col);
@@ -1103,20 +1103,12 @@ static int DrawIC(Circuit *ci, IC *c)
     glDisable(GL_POLYGON_OFFSET_FILL);
     glEnable(GL_TEXTURE_2D);
     glEnable(GL_BLEND);
-    if (c->pins == 8)
-      size = 0.4;
-    else
-      size = 0.6;
-    th = size*2/3;
 
     {
       GLfloat texfg[] = {0.7, 0.7, 0.7, 1.0};
       GLfloat s = 0.015;
       XCharStruct e;
-      int w, h;
       texture_string_metrics (ci->font, c->text, &e, 0, 0);
-      w = e.width;
-      h = e.ascent + e.descent;
 
       glPushMatrix();
       glTranslatef (0, 0, 0.1);
@@ -1356,10 +1348,9 @@ static int DrawTransistor(Circuit *ci, Transistor *t)
       GLfloat texfg[] = {0.7, 0.7, 0.7, 1.0};
       GLfloat s = 0.015;
       XCharStruct e;
-      int w, h;
+      int w;
       texture_string_metrics (ci->font, t->text, &e, 0, 0);
       w = e.width;
-      h = e.ascent + e.descent;
       glPushMatrix();
       glRotatef (90, 1, 0, 0);
       glTranslatef (0.5, -0.05, 0.21);
@@ -1385,10 +1376,9 @@ static int DrawTransistor(Circuit *ci, Transistor *t)
       GLfloat texfg[] = {0.7, 0.7, 0.7, 1.0};
       GLfloat s = 0.015;
       XCharStruct e;
-      int w, h;
+      int w;
       texture_string_metrics (ci->font, t->text, &e, 0, 0);
       w = e.width;
-      h = e.ascent + e.descent;
       glPushMatrix();
       glTranslatef (0.75, 0.75, 0.01);
       glScalef (s, s, s);
@@ -1918,7 +1908,6 @@ static void display(ModeInfo *mi)
   glEnable(GL_LIGHTING);
   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
   glLoadIdentity();
-  /* glRotatef(current_device_rotation(), 0, 0, 1); */
   gluLookAt(ci->viewer[0], ci->viewer[1], ci->viewer[2], 
             0.0, 0.0, 0.0, 
             0.0, 1.0, 0.0);
@@ -1933,6 +1922,18 @@ static void display(ModeInfo *mi)
   glLighti(GL_LIGHT0, GL_CONSTANT_ATTENUATION, (GLfloat)1); 
   glLighti(GL_LIGHT0, GL_LINEAR_ATTENUATION, (GLfloat)0.5); 
   glLighti(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, (GLfloat)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 (h, h, h);
+    h = 2;
+    glScalef (h, h, h);
+  }
+# endif
+
   mi->polygon_count += drawgrid(ci);
   glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, light_sp);
   if (f_rand() < 0.05) {