ftp://ftp.linux.ncsu.edu/mirror/ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os...
[xscreensaver] / hacks / glx / glforestfire.c
index dee6a56670c86a7027c41cc82d8a555110af54ea..589ed6172ddf19981f904a2f9aa641c7430e7612 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 4 -*- */
 /* fire --- 3D fire or rain landscape */
 
-#if !defined( lint ) && !defined( SABER )
+#if 0
 static const char sccsid[] = "@(#)fire.c       5.02 2001/09/26 xlockmore";
 #endif
 
@@ -25,7 +25,7 @@ static const char sccsid[] = "@(#)fire.c      5.02 2001/09/26 xlockmore";
  * of Mesa (Mesa-3.2/3Dfx/demos/). This mode is the result of the merge of
  * two of the David's demos (fire and rain).
  *
- * Eric Lassauge  (October-10-2000) <lassauge@mail.dotcom.fr>
+ * Eric Lassauge  (October-10-2000) <lassauge@users.sourceforge.net>
  *                                 http://lassauge.free.fr/linux.html
  *
  * REVISION HISTORY:
@@ -180,36 +180,37 @@ static int frame = 0;
 static XFontStruct *mode_font = None;
 
 static XrmOptionDescRec opts[] = {
-    {(char *) "-texture", (char *) ".fire.texture", XrmoptionNoArg, (caddr_t) "on"},
-    {(char *) "+texture", (char *) ".fire.texture", XrmoptionNoArg, (caddr_t) "off"},
-    {(char *) "-fog", (char *) ".fire.fog", XrmoptionNoArg, (caddr_t) "on"},
-    {(char *) "+fog", (char *) ".fire.fog", XrmoptionNoArg, (caddr_t) "off"},
-    {(char *) "-shadows", (char *) ".fire.shadows", XrmoptionNoArg, (caddr_t) "on"},
-    {(char *) "+shadows", (char *) ".fire.shadows", XrmoptionNoArg, (caddr_t) "off"},
-    {(char *) "-trackmouse", (char *) ".fire.trackmouse", XrmoptionNoArg, (caddr_t) "on"},
-    {(char *) "+trackmouse", (char *) ".fire.trackmouse", XrmoptionNoArg, (caddr_t) "off"},
-    {(char *) "-wander", (char *) ".fire.wander", XrmoptionNoArg, (caddr_t) "on"},
-    {(char *) "+wander", (char *) ".fire.wander", XrmoptionNoArg, (caddr_t) "off"},
-    {(char *) "-trees", (char *) ".fire.trees", XrmoptionSepArg, (caddr_t) NULL},
+    {"-texture", ".fire.texture", XrmoptionNoArg, "on"},
+    {"+texture", ".fire.texture", XrmoptionNoArg, "off"},
+    {"-fog", ".fire.fog", XrmoptionNoArg, "on"},
+    {"+fog", ".fire.fog", XrmoptionNoArg, "off"},
+    {"-shadows", ".fire.shadows", XrmoptionNoArg, "on"},
+    {"+shadows", ".fire.shadows", XrmoptionNoArg, "off"},
+    {"-trackmouse", ".fire.trackmouse", XrmoptionNoArg, "on"},
+    {"+trackmouse", ".fire.trackmouse", XrmoptionNoArg, "off"},
+    {"-wander", ".fire.wander", XrmoptionNoArg, "on"},
+    {"+wander", ".fire.wander", XrmoptionNoArg, "off"},
+    {"-trees", ".fire.trees", XrmoptionSepArg, 0},
+    {"-rain", ".fire.count", XrmoptionNoArg, "0"},
 
 };
 
 static argtype vars[] = {
-    {(caddr_t *) & do_texture, (char *) "texture", (char *) "Texture", (char *) DEF_TEXTURE, t_Bool},
-    {(caddr_t *) & do_fog, (char *) "fog", (char *) "Fog", (char *) DEF_FOG, t_Bool},
-    {(caddr_t *) & do_shadows, (char *) "shadows", (char *) "Shadows", (char *) DEF_SHADOWS, t_Bool},
-    {(caddr_t *) & do_trackmouse, (char *) "trackmouse", (char *) "TrackMouse", (char *) DEF_TRACKMOUSE, t_Bool},
-    {(caddr_t *) & do_wander, (char *) "wander", (char *) "Wander", (char *) DEF_WANDER, t_Bool},
-    {(caddr_t *) & num_trees, (char *) "trees", (char *) "Trees", (char *) DEF_TREES, t_Int},
+    {&do_texture,    "texture",    "Texture",    DEF_TEXTURE,    t_Bool},
+    {&do_fog,        "fog",        "Fog",        DEF_FOG,        t_Bool},
+    {&do_shadows,    "shadows",    "Shadows",    DEF_SHADOWS,    t_Bool},
+    {&do_trackmouse, "trackmouse", "TrackMouse", DEF_TRACKMOUSE, t_Bool},
+    {&do_wander,     "wander",     "Wander",     DEF_WANDER,     t_Bool},
+    {&num_trees,     "trees",      "Trees",      DEF_TREES,      t_Int},
 };
 
 static OptionStruct desc[] = {
-    {(char *) "-/+texture", (char *) "turn on/off texturing"},
-    {(char *) "-/+fog", (char *) "turn on/off fog"},
-    {(char *) "-/+shadows", (char *) "turn on/off shadows"},
-    {(char *) "-/+trackmouse", (char *) "turn on/off the tracking of the mouse"},
-    {(char *) "-/+wander", (char *) "turn on/off wandering"},
-    {(char *) "-trees num", (char *) "number of trees (0 disables)"},
+    {"-/+texture", "turn on/off texturing"},
+    {"-/+fog", "turn on/off fog"},
+    {"-/+shadows", "turn on/off shadows"},
+    {"-/+trackmouse", "turn on/off the tracking of the mouse"},
+    {"-/+wander", "turn on/off wandering"},
+    {"-trees num", "number of trees (0 disables)"},
 };
 
 ModeSpecOpt fire_opts =
@@ -338,8 +339,13 @@ static float gettimerain(void)
 {
 #if 0
   /* Oh yeah, *that's* portable!  WTF. */
+  /* 
+   * I really thought clock() was standard ... EL
+   * I found this on the net:
+   * The clock() function conforms to ISO/IEC 9899:1990 (``ISO C89'') 
+   * */
 
-  static clock_t told=0;
+  static clock_t told= (clock_t)0;
   clock_t tnew,ris;
 
   tnew=clock();
@@ -348,9 +354,9 @@ static float gettimerain(void)
 
   told=tnew;
 
-  return (ris/(float)CLOCKS_PER_SEC);
+  return (0.0125 + ris/(float)CLOCKS_PER_SEC);
 #else
-  return 0;
+  return 0.0150;
 #endif
 }
 
@@ -590,8 +596,11 @@ static void inittextures(ModeInfo * mi)
        glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
     clear_gl_error();
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
-                    fs->gtexture->width, fs->gtexture->height, 0,
-                    GL_RGBA, GL_UNSIGNED_BYTE, fs->gtexture->data);
+                 fs->gtexture->width, fs->gtexture->height, 0,
+                 GL_RGBA,
+                 /* GL_UNSIGNED_BYTE, */
+                 GL_UNSIGNED_INT_8_8_8_8_REV,
+                 fs->gtexture->data);
     check_gl_error("texture");
 
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
@@ -619,8 +628,11 @@ static void inittextures(ModeInfo * mi)
 
         clear_gl_error();
            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
-                       fs->ttexture->width, fs->ttexture->height, 0,
-                       GL_RGBA, GL_UNSIGNED_BYTE, fs->ttexture->data);
+                     fs->ttexture->width, fs->ttexture->height, 0,
+                     GL_RGBA,
+                     /* GL_UNSIGNED_BYTE, */
+                     GL_UNSIGNED_INT_8_8_8_8_REV,
+                     fs->ttexture->data);
         check_gl_error("texture");
 
            glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);