From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[xscreensaver] / hacks / glx / flipscreen3d.c
index 92c0fa0dc5da99748e368b578479b7f1cfc9d504..7217de969353a13599215bb93abf148199a81392 100644 (file)
@@ -322,12 +322,21 @@ static void drawgrid(void)
 static void display(Screenflip *c, int wire)
 {
   int frozen;
+  GLfloat rot = current_device_rotation();
 
   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
   glLoadIdentity();
   gluLookAt(viewer[0], viewer[1], viewer[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   glPushMatrix();
 
+  glRotatef(rot, 0, 0, 1);
+  if ((rot >  45 && rot <  135) ||
+      (rot < -45 && rot > -135))
+    {
+      GLfloat s = c->winw / (GLfloat) c->winh;
+      glScalef (s, 1/s, 1);
+    }
+
   if (inposition(c)) {
     frozen = 0;
     glTranslatef(5 * sin(c->theta), 5 * sin(c->rho), 10 * cos(c->gamma) - 10);
@@ -340,7 +349,9 @@ static void display(Screenflip *c, int wire)
       if (random() % 2)
         c->dgamma = 1/60 - (float)(random() % 100)/3000;
     }
+    glRotatef(-rot, 0, 0, 1);
     gltrackball_rotate (c->trackball);
+    glRotatef(rot, 0, 0, 1);
     if (rotate) glRotatef(c->rot, c->rx, c->ry, c->rz);
 /* update variables with each frame */
     if(!c->button_down_p && !c->fadetime) {
@@ -470,8 +481,6 @@ ENTRYPOINT void init_screenflip(ModeInfo *mi)
  c->show_colors[0] = c->show_colors[1] = 
    c->show_colors[2] = c->show_colors[3] = 1;
 
- glClearColor(0.0,0.0,0.0,0.0);
-
  if (! MI_IS_WIREFRAME(mi))
    {
      glShadeModel(GL_SMOOTH);