/* -*- 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 */
# 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 */
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[] = {
{
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;
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;
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);