From http://www.jwz.org/xscreensaver/xscreensaver-5.20.tar.gz
[xscreensaver] / hacks / glx / glcells.c
index 746f258fd71318ac2d88cafbb1c50234e3acc406..c312f0c2d6083405036065366610ad5ba860725e 100644 (file)
@@ -20,7 +20,7 @@
  *
  * 2007: Written by Matthias Toussaint
  * 0.1 Initial version
- * 0.2 Bugfixes (threading) and code cleanup by Jamie Zavinsky
+ * 0.2 Bugfixes (threading) and code cleanup by Jamie Zawinski
  *     Window scaling bug + performance bug in tick()
  */
  
@@ -48,7 +48,7 @@
 #define DEF_MINFOOD   "5"
 #define DEF_MAXFOOD   "20"
 #define DEF_DIVIDEAGE "20"
-#define DEF_MINDIST   "1.40"
+#define DEF_MINDIST   "1.4"
 #define DEF_PAUSE     "50"
 
 #define DEFAULTS       "*delay:        30000            \n" \
@@ -58,7 +58,9 @@
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
 
-#define USE_VERTEX_ARRAY
+#ifndef HAVE_JWZGLES /* glDrawElements unimplemented... */
+# define USE_VERTEX_ARRAY
+#endif
 
 #define TEX_SIZE 64
 
@@ -184,7 +186,7 @@ static argtype vars[] = {
   {&s_maxfood,   "maxfood",   "Max Food",       DEF_MAXFOOD,  t_Int},
   {&s_pause,   "pause",     "Pause at end",   DEF_PAUSE,  t_Int},
   {&s_divideage, "divideage", "Age for duplication (Ticks)",       DEF_DIVIDEAGE,  t_Int},
-  {&s_min_dist,  "mindist",   "Minimum prefered distance to other cells",       DEF_MINDIST,  t_Float},
+  {&s_min_dist,  "mindist",   "Minimum preferred distance to other cells",       DEF_MINDIST,  t_Float},
   {&s_keepold,   "keepold",   "Keep old cells", DEF_KEEPOLD,  t_Bool}
 };
 
@@ -242,7 +244,9 @@ static Object *create_sphere( State *st, int divisions );
 static Object *clone_Object( Object * );
 /* return 1 if cell is capable to divide */
 static int can_divide( State *st, Cell *cell );
+#ifdef USE_VERTEX_ARRAY
 static VertexArray *array_from_ObjectSmooth( ObjectSmooth * );
+#endif
 static void create_nucleus_texture( State *st );
 
 ENTRYPOINT ModeSpecOpt glcells_opts = { countof(opts), opts,                                                   countof(vars), vars, 
@@ -422,6 +426,7 @@ static Object *clone_Object( Object *obj )
   return ret;
 }
 
+#ifdef USE_VERTEX_ARRAY
 static VertexArray *array_from_ObjectSmooth( ObjectSmooth *obj )
 {
   int i, j;
@@ -449,6 +454,8 @@ static VertexArray *array_from_ObjectSmooth( ObjectSmooth *obj )
   
   return array;
 }
+#endif /* USE_VERTEX_ARRAY */
+
 
 /* create a smoothed version of the given Object
    by computing average normal vectors for the vertexes 
@@ -696,8 +703,7 @@ static int render( State *st )
   fprintf( stderr, "tick %d\n", usec );
   gettimeofday( &tv1, NULL );
 #endif
-  glClearColor( 0, 0, 0, 0 );
-  
+
   glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
   glDepthFunc(GL_LESS);
   glEnable(GL_DEPTH_TEST);
@@ -850,6 +856,8 @@ static int create_list( State *st, double fac )
   ObjectSmooth *smooth;
 #ifdef USE_VERTEX_ARRAY
   VertexArray *vertex_array;
+#else
+  int t, i;
 #endif
   int list = glGenLists(1);  
   
@@ -1189,8 +1197,7 @@ reshape_glcells( ModeInfo *mi, int width, int height )
   
   if (st->food) free( st->food );
   st->food = (int *)malloc( ((width*height)/16)*sizeof(int) );
-  
-  create_cells( st );
+  /* create_cells( st );*/
 }
 
 ENTRYPOINT void 
@@ -1214,6 +1221,10 @@ init_glcells( ModeInfo *mi )
   st->num_cells = 0;
   st->wire = MI_IS_WIREFRAME(mi);
   
+# ifdef HAVE_JWZGLES /* #### glPolygonMode other than GL_FILL unimplemented */
+  st->wire = 0;
+# endif
+
   /* get settings */
   st->max_cells = s_maxcells;;
   if (st->max_cells < 50) st->max_cells = 50;