http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / hacks / glx / sonar.c
index 535b52fea5599ea0d014ada3804e7638a2b7a5d1..da66865b01f5ccef35779f726cfc87cf2ef7a396 100644 (file)
@@ -1,4 +1,4 @@
-/* sonar, Copyright (c) 1998-2008 Jamie Zawinski and Stephen Martin
+/* sonar, Copyright (c) 1998-2011 Jamie Zawinski and Stephen Martin
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -236,6 +236,9 @@ draw_screen (ModeInfo *mi, Bool mesh_p, Bool sweep_p)
 
       r0 = i     / (GLfloat) r_steps;
       r1 = (i+1) / (GLfloat) r_steps;
+
+      if (r1 > 1) r1 = 1; /* avoid asin lossage */
+
       z0 = cos (curvature/2 * asin (r0)) / 2 - zoff;
       z1 = cos (curvature/2 * asin (r1)) / 2 - zoff;
 
@@ -556,9 +559,11 @@ static void
 copy_and_insert_bogie (sonar_sensor_data *ssd, sonar_bogie *b,
                        sonar_bogie **to_list)
 {
-  sonar_bogie *ob, *prev;
+  sonar_bogie *ob, *next;
   if (!b) abort();
-  for (prev = 0, ob = *to_list; ob; prev = ob, ob = ob->next)
+  for (ob = *to_list, next = ob ? ob->next : 0; 
+       ob; 
+       ob = next, next = ob ? ob->next : 0)
     {
       if (ob == b) abort();   /* this will end badly */
       if (!strcmp (ob->name, b->name))  /* match! */
@@ -821,6 +826,7 @@ init_sonar (ModeInfo *mi)
   sp->glx_context = init_GL(mi);
 
   reshape_sonar (mi, MI_WIDTH(mi), MI_HEIGHT(mi));
+  clear_gl_error(); /* WTF? sometimes "invalid op" from glViewport! */
 
   if (!wire)
     {