From http://www.jwz.org/xscreensaver/xscreensaver-5.39.tar.gz
[xscreensaver] / hacks / glx / winduprobot.c
index c90d07359687098ffe5db5f038213a6667c8b18e..61091cfce9cdb34f048c3329a7aae8a0b2c9f4aa 100644 (file)
@@ -1,4 +1,4 @@
-/* winduprobot, Copyright (c) 2014-2017 Jamie Zawinski <jwz@jwz.org>
+/* winduprobot, Copyright (c) 2014-2018 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -68,7 +68,6 @@
 #undef DEBUG
 #define WORDBUBBLES
 
-# define refresh_robot 0
 # define release_robot 0
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
@@ -82,7 +81,7 @@
 
 #include "xlockmore.h"
 #include "gltrackball.h"
-#include "xpm-ximage.h"
+#include "ximage-loader.h"
 #include "involute.h"
 #include "sphere.h"
 
@@ -98,7 +97,7 @@
 #endif
 
 #ifdef HAVE_TEXTURE
-# include "../images/chromesphere.xpm"
+# include "images/gen/chromesphere_png.h"
 #endif
 
 #ifdef USE_GL /* whole file */
@@ -237,8 +236,15 @@ ENTRYPOINT void
 reshape_robot (ModeInfo *mi, int width, int height)
 {
   GLfloat h = (GLfloat) height / (GLfloat) width;
+  int y = 0;
 
-  glViewport (0, 0, width, height);
+  if (width > height * 5) {   /* tiny window: show middle */
+    height = width * 9/16;
+    y = -height/2;
+    h = height / (GLfloat) width;
+  }
+
+  glViewport (0, y, width, height);
 
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
@@ -313,8 +319,8 @@ load_textures (ModeInfo *mi)
   robot_configuration *bp = &bps[MI_SCREEN(mi)];
   XImage *xi;
 
-  xi = xpm_to_ximage (mi->dpy, mi->xgwa.visual, mi->xgwa.colormap,
-                      chromesphere_xpm);
+  xi = image_data_to_ximage (mi->dpy, mi->xgwa.visual,
+                             chromesphere_png, sizeof(chromesphere_png));
   clear_gl_error();
 
   glGenTextures (1, &bp->chrome_texture);
@@ -324,13 +330,7 @@ load_textures (ModeInfo *mi)
   glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
   glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
                 xi->width, xi->height, 0,
-                GL_RGBA,
-# ifndef USE_IPHONE
-                GL_UNSIGNED_INT_8_8_8_8_REV,
-# else
-                GL_UNSIGNED_BYTE,
-# endif
-                xi->data);
+                GL_RGBA, GL_UNSIGNED_BYTE, xi->data);
   check_gl_error("texture");
 
   glEnable(GL_TEXTURE_GEN_S);
@@ -344,7 +344,6 @@ load_textures (ModeInfo *mi)
 static int unit_gear (ModeInfo *, GLfloat color[4]);
 static int draw_ground (ModeInfo *, GLfloat color[4]);
 static void init_walker (ModeInfo *, walker *);
-static void free_robot (ModeInfo *mi);
 
 static void
 parse_color (ModeInfo *mi, char *key, GLfloat color[4])
@@ -371,7 +370,7 @@ init_robot (ModeInfo *mi)
   robot_configuration *bp;
   int wire = MI_IS_WIREFRAME(mi);
   int i;
-  MI_INIT (mi, bps, free_robot);
+  MI_INIT (mi, bps);
 
   bp = &bps[MI_SCREEN(mi)];
 
@@ -2469,7 +2468,7 @@ draw_robot (ModeInfo *mi)
   glXSwapBuffers(dpy, window);
 }
 
-static void
+ENTRYPOINT void
 free_robot (ModeInfo *mi)
 {
 # ifdef WORDBUBBLES