ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.22.tar.gz
[xscreensaver] / hacks / glx / stairs.c
index 97808a0c86d14509c7688b6b89c3c2b696351faf..583360cdba1fe195db219298ca3be1d792db6c8f 100644 (file)
@@ -1,9 +1,8 @@
 /* -*- Mode: C; tab-width: 4 -*- */
 /* stairs --- Infinite Stairs, and Escher-like scene. */
 
-#if !defined( lint ) && !defined( SABER )
+#if 0
 static const char sccsid[] = "@(#)stairs.c     4.07 97/11/24 xlockmore";
-
 #endif
 
 #undef DEBUG_LISTS
@@ -64,10 +63,10 @@ static const char sccsid[] = "@(#)stairs.c  4.07 97/11/24 xlockmore";
 # define PROGCLASS                     "Stairs"
 # define HACK_INIT                     init_stairs
 # define HACK_DRAW                     draw_stairs
+# define HACK_RESHAPE          reshape_stairs
 # define stairs_opts           xlockmore_opts
-# define DEFAULTS                      "*cycles:               1       \n"                     \
-                                                       "*delay:                20000   \n"                     \
-                                                       "*wireframe:    False   \n"
+# define DEFAULTS                      "*delay:                20000   \n" \
+                                                       "*showFPS:      False   \n"
 # include "xlockmore.h"                /* from the xscreensaver distribution */
 #else /* !STANDALONE */
 # include "xlock.h"                    /* from the xlockmore distribution */
@@ -414,8 +413,8 @@ draw_stairs_internal(ModeInfo * mi)
                sp->sphere_position = 0;
 }
 
-static void
-reshape(ModeInfo * mi, int width, int height)
+void
+reshape_stairs(ModeInfo * mi, int width, int height)
 {
        stairsstruct *sp = &stairs[MI_SCREEN(mi)];
 
@@ -439,6 +438,7 @@ reshape(ModeInfo * mi, int width, int height)
 static void
 pinit(void)
 {
+    int status;
        glClearDepth(1.0);
        glClearColor(0.0, 0.0, 0.0, 1.0);
 
@@ -464,8 +464,21 @@ pinit(void)
        glEnable(GL_CULL_FACE);
 
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-       gluBuild2DMipmaps(GL_TEXTURE_2D, 3, WoodTextureWidth, WoodTextureHeight,
-                         GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
+
+    clear_gl_error();
+    status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3,
+                               WoodTextureWidth, WoodTextureHeight,
+                               GL_RGB, GL_UNSIGNED_BYTE, WoodTextureData);
+    if (status)
+      {
+        const char *s = (char *) gluErrorString (status);
+        fprintf (stderr, "%s: error mipmapping %dx%d texture: %s\n",
+                 progname, WoodTextureWidth, WoodTextureHeight,
+                 (s ? s : "(unknown)"));
+        exit (1);
+      }
+    check_gl_error("mipmapping");
+
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@@ -495,7 +508,7 @@ init_stairs(ModeInfo * mi)
 
        if ((sp->glx_context = init_GL(mi)) != NULL) {
 
-               reshape(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
+               reshape_stairs(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
                glDrawBuffer(GL_BACK);
                if (!glIsList(objects))
                        objects = glGenLists(1);
@@ -541,6 +554,7 @@ draw_stairs(ModeInfo * mi)
 
        glPopMatrix();
 
+    if (mi->fps_p) do_fps (mi);
        glFlush();
 
        glXSwapBuffers(display, window);