#undef countof
#define countof(x) (sizeof((x))/sizeof((*x)))
+#undef LINEAR
+#undef DXF_OUTPUT_HACK
+
#ifdef DXF_OUTPUT_HACK /* When this is defined, instead of rendering
to the screen, we write a DXF CAD file to stdout.
This is a kludge of shocking magnitude...
#ifdef USE_GL /* whole file */
+#ifdef HAVE_JWZGLES
+# include "dnapizza.h"
+#else
+# define HAVE_TESS
+#endif
+
typedef enum {
HELIX_IN, HELIX, HELIX_OUT,
PIZZA_IN, PIZZA, PIZZA_OUT,
/* Make some pizza.
*/
+#ifdef HAVE_TESS
+
typedef struct {
GLdouble *points;
int i;
glEnd();
}
+#endif /* HAVE_TESS */
+
static int
make_pizza (logo_configuration *dc, int facetted, int wire)
{
int polys = 0;
-
int topfaces = (facetted ? 48 : 120);
int discfaces = (facetted ? 12 : 120);
int npoints = topfaces * 2 + 100;
GLfloat thick2 = (dc->gasket_thickness / dc->gasket_size) / 4;
GLfloat th, x, y, s;
int i, j, k;
- tess_out TO, *to = &TO;
- GLUtesselator *tess = gluNewTess();
int endpoints;
int endedge1;
+# ifdef HAVE_TESS
+ tess_out TO, *to = &TO;
+ GLUtesselator *tess = gluNewTess();
+
to->points = (GLdouble *) calloc (topfaces * 20, sizeof(GLdouble));
to->i = 0;
-
-# ifndef _GLUfuncptr
-# define _GLUfuncptr void(*)(void)
-# endif
+# ifndef _GLUfuncptr
+# define _GLUfuncptr void(*)(void)
+# endif
gluTessCallback(tess,GLU_TESS_BEGIN, (_GLUfuncptr)tess_begin_cb);
gluTessCallback(tess,GLU_TESS_VERTEX, (_GLUfuncptr)glVertex3dv);
gluTessProperty (tess, GLU_TESS_BOUNDARY_ONLY, wire);
gluTessProperty (tess,GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
+# endif /* HAVE_TESS */
+
glPushMatrix();
s = 1.9;
y = p[1];
polys++;
}
+
do_normal (points[0], points[1], -thick2,
points[0], points[1], thick2,
x, y, thick2);
polys++;
glEnd();
+# ifndef HAVE_TESS
+ if (wire)
+ {
+ /* Outline of slice */
+ glBegin (GL_LINE_LOOP);
+ for (i = 0; i < endpoints; i++)
+ glVertex3f (points[i*3], points[i*3+1], -thick2);
+ glEnd();
+ glBegin (GL_LINE_LOOP);
+ for (i = 0; i < endpoints; i++)
+ glVertex3f (points[i*3], points[i*3+1], thick2);
+ glEnd();
+ }
+# endif /* HAVE_TESS */
+
/* Compute the holes */
step = M_PI * 2 / discfaces;
for (k = 0; k < nholes; k++)
for (k = 0; k < nholes; k++)
{
GLdouble *p = holes + (discfaces * 3 * k);
+
glBegin (wire ? GL_LINES : GL_QUAD_STRIP);
for (i = 0; i < discfaces; i++)
{
glVertex3f (p[0], p[1], thick2);
polys++;
glEnd();
+# ifndef HAVE_TESS
+ if (wire)
+ {
+ /* Outline of holes */
+ glBegin (GL_LINE_LOOP);
+ for (i = 0; i < discfaces; i++)
+ glVertex3f (p[i*3], p[i*3+1], -thick2);
+ glEnd();
+ glBegin (GL_LINE_LOOP);
+ for (i = 0; i < discfaces; i++)
+ glVertex3f (p[i*3], p[i*3+1], thick2);
+ glEnd();
+ }
+# endif /* !HAVE_TESS */
}
+# ifdef HAVE_TESS
glTranslatef (0, 0, -thick2);
for (y = 0; y <= 1; y++)
{
gluTessEndPolygon (tess);
}
+
glTranslatef (0, 0, -thick2);
+# else /* !HAVE_TESS */
+ if (! wire)
+ {
+ glDisableClientState (GL_COLOR_ARRAY);
+ glDisableClientState (GL_NORMAL_ARRAY);
+ glDisableClientState (GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState (GL_VERTEX_ARRAY);
+ glVertexPointer (3, GL_FLOAT, 0, dnapizza_triangles);
+
+ glTranslatef(0, 0, thick2);
+ glNormal3f (0, 0, 1);
+ glFrontFace (GL_CW);
+ glDrawArrays (GL_TRIANGLES, 0, countof (dnapizza_triangles) / 3);
+
+ glTranslatef(0, 0, -thick2*2);
+ glNormal3f (0, 0, -1);
+ glFrontFace (GL_CCW);
+ glDrawArrays (GL_TRIANGLES, 0, countof (dnapizza_triangles) / 3);
+
+ glTranslatef(0, 0, thick2);
+ }
+# endif /* !HAVE_TESS */
+
/* Compute the crust */
glEnd();
}
+# ifdef HAVE_TESS
gluDeleteTess (tess);
+ free (to->points);
+# endif /* HAVE_TESS */
+
free (points);
free (holes);
- free (to->points);
glPopMatrix();
mi->polygon_count = 0;
glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(dc->glx_context));
- glRotatef(current_device_rotation(), 0, 0, 1);
-
if (!wire &&
dc->wire_overlay == 0 &&
(random() % (int) (PROBABILITY_SCALE / 0.2)) == 0)
tick_spinner (mi, &dc->frame_spinner);
link_spinners (mi, &dc->scene_spinnerx, &dc->scene_spinnery);
+# ifdef LINEAR
+ {
+ static double i = 0.0;
+ dc->anim_state = HELIX;
+ dc->wire_overlay = 0;
+ dc->gasket_spinnerx.spinning_p = 0;
+ dc->gasket_spinnery.spinning_p = 0;
+ dc->gasket_spinnerz.spinning_p = 0;
+ dc->helix_spinnerz.spinning_p = 0;
+ dc->pizza_spinnery.spinning_p = 0;
+ dc->pizza_spinnerz.spinning_p = 0;
+ dc->scene_spinnerx.spinning_p = 0;
+ dc->scene_spinnery.spinning_p = 0;
+ dc->frame_spinner.spinning_p = 0;
+ dc->frame_spinner.position = 0.3;
+ dc->gasket_spinnerz.position = i;
+ dc->helix_spinnerz.position = i;
+ i += 0.005;
+ if (i > 1) i = 0;
+ }
+# endif /* LINEAR */
+
switch (dc->anim_state)
{
case HELIX:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix ();
+ glRotatef(current_device_rotation(), 0, 0, 1);
{
- GLfloat scale = 0;
- glScalef(3, 3, 3);
+ GLfloat scale = 1.8;
+# ifdef LINEAR
+ scale = 3.85;
+# endif
+ glScalef(scale, scale, scale);
glColor3f(dc->color[0], dc->color[1], dc->color[2]);
glScalef (1, scale, scale);
if (wire)
{
+ glDisable (GL_LIGHTING);
glCallList (dc->frame_list_wire);
mi->polygon_count += dc->polys[6];
}
{
glCallList (dc->frame_list);
glDisable (GL_LIGHTING);
+ glColor3fv (dc->color);
glCallList (dc->frame_list_wire);
mi->polygon_count += dc->polys[6];
if (!wire) glEnable (GL_LIGHTING);
glRotatef(90, 1, 0, 0);
glRotatef(90, 0, 0, 1);
- glRotatef (360 * sin (M_PI/2 * dc->scene_spinnerx.position), 0, 1, 0);
- glRotatef (360 * sin (M_PI/2 * dc->scene_spinnery.position), 0, 0, 1);
+# ifdef LINEAR
+# define SINIFY(I) (I)
+# else
+# define SINIFY(I) sin (M_PI/2 * (I))
+# endif
+
+ glRotatef (360 * SINIFY (dc->scene_spinnerx.position), 0, 1, 0);
+ glRotatef (360 * SINIFY (dc->scene_spinnery.position), 0, 0, 1);
glPushMatrix();
{
- glRotatef (360 * sin (M_PI/2 * dc->gasket_spinnerx.position), 0, 1, 0);
- glRotatef (360 * sin (M_PI/2 * dc->gasket_spinnery.position), 0, 0, 1);
- glRotatef (360 * sin (M_PI/2 * dc->gasket_spinnerz.position), 1, 0, 0);
+ glRotatef (360 * SINIFY (dc->gasket_spinnerx.position), 0, 1, 0);
+ glRotatef (360 * SINIFY (dc->gasket_spinnery.position), 0, 0, 1);
+ glRotatef (360 * SINIFY (dc->gasket_spinnerz.position), 1, 0, 0);
memcpy (gcolor, dc->color, sizeof (dc->color));
if (dc->wire_overlay != 0)
if (wire)
{
+ glDisable (GL_LIGHTING);
glCallList (dc->gasket_list_wire);
mi->polygon_count += dc->polys[4];
}
{
glCallList (dc->gasket_list);
glDisable (GL_LIGHTING);
+ glColor3fv (dc->color);
glCallList (dc->gasket_list_wire);
mi->polygon_count += dc->polys[4];
if (!wire) glEnable (GL_LIGHTING);
+ glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, gcolor);
}
else
{
if (pizza_p)
{
- glRotatef (360 * sin (M_PI/2 * dc->pizza_spinnery.position), 1, 0, 0);
- glRotatef (360 * sin (M_PI/2 * dc->pizza_spinnerz.position), 0, 0, 1);
+ glRotatef (360 * SINIFY (dc->pizza_spinnery.position), 1, 0, 0);
+ glRotatef (360 * SINIFY (dc->pizza_spinnerz.position), 0, 0, 1);
}
else
{
- glRotatef (360 * sin (M_PI/2 * dc->helix_spinnerz.position), 0, 0, 1);
+ glRotatef (360 * SINIFY (dc->helix_spinnerz.position), 0, 0, 1);
}
scale = ((dc->anim_state == PIZZA_IN || dc->anim_state == HELIX_IN)
if (wire)
{
+ glDisable (GL_LIGHTING);
if (pizza_p)
glCallList (dc->pizza_list_wire);
else
glCallList (dc->helix_list_facetted);
glDisable (GL_LIGHTING);
+ glColor3fv (dc->color);
if (pizza_p)
glCallList (dc->pizza_list_wire);
glXSwapBuffers(dpy, window);
}
-XSCREENSAVER_MODULE_2 ("DNAlogo", dnalogo, logo)
+XSCREENSAVER_MODULE_2 ("DNALogo", dnalogo, logo)
#endif /* USE_GL */