#define DEFAULTS "*delay: 30000 \n" \
"*showFPS: False \n" \
"*wireframe: False \n" \
- "*titleFont: -*-helvetica-medium-r-normal-*-140-*\n" \
- "*titleFont2: -*-helvetica-medium-r-normal-*-100-*\n" \
- "*titleFont3: -*-helvetica-medium-r-normal-*-80-*\n" \
+ "*titleFont: sans-serif 14\n" \
+ "*titleFont2: sans-serif 10\n" \
+ "*titleFont3: sans-serif 8\n" \
+ "*suppressRotationAnimation: True\n" \
-# define refresh_polyhedra 0
# define release_polyhedra 0
-#undef countof
-#define countof(x) (sizeof((x))/sizeof((*x)))
#include "xlockmore.h"
-
-#ifdef HAVE_COCOA
-# include "jwxyz.h"
-#else
-# include <X11/Xlib.h>
-# include <GL/gl.h>
-# include <GL/glu.h>
-#endif
-
-#ifdef HAVE_JWZGLES
-# include "jwzgles.h"
-#endif /* HAVE_JWZGLES */
+#include "texfont.h"
+#include "normals.h"
+#include "polyhedra.h"
+#include "colors.h"
+#include "rotator.h"
+#include "gltrackball.h"
+#include "teapot.h"
#define DEF_SPIN "True"
#define DEF_WANDER "True"
#define DEF_DURATION "12"
#define DEF_WHICH "random"
-#include "glxfonts.h"
-#include "normals.h"
-#include "polyhedra.h"
-#include "colors.h"
-#include "rotator.h"
-#include "gltrackball.h"
-#include "teapot.h"
-
-#ifndef HAVE_COCOA
+#ifndef HAVE_JWXYZ
# define XK_MISCELLANY
# include <X11/keysymdef.h>
#endif
int which;
int change_to;
GLuint object_list;
- GLuint title_list;
int mode; /* 0 = normal, 1 = out, 2 = in */
int mode_tick;
texture_font_data *f = bp->font1_data;
glColor3f (0.8, 0.8, 0);
- print_gl_string (mi->dpy, bp->font1_data,
- mi->xgwa.width, mi->xgwa.height,
- mi->xgwa.width - (
- texture_string_width (f, s, 0)
- + 40),
- mi->xgwa.height - 10,
- s, False);
+ print_texture_label (mi->dpy, f,
+ mi->xgwa.width, mi->xgwa.height,
+ 0, s);
glFinish();
glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi));
}
/* Window management, etc
*/
-static void new_label (ModeInfo *mi);
-
ENTRYPOINT void
reshape_polyhedra (ModeInfo *mi, int width, int height)
{
GLfloat h = (GLfloat) height / (GLfloat) width;
+ int y = 0;
+
+ if (width > height * 5) { /* tiny window: show middle */
+ height = width * 9/16;
+ y = -height/2;
+ h = height / (GLfloat) width;
+ }
- glViewport (0, 0, (GLint) width, (GLint) height);
+ glViewport (0, y, (GLint) width, (GLint) height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
0.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
-
- /* need to re-render the text when the window size changes */
- new_label (mi);
}
static void
-new_label (ModeInfo *mi)
+draw_label (ModeInfo *mi)
{
polyhedra_configuration *bp = &bps[MI_SCREEN(mi)];
polyhedron *p = bp->which >= 0 ? bp->polyhedra[bp->which] : 0;
+ char label[1024];
+ char name2[255];
+ GLfloat color[4] = { 0.8, 0.8, 0.8, 1 };
+ texture_font_data *f;
+
+ if (!p || !do_titles) return;
+
+ strcpy (name2, p->name);
+ if (*p->class)
+ sprintf (name2 + strlen(name2), " (%s)", p->class);
+
+ sprintf (label,
+ "Polyhedron %d: \t%s\n\n"
+ "Wythoff Symbol:\t%s\n"
+ "Vertex Configuration:\t%s\n"
+ "Symmetry Group:\t%s\n"
+ /* "Dual of: \t%s\n" */
+ "\n"
+ "Faces:\t %d\n"
+ "Edges:\t %d\n"
+ "Vertices:\t %d\n"
+ "Density:\t %d\n"
+ "Euler:\t%s%d\n",
+ bp->which, name2, p->wythoff, p->config, p->group,
+ /* p->dual, */
+ p->logical_faces, p->nedges, p->logical_vertices,
+ p->density, (p->chi < 0 ? "" : " "), p->chi);
+
+ if (MI_WIDTH(mi) >= 500 && MI_HEIGHT(mi) >= 375)
+ f = bp->font1_data;
+ else if (MI_WIDTH(mi) >= 350 && MI_HEIGHT(mi) >= 260)
+ f = bp->font2_data; /* small font */
+ else
+ f = bp->font3_data; /* tiny font */
- glNewList (bp->title_list, GL_COMPILE);
- if (p && do_titles)
- {
- char label[1024];
- char name2[255];
- strcpy (name2, p->name);
- if (*p->class)
- sprintf (name2 + strlen(name2), " (%s)", p->class);
-
- sprintf (label,
- "Polyhedron %d: \t%s\n\n"
- "Wythoff Symbol:\t%s\n"
- "Vertex Configuration:\t%s\n"
- "Symmetry Group:\t%s\n"
- /* "Dual of: \t%s\n" */
- "\n"
- "Faces:\t %d\n"
- "Edges:\t %d\n"
- "Vertices:\t %d\n"
- "Density:\t %d\n"
- "Euler:\t%s%d\n",
- bp->which, name2, p->wythoff, p->config, p->group,
- /* p->dual, */
- p->logical_faces, p->nedges, p->logical_vertices,
- p->density, (p->chi < 0 ? "" : " "), p->chi);
-
- {
- GLfloat color[4] = { 0.8, 0.8, 0.8, 1 };
- texture_font_data *f;
- if (MI_WIDTH(mi) >= 500 && MI_HEIGHT(mi) >= 375)
- f = bp->font1_data;
- else if (MI_WIDTH(mi) >= 350 && MI_HEIGHT(mi) >= 260)
- f = bp->font2_data; /* small font */
- else
- f = bp->font3_data; /* tiny font */
-
- glColor4fv (color);
- glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
- print_gl_string (mi->dpy, f,
- mi->xgwa.width, mi->xgwa.height,
- 10, mi->xgwa.height - 10,
- label, False);
- }
- }
- glEndList ();
+ glColor4fv (color);
+ glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
+ print_texture_label (mi->dpy, f,
+ mi->xgwa.width, mi->xgwa.height,
+ 1, label);
}
bp->change_to = -1;
p = bp->polyhedra[bp->which];
- new_label (mi);
-
if (wire)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
wire = 0;
# endif
- if (!bps) {
- bps = (polyhedra_configuration *)
- calloc (MI_NUM_SCREENS(mi), sizeof (polyhedra_configuration));
- if (!bps) {
- fprintf(stderr, "%s: out of memory\n", progname);
- exit(1);
- }
- }
+ MI_INIT (mi, bps);
bp = &bps[MI_SCREEN(mi)];
construct_teapot (mi);
bp->object_list = glGenLists (1);
- bp->title_list = glGenLists (1);
bp->change_to = -1;
{
if (!bp->glx_context)
return;
- glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *bp->glx_context);
if (bp->mode == 0 && do_which >= 0 && bp->change_to < 0)
;
if (!bp->button_down_p && now - bp->last_change_time >= duration)
{
bp->mode = 1; /* go out */
- bp->mode_tick = 20 * speed;
+ bp->mode_tick = 20 / speed;
bp->last_change_time = now;
}
}
if (--bp->mode_tick <= 0)
{
new_polyhedron (mi);
- bp->mode_tick = 20 * speed;
+ bp->mode_tick = 20 / speed;
bp->mode = 2; /* go in */
}
}
glPushMatrix ();
+ {
+ GLfloat s = (MI_WIDTH(mi) < MI_HEIGHT(mi)
+ ? (MI_WIDTH(mi) / (GLfloat) MI_HEIGHT(mi))
+ : 1);
+ glScalef (s, s, s);
+ }
+
glScalef(1.1, 1.1, 1.1);
{
if (bp->mode != 0)
{
GLfloat s = (bp->mode == 1
- ? bp->mode_tick / (20 * speed)
- : ((20 * speed) - bp->mode_tick + 1) / (20 * speed));
+ ? bp->mode_tick / (20 / speed)
+ : ((20 / speed) - bp->mode_tick + 1) / (20 / speed));
glScalef (s, s, s);
}
glScalef (2, 2, 2);
glCallList (bp->object_list);
if (bp->mode == 0 && !bp->button_down_p)
- glCallList (bp->title_list);
+ draw_label (mi); /* print_texture_font can't go inside a display list */
glPopMatrix ();
glXSwapBuffers(dpy, window);
}
+
+ENTRYPOINT void
+free_polyhedra (ModeInfo *mi)
+{
+ polyhedra_configuration *bp = &bps[MI_SCREEN(mi)];
+ int i;
+
+ if (!bp->glx_context) return;
+ glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *bp->glx_context);
+
+ for (i = 0; i < bp->npolyhedra; i++)
+ free_polyhedron (bp->polyhedra[i]);
+ if (bp->trackball) gltrackball_free (bp->trackball);
+ if (bp->rot) free_rotator (bp->rot);
+ if (bp->colors) free (bp->colors);
+ if (bp->font1_data) free_texture_font (bp->font1_data);
+ if (bp->font2_data) free_texture_font (bp->font2_data);
+ if (bp->font3_data) free_texture_font (bp->font3_data);
+ if (glIsList(bp->object_list)) glDeleteLists(bp->object_list, 1);
+}
+
XSCREENSAVER_MODULE ("Polyhedra", polyhedra)
#endif /* USE_GL */