X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fgleidescope.c;h=6ddf99d14463248ca9e2bc976969a863a3ac0d20;hb=447db08c956099b3b183886729108bf5b364c4b8;hp=7470d3f3888d1584c92645212bcc2fe61fefc1b4;hpb=96a411663168b0ba5432b407a83be55f3df0c802;p=xscreensaver diff --git a/hacks/glx/gleidescope.c b/hacks/glx/gleidescope.c index 7470d3f3..6ddf99d1 100644 --- a/hacks/glx/gleidescope.c +++ b/hacks/glx/gleidescope.c @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 4 -*- */ #if !defined( lint ) && !defined( SABER ) -static const char sccsid[] = "@(#)gleidescope.c 1.0 03/06/27 xlockmore"; +/*static const char sccsid[] = "@(#)gleidescope.c 1.0 03/06/27 xlockmore";*/ #endif /* enable -grab switch */ @@ -64,12 +64,8 @@ static const char sccsid[] = "@(#)gleidescope.c 1.0 03/06/27 xlockmore"; # define DEFAULTS \ "*delay: 20000 \n" \ "*showFPS: False \n" \ - "*move: False \n" \ - "*rotate: False \n" \ - "*zoom: False \n" \ - "*image: DEFAULT \n" \ "*size: -1 \n" \ - "*duration: 30 \n" \ + "*useSHM: True \n" # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -109,33 +105,33 @@ static float rangle_acc = 0.0; /* rotate acceleration */ static XrmOptionDescRec opts[] = { #ifdef GRAB - {"-grab", (char *) ".gleidescope.grab", XrmoptionNoArg, "true"}, + {"-grab", ".gleidescope.grab", XrmoptionNoArg, "true"}, #endif - {"-move", (char *) ".gleidescope.move", XrmoptionNoArg, "true"}, - {"-no-move", (char *) ".gleidescope.nomove", XrmoptionNoArg, "true"}, - {"-rotate", (char *) ".gleidescope.rotate", XrmoptionNoArg, "true"}, - {"-no-rotate", (char *) ".gleidescope.norotate", XrmoptionNoArg, "true"}, - /*{"-size", (char *) ".gleidescope.size", XrmoptionNoArg, "-1"},*/ - {"-zoom", (char *) ".gleidescope.zoom", XrmoptionNoArg, "true"}, - {"-no-zoom", (char *) ".gleidescope.nozoom", XrmoptionNoArg, "true"}, - {"-image", (char *) ".gleidescope.image", XrmoptionSepArg, "DEFAULT"}, - {"-duration", (char *) ".gleidescope.duration", XrmoptionSepArg, "30"}, + {"-move", ".gleidescope.move", XrmoptionNoArg, "true"}, + {"-no-move", ".gleidescope.nomove", XrmoptionNoArg, "true"}, + {"-rotate", ".gleidescope.rotate", XrmoptionNoArg, "true"}, + {"-no-rotate", ".gleidescope.norotate", XrmoptionNoArg, "true"}, + /*{"-size", ".gleidescope.size", XrmoptionNoArg, "-1"},*/ + {"-zoom", ".gleidescope.zoom", XrmoptionNoArg, "true"}, + {"-no-zoom", ".gleidescope.nozoom", XrmoptionNoArg, "true"}, + {"-image", ".gleidescope.image", XrmoptionSepArg, "DEFAULT"}, + {"-duration", ".gleidescope.duration", XrmoptionSepArg, "30"}, }; static argtype vars[] = { #ifdef GRAB - {(caddr_t *) &grab, "grab", "Grab", "False", t_Bool}, + {&grab, "grab", "Grab", "False", t_Bool}, #endif - {(caddr_t *) &move, "move", "Move", "False", t_Bool}, - {(caddr_t *) &nomove, "nomove", "noMove", "False", t_Bool}, - {(caddr_t *) &rotate, "rotate", "Rotate", "False", t_Bool}, - {(caddr_t *) &norotate, "norotate", "noRotate", "False", t_Bool}, - /*{(caddr_t *) &size, "size", "Size", "-1", t_Int},*/ - {(caddr_t *) &zoom, "zoom", "Zoom", "False", t_Bool}, - {(caddr_t *) &nozoom, "nozoom", "noZoom", "False", t_Bool}, - {(caddr_t *) &image, "image", "Image", "DEFAULT", t_String}, - {(caddr_t *) &duration, "duration", "Duration", "30", t_Int}, + {&move, "move", "Move", "False", t_Bool}, + {&nomove, "nomove", "noMove", "False", t_Bool}, + {&rotate, "rotate", "Rotate", "False", t_Bool}, + {&norotate, "norotate", "noRotate", "False", t_Bool}, + /*{&size, "size", "Size", "-1", t_Int},*/ + {&zoom, "zoom", "Zoom", "False", t_Bool}, + {&nozoom, "nozoom", "noZoom", "False", t_Bool}, + {&image, "image", "Image", "DEFAULT", t_String}, + {&duration, "duration", "Duration", "30", t_Int}, }; static OptionStruct desc[] = { @@ -417,7 +413,8 @@ gleidescope_handle_event(ModeInfo *mi, XEvent *event) { case ButtonPress: - if (event->xbutton.button == Button1 || event->xbutton.button == Button3) + if (event->xbutton.button == Button1 || + event->xbutton.button == Button3) { /* store initial values of mouse */ xstart = event->xbutton.x; @@ -443,7 +440,8 @@ gleidescope_handle_event(ModeInfo *mi, XEvent *event) case ButtonRelease: - if (event->xbutton.button == Button1 || event->xbutton.button == Button3) + if (event->xbutton.button == Button1 || + event->xbutton.button == Button3) { /* button is up */ gp->button_down_p = False; @@ -474,59 +472,24 @@ gleidescope_handle_event(ModeInfo *mi, XEvent *event) static void getSnapshot(ModeInfo *mi, GLuint name) { - XImage *ximage; - int status; - int tw, th; + Bool mipmap_p = True; + int iw, ih, tw, th; gleidestruct *gp = &gleidescope[MI_SCREEN(mi)]; if (MI_IS_WIREFRAME(mi)) return; - ximage = screen_to_ximage(mi->xgwa.screen, mi->window, 0); - - tw = mi->xgwa.width; - th = mi->xgwa.height; - - gp->max_tx = (GLfloat) tw / (GLfloat) ximage->width; - gp->max_ty = (GLfloat) th / (GLfloat) ximage->height; - glBindTexture (GL_TEXTURE_2D, name); + if (! screen_to_texture (mi->xgwa.screen, mi->window, 0, 0, + mipmap_p, NULL, NULL, &iw, &ih, &tw, &th)) + exit (1); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR_MIPMAP_LINEAR); - - clear_gl_error(); - status = gluBuild2DMipmaps(GL_TEXTURE_2D, 3, - ximage->width, ximage->height, - GL_RGBA, GL_UNSIGNED_BYTE, ximage->data); - - if (!status && glGetError()) - /* Some implementations of gluBuild2DMipmaps(), but set a GL error anyway. - ** We could just call check_gl_error(), but that would exit. */ - status = -1; - - if (status) - { - const GLubyte *s = gluErrorString (status); - if (s) - { - fprintf (stderr, "%s: error mipmapping %dx%d texture: %s\n", - progname, ximage->width, ximage->height, s); - } - else - { - fprintf (stderr, "%s: error mipmapping %dx%d texture: (unknown)\n", - progname, ximage->width, ximage->height); - } - clear_gl_error(); - } - check_gl_error("mipmapping"); /* should get a return code instead of a - GL error, but just in case... */ + gp->max_tx = (GLfloat) iw / tw; + gp->max_ty = (GLfloat) ih / th; - free(ximage->data); - ximage->data = 0; - XDestroyImage (ximage); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + (mipmap_p ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR)); /* remember time of last image change */ gp->start_time = time ((time_t *) 0);