X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=hacks%2Fglx%2Flament.c;h=8d5fe8c29b8300b97d0ebe14ca8367bf7ffe658a;hb=a445bdd3e3ba4abbee441844b6665b4c3c13d48c;hp=8a2360958900f81b257f6518e750c5bafd28f3ac;hpb=2a991a811de4c7b22f812682b267b616a809fd9a;p=xscreensaver diff --git a/hacks/glx/lament.c b/hacks/glx/lament.c index 8a236095..8d5fe8c2 100644 --- a/hacks/glx/lament.c +++ b/hacks/glx/lament.c @@ -81,8 +81,10 @@ #define PROGCLASS "Lament" #define HACK_INIT init_lament #define HACK_DRAW draw_lament +#define HACK_RESHAPE reshape_lament #define lament_opts xlockmore_opts #define DEFAULTS "*delay: 10000 \n" \ + "*showFPS: False \n" \ "*wireframe: False \n" \ "*texture: True \n" #include "xlockmore.h" @@ -183,7 +185,6 @@ parse_image_data(ModeInfo *mi) lament_faces); } - /* Computing normal vectors (thanks to Nat Friedman ) */ @@ -565,7 +566,7 @@ star(ModeInfo *mi, Bool top, Bool wire) #endif /* HAVE_GLBINDTEXTURE */ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, interior_color); - i = countof(points) - 3; + i = countof(points) - 9; do_normal(points[i+0][0], points[i+0][1], 0, points[i+4][0], points[i+4][1], 0, points[i+8][0], points[i+8][1], 0); @@ -712,7 +713,6 @@ tetra(ModeInfo *mi, Bool wire) 0.0, 0.0, 0.5, -0.5, 0.5, 0.0, 0.0, 0.5, 0.5, -0.5, 0.0, 0.0, -0.5, -0.5, -0.5); - glEnd(); } glEndList(); @@ -1873,8 +1873,8 @@ rotate(GLfloat *pos, GLfloat *v, GLfloat *dv, GLfloat max_v) /* Window management, etc */ -static void -reshape(int width, int height) +void +reshape_lament(ModeInfo *mi, int width, int height) { int target_size = 180; int win_size = (width > height ? height : width); @@ -1976,11 +1976,14 @@ gl_init(ModeInfo *mi) int height = lc->texture->width; /* assume square */ glBindTexture(GL_TEXTURE_2D, lc->texids[i]); glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, exterior_color); + + clear_gl_error(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lc->texture->width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (lc->texture->data + (lc->texture->bytes_per_line * height * i))); + check_gl_error("texture"); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); @@ -2025,6 +2028,48 @@ gl_init(ModeInfo *mi) } +# ifdef HAVE_MESA_GL + +# include + +static RETSIGTYPE +lament_signal_kludge (int sig) +{ + signal (sig, SIG_DFL); + fprintf (stderr, + "\n" + "%s: dying with signal %d (%s).\n" + "\n" + "\tThis is almost certainly a bug in the MesaGL library,\n" + "\tespecially if the stack trace in the core file mentions\n" + "\t`lambda_textured_triangle' or `render_quad'.\n" + "\n" + "\tI encourage you to report this to the Mesa maintainers\n" + "\tat . I reported this bug more\n" + "\tthan a year ago, and it is trivially reproducible.\n" + "\tI do not know a workaround.\n" + "\n", + progname, + sig, + (sig == SIGILL ? "SIGILL" : + sig == SIGFPE ? "SIGFPE" : + sig == SIGBUS ? "SIGBUS" : + sig == SIGSEGV ? "SIGSEGV" : "???")); + fflush (stderr); + kill (getpid (), sig); +} + +static void +handle_signals (void) +{ + signal (SIGILL, lament_signal_kludge); + signal (SIGFPE, lament_signal_kludge); + signal (SIGBUS, lament_signal_kludge); + signal (SIGSEGV, lament_signal_kludge); +} +# endif /* HAVE_MESA_GL */ + + void init_lament(ModeInfo *mi) { @@ -2057,25 +2102,24 @@ init_lament(ModeInfo *mi) lc->ddy = 0.00006 + frand(0.00003); lc->ddz = 0.00006 + frand(0.00003); - lc->ddx = 0.00001; - lc->ddy = 0.00001; - lc->ddz = 0.00001; - lc->type = LAMENT_BOX; lc->anim_pause = 300 + (random() % 100); if ((lc->glx_context = init_GL(mi)) != NULL) { - reshape(MI_WIDTH(mi), MI_HEIGHT(mi)); + reshape_lament(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); gl_init(mi); } + +# ifdef HAVE_MESA_GL + handle_signals (); +# endif /* HAVE_MESA_GL */ } void draw_lament(ModeInfo *mi) { - static int tick = 0; lament_configuration *lc = &lcs[MI_SCREEN(mi)]; Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); @@ -2087,6 +2131,8 @@ draw_lament(ModeInfo *mi) glXMakeCurrent(dpy, window, *(lc->glx_context)); draw(mi); + if (mi->fps_p) do_fps (mi); + glFinish(); glXSwapBuffers(dpy, window); @@ -2101,12 +2147,6 @@ draw_lament(ModeInfo *mi) lc->anim_pause--; else animate(mi); - - if (++tick > 500) - { - tick = 0; - reshape(MI_WIDTH(mi), MI_HEIGHT(mi)); - } } #endif /* USE_GL */