-/* glslideshow, Copyright (c) 2003-2006 Jamie Zawinski <jwz@jwz.org>
+/* glslideshow, Copyright (c) 2003-2014 Jamie Zawinski <jwz@jwz.org>
* Loads a sequence of images and smoothly pans around them; crossfades
* when loading new images.
*
"*showFPS: False \n" \
"*fpsSolid: True \n" \
"*useSHM: True \n" \
- "*titleFont: -*-times-bold-r-normal-*-180-*\n" \
+ "*titleFont: -*-helvetica-medium-r-normal-*-*-180-*-*-*-*-*-*\n" \
"*desktopGrabber: xscreensaver-getimage -no-desktop %s\n" \
"*grabDesktopImages: False \n" \
"*chooseRandomImages: True \n"
# define DEF_MIPMAP "True"
#include "grab-ximage.h"
-#include "glxfonts.h"
+#include "texfont.h"
typedef struct {
double x, y, w, h;
Bool checked_fps_p; /* Whether we have checked for a low
frame rate. */
- XFontStruct *xfont; /* for printing image file names */
- GLuint font_dlist;
+ texture_font_data *font_data; /* for printing image file names */
int sprite_id, image_id; /* debugging id counters */
static const char *
blurb (void)
{
-# ifdef HAVE_COCOA
+# ifdef HAVE_JWXYZ
return "GLSlideshow";
# else
static char buf[255];
img->geom.height *= scale;
}
- if (img->title) /* strip filename to part after last /. */
+ /* xscreensaver-getimage returns paths relative to the image directory
+ now, so leave the sub-directory part in. Unless it's an absolute path.
+ */
+ if (img->title && img->title[0] == '/')
{
+ /* strip filename to part between last "/" and last ".". */
char *s = strrchr (img->title, '/');
if (s) strcpy (img->title, s+1);
+ s = strrchr (img->title, '.');
+ if (s) *s = 0;
}
if (debug_p)
int vp_h = MI_HEIGHT(mi);
int img_w = sp->img->geom.width;
int img_h = sp->img->geom.height;
- int min_w, min_h, max_w, max_h;
+ int min_w, max_w;
double ratio = (double) img_h / img_w;
if (letterbox_p)
{
min_w = img_w;
- min_h = img_h;
}
else
{
if (img_w < vp_w)
- {
- min_w = vp_w;
- min_h = img_h * (float) vp_w / img_w;
- }
+ min_w = vp_w;
else
- {
- min_w = img_w * (float) vp_h / img_h;
- min_h = vp_h;
- }
+ min_w = img_w * (float) vp_h / img_h;
}
max_w = min_w * 100 / zoom;
- max_h = min_h * 100 / zoom;
sp->from.w = min_w + frand ((max_w - min_w) * 0.4);
sp->to.w = max_w - frand ((max_w - min_w) * 0.4);
sp->from = swap;
}
- /* Make sure the aspect ratios are within 0.0001 of each other.
+ /* Make sure the aspect ratios are within 0.001 of each other.
*/
- if ((int) (0.5 + (sp->from.w * 1000 / sp->from.h)) !=
- (int) (0.5 + (sp->to.w * 1000 / sp->to.h)))
- abort();
+ {
+ int r1 = 0.5 + (sp->from.w * 1000 / sp->from.h);
+ int r2 = 0.5 + (sp->to.w * 1000 / sp->to.h);
+ if (r1 < r2-1 || r1 > r2+1)
+ {
+ fprintf (stderr,
+ "%s: botched aspect: %f x %f (%d) vs %f x %f (%d): %s\n",
+ progname,
+ sp->from.w, sp->from.h, r1,
+ sp->to.w, sp->to.h, r2,
+ (sp->img->title ? sp->img->title : "[null]"));
+ abort();
+ }
+ }
sp->from.x /= vp_w;
sp->from.y /= vp_h;
if (do_titles &&
- img->title && *img->title)
+ img->title && *img->title &&
+ (sp->state == IN || sp->state == FULL))
{
- int x = 10;
- int y = mi->xgwa.height - 10;
- glColor4f (0, 0, 0, sp->opacity); /* cheap-assed dropshadow */
- print_gl_string (mi->dpy, ss->xfont, ss->font_dlist,
- mi->xgwa.width, mi->xgwa.height, x, y,
- img->title);
- x++; y++;
glColor4f (1, 1, 1, sp->opacity);
- print_gl_string (mi->dpy, ss->xfont, ss->font_dlist,
- mi->xgwa.width, mi->xgwa.height, x, y,
- img->title);
+ print_texture_label (mi->dpy, ss->font_data,
+ mi->xgwa.width, mi->xgwa.height,
+ 1, img->title);
}
}
glPopMatrix();
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
+
+/*
+ {
+ GLfloat rot = current_device_rotation();
+ glTranslatef (0.5, 0.5, 0);
+ glRotatef(rot, 0, 0, 1);
+ if ((rot > 45 && rot < 135) ||
+ (rot < -45 && rot > -135))
+ {
+ GLfloat s = MI_WIDTH(mi) / (GLfloat) MI_HEIGHT(mi);
+ glScalef (s, 1/s, 1);
+ }
+ glTranslatef (-0.5, -0.5, 0);
+ }
+*/
+
for (i = 0; i < ss->nsprites; i++)
draw_sprite (mi, ss->sprites[i]);
glPopMatrix();
glViewport (0, 0, width, height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
+ glRotatef (current_device_rotation(), 0, 0, 1);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
{
slideshow_state *ss = &sss[MI_SCREEN(mi)];
- if (event->xany.type == ButtonPress &&
- event->xbutton.button == Button1)
- {
- ss->change_now_p = True;
- return True;
- }
- else if (event->xany.type == KeyPress)
- {
- KeySym keysym;
- char c = 0;
- XLookupString (&event->xkey, &c, 1, &keysym, 0);
- if (c == ' ' || c == '\r' || c == '\n' || c == '\t')
- {
- ss->change_now_p = True;
- return True;
- }
- }
- else if (event->xany.type == Expose ||
+ if (event->xany.type == Expose ||
event->xany.type == GraphicsExpose ||
event->xany.type == VisibilityNotify)
{
fprintf (stderr, "%s: exposure\n", blurb());
return False;
}
+ else if (screenhack_event_helper (MI_DISPLAY(mi), MI_WINDOW(mi), event))
+ {
+ ss->change_now_p = True;
+ return True;
+ }
return False;
}
static void
check_fps (ModeInfo *mi)
{
-#ifndef HAVE_COCOA /* always assume Cocoa is fast enough */
+#ifndef HAVE_JWXYZ /* always assume Cocoa and mobile are fast enough */
slideshow_state *ss = &sss[MI_SCREEN(mi)];
/* Need this in case zoom changed. */
reshape_slideshow (mi, mi->xgwa.width, mi->xgwa.height);
-#endif /* HAVE_COCOA */
+#endif /* HAVE_JWXYZ */
}
slideshow_state *ss;
int wire = MI_IS_WIREFRAME(mi);
- if (sss == NULL) {
- if ((sss = (slideshow_state *)
- calloc (MI_NUM_SCREENS(mi), sizeof(slideshow_state))) == NULL)
- return;
- }
+ MI_INIT (mi, sss, NULL);
ss = &sss[screen];
if ((ss->glx_context = init_GL(mi)) != NULL) {
if (debug_p) glLineWidth (3);
- load_font (mi->dpy, "titleFont", &ss->xfont, &ss->font_dlist);
+ ss->font_data = load_texture_font (mi->dpy, "titleFont");
if (debug_p)
hack_resources();
draw_sprites (mi);
- ss->fps = fps_1 (mi);
- if (mi->fps_p) fps_2 (mi);
+ if (mi->fps_p) do_fps (mi);
glFinish();
glXSwapBuffers (MI_DISPLAY (mi), MI_WINDOW(mi));