-/* photopile, Copyright (c) 2008-2011 Jens Kilian <jjk@acm.org>
+/* photopile, Copyright (c) 2008-2012 Jens Kilian <jjk@acm.org>
* Based on carousel, Copyright (c) 2005-2008 Jamie Zawinski <jwz@jwz.org>
* Loads a sequence of images and shuffles them into a pile.
*
} image;
-typedef enum { EARLY, IN, NORMAL, LOADING, SHUFFLE } fade_mode;
+typedef enum { EARLY, SHUFFLE, NORMAL, LOADING } fade_mode;
static int fade_ticks = 60;
typedef struct {
static Bool mipmap_p; /* Use mipmaps instead of single textures. */
static Bool titles_p; /* Display image titles. */
static Bool polaroid_p; /* Use instant-film look for images. */
-static Bool clip_p; /* Clip images instead of scaling for -polaroid. */static Bool shadows_p; /* Draw drop shadows. */
+static Bool clip_p; /* Clip images instead of scaling for -polaroid. */
+static Bool shadows_p; /* Draw drop shadows. */
static Bool debug_p; /* Be loud and do weird things. */
for (i = 0; i < MI_COUNT(mi)+1; ++i)
{
image *frame = ss->frames + i;
- GLfloat d = sqrt(frame->w*frame->w + frame->h*frame->h);
+ GLfloat w = frame->w;
+ GLfloat h = frame->h;
+ GLfloat d = sqrt(w*w + h*h);
GLfloat leave = frand(M_PI * 2.0);
GLfloat enter = frand(M_PI * 2.0);
frame->pos[3].y = BELLRAND(MI_HEIGHT(mi));
frame->pos[3].angle = (frand(2.0) - 1.0) * max_tilt;
+ /* Try to keep the images mostly inside the screen bounds */
+ frame->pos[3].x = MAX(0.5*w, MIN(MI_WIDTH(mi)-0.5*w, frame->pos[3].x));
+ frame->pos[3].y = MAX(0.5*h, MIN(MI_HEIGHT(mi)-0.5*h, frame->pos[3].y));
+
/* intermediate points */
frame->pos[1] = offset_pos(frame->pos[0], leave, d * (0.5 + frand(1.0)));
frame->pos[2] = offset_pos(frame->pos[3], enter, d * (0.5 + frand(1.0)));
free (frame->title);
frame->title = (filename ? strdup (filename) : 0);
-# if 0 /* xscreensaver-getimage returns paths relative to the image directory
- now, so leave the sub-directory part in.
- */
- if (frame->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 (frame->title && frame->title[0] == '/')
{
+ /* strip filename to part after last /. */
char *s = strrchr (frame->title, '/');
if (s) strcpy (frame->title, s+1);
}
-# endif /* 0 */
if (debug_p)
fprintf (stderr, "%s: loaded %4d x %-4d %4d x %-4d \"%s\"\n",
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
- gluOrtho2D(0, MI_WIDTH(mi), 0, MI_HEIGHT(mi));
+ glOrtho(0, MI_WIDTH(mi), 0, MI_HEIGHT(mi), -1, 1);
glTranslatef ((MI_WIDTH(mi) - ss->loading_sw) / 2,
(MI_HEIGHT(mi) - ss->loading_sh) / 2,
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- gluOrtho2D(0, MI_WIDTH(mi), 0, MI_HEIGHT(mi));
+ glOrtho(0, MI_WIDTH(mi), 0, MI_HEIGHT(mi), -1, 1);
glClear(GL_COLOR_BUFFER_BIT);
}
MI_CLEARWINDOW(mi);
}
- glDisable (GL_LIGHTING);
- glEnable (GL_DEPTH_TEST);
- glDisable (GL_CULL_FACE);
-
- if (! wire)
- {
- glShadeModel (GL_SMOOTH);
- glEnable (GL_LINE_SMOOTH);
- glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
- glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- }
-
ss->shadow = init_drop_shadow();
ss->texfont = load_texture_font (MI_DISPLAY(mi), "font");
{
glColor3f (0, 0, 0);
draw_drop_shadow(ss->shadow, -w1, -h1, z2, 2.0 * w1, h1 + h2, 20.0);
+ glDisable (GL_BLEND);
}
+ glDisable (GL_LIGHTING);
+ glEnable (GL_DEPTH_TEST);
+ glDisable (GL_CULL_FACE);
+
/* Draw the retro instant-film frame.
*/
if (polaroid_p)
{
if (! wire)
{
+ glShadeModel (GL_SMOOTH);
+ glEnable (GL_LINE_SMOOTH);
+ glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
+
glColor3f (1, 1, 1);
glBegin (GL_QUADS);
glVertex3f (-w1, -h1, z2);
glEnd();
}
- glLineWidth (2.0);
+ glLineWidth (1.0);
glColor3f (0.5, 0.5, 0.5);
glBegin (GL_LINE_LOOP);
glVertex3f (-w1, -h1, z);
/* Draw a box around it.
*/
- glLineWidth (2.0);
+ if (! wire)
+ {
+ glShadeModel (GL_SMOOTH);
+ glEnable (GL_LINE_SMOOTH);
+ glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
+ }
+ glLineWidth (1.0);
glColor3f (0.5, 0.5, 0.5);
glBegin (GL_LINE_LOOP);
glVertex3f (-w, -h, z);
if (!wire)
{
glEnable (GL_TEXTURE_2D);
+ glEnable (GL_BLEND);
print_texture_string (ss->texfont, title);
- glDisable (GL_TEXTURE_2D);
}
else
{
{
GLfloat t;
+ glPushMatrix();
+ glTranslatef (MI_WIDTH(mi)/2, MI_HEIGHT(mi)/2, 0);
+ glRotatef(current_device_rotation(), 0, 0, 1);
+ glTranslatef (-MI_WIDTH(mi)/2, -MI_HEIGHT(mi)/2, 0);
+
/* Handle state transitions. */
switch (ss->mode)
{
- case IN:
+ case SHUFFLE:
if (--ss->mode_tick <= 0)
{
+ ss->nframe = (ss->nframe+1) % (MI_COUNT(mi)+1);
+
ss->mode = NORMAL;
ss->last_time = time((time_t *) 0);
}
ss->mode_tick = fade_ticks / speed;
}
break;
- case SHUFFLE:
- if (--ss->mode_tick <= 0)
- {
- ss->nframe = (ss->nframe+1) % (MI_COUNT(mi)+1);
-
- ss->mode = NORMAL;
- ss->last_time = time((time_t *) 0);
- }
- break;
default:
abort();
}
switch (ss->mode)
{
- case IN:
- s *= t;
- break;
- case NORMAL:
- case LOADING:
- t = 1.0;
- break;
case SHUFFLE:
if (i == MI_COUNT(mi))
{
s *= 1.0 - t;
}
break;
+ case NORMAL:
+ case LOADING:
+ t = 1.0;
+ break;
default:
abort();
}
draw_image(mi, j, t, s, z);
}
}
+ glPopMatrix();
}
if (mi->fps_p) do_fps (mi);