+
+ GLfloat texw = frame->current.geom.width / (GLfloat) frame->current.tw;
+ GLfloat texh = frame->current.geom.height / (GLfloat) frame->current.th;
+ GLfloat texx1 = frame->current.geom.x / (GLfloat) frame->current.tw;
+ GLfloat texy1 = frame->current.geom.y / (GLfloat) frame->current.th;
+ GLfloat texx2 = texx1 + texw;
+ GLfloat texy2 = texy1 + texh;
+ GLfloat aspect = ((GLfloat) frame->current.geom.height /
+ (GLfloat) frame->current.geom.width);
+
+ glBindTexture (GL_TEXTURE_2D, frame->current.texid);
+
+ glPushMatrix();
+
+ /* Position this image on the wheel.
+ */
+ glRotatef (frame->theta, 0, 1, 0);
+ glTranslatef (0, 0, frame->r);
+
+ /* Scale down the image so that all N frames fit on the wheel
+ without bumping in to each other.
+ */
+ {
+ GLfloat t, s;
+ switch (ss->nframes)
+ {
+ case 1: t = -1.0; s = 1.7; break;
+ case 2: t = -0.8; s = 1.6; break;
+ case 3: t = -0.4; s = 1.5; break;
+ case 4: t = -0.2; s = 1.3; break;
+ default: t = 0.0; s = 6.0 / ss->nframes; break;
+ }
+ glTranslatef (0, 0, t);
+ glScalef (s, s, s);
+ }
+
+ /* Center this image on the wheel plane.
+ */
+ glTranslatef (-0.5, -(aspect/2), 0);
+
+ /* Move as per the "zoom in and out" setting.
+ */
+ if (zoom_p)
+ {
+ double x, y, z;
+ /* Only use the Z component of the rotator for in/out position. */
+ get_position (frame->rot, &x, &y, &z, !ss->button_down_p);
+ glTranslatef (0, 0, z/2);
+ }
+
+ /* Compute the "drop in and out" state.
+ */
+ switch (frame->mode)
+ {
+ case EARLY:
+ abort();
+ break;
+ case NORMAL:
+ if (!ss->button_down_p &&
+ now >= frame->expires &&
+ ss->loads_in_progress == 0) /* only load one at a time */
+ load_image (mi, frame);
+ break;
+ case LOADING:
+ break;
+ case OUT:
+ if (--frame->mode_tick <= 0) {
+ image swap = frame->current;
+ frame->current = frame->loading;
+ frame->loading = swap;
+
+ frame->mode = IN;
+ frame->mode_tick = fade_ticks / speed;
+ }
+ break;
+ case IN:
+ if (--frame->mode_tick <= 0)
+ frame->mode = NORMAL;
+ break;
+ default:
+ abort();
+ }
+
+ /* Now translate for current in/out state.
+ */
+ if (frame->mode == OUT || frame->mode == IN)
+ {
+ GLfloat t = (frame->mode == OUT
+ ? frame->mode_tick / (fade_ticks / speed)
+ : (((fade_ticks / speed) - frame->mode_tick + 1) /
+ (fade_ticks / speed)));
+ t = 5 * (1 - t);
+ if (frame->from_top_p) t = -t;
+ glTranslatef (0, t, 0);
+ }
+
+ if (body_p) /* Draw the image quad. */
+ {
+ if (! wire)
+ {
+ glColor3f (1, 1, 1);
+ glNormal3f (0, 0, 1);
+ glEnable (GL_TEXTURE_2D);
+ glBegin (GL_QUADS);
+ glNormal3f (0, 0, 1);
+ glTexCoord2f (texx1, texy2); glVertex3f (0, 0, 0);
+ glTexCoord2f (texx2, texy2); glVertex3f (1, 0, 0);
+ glTexCoord2f (texx2, texy1); glVertex3f (1, aspect, 0);
+ glTexCoord2f (texx1, texy1); glVertex3f (0, aspect, 0);
+ glEnd();
+ }
+
+ /* Draw a box around it.
+ */
+ glLineWidth (2.0);
+ glColor3f (0.5, 0.5, 0.5);
+ glDisable (GL_TEXTURE_2D);
+ glBegin (GL_LINE_LOOP);
+ glVertex3f (0, 0, 0);
+ glVertex3f (1, 0, 0);
+ glVertex3f (1, aspect, 0);
+ glVertex3f (0, aspect, 0);
+ glEnd();
+
+ }
+ else /* Draw a title under the image. */
+ {
+ XCharStruct e;
+ int sw, sh;
+ GLfloat scale = 0.05;
+ char *title = frame->current.title ? frame->current.title : "(untitled)";
+ texture_string_metrics (ss->texfont, title, &e, 0, 0);
+ sw = e.width;
+ sh = e.ascent + e.descent;
+
+ glTranslatef (0, -scale, 0);
+
+ scale /= sh;
+ glScalef (scale, scale, scale);
+
+ glTranslatef (((1/scale) - sw) / 2, 0, 0);
+ glColor3f (1, 1, 1);
+
+ if (!wire)
+ {
+ glEnable (GL_TEXTURE_2D);
+ print_texture_string (ss->texfont, title);
+ }
+ else
+ {
+ glBegin (GL_LINE_LOOP);
+ glVertex3f (0, 0, 0);
+ glVertex3f (sw, 0, 0);
+ glVertex3f (sw, sh, 0);
+ glVertex3f (0, sh, 0);
+ glEnd();
+ }
+ }
+
+ glPopMatrix();
+}
+
+
+ENTRYPOINT void
+draw_carousel (ModeInfo *mi)
+{
+ carousel_state *ss = &sss[MI_SCREEN(mi)];