X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fdnalogo.c;h=075fb55877e9ad3c5e7c2e6fc2a23f4f1a765aee;hp=6d04233e4ef2cc8f1af8d6894b28cfa087ebe4e6;hb=019de959b265701cd0c3fccbb61f2b69f06bf9ee;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe diff --git a/hacks/glx/dnalogo.c b/hacks/glx/dnalogo.c index 6d04233e..075fb558 100644 --- a/hacks/glx/dnalogo.c +++ b/hacks/glx/dnalogo.c @@ -55,6 +55,9 @@ #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... @@ -75,6 +78,12 @@ #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, @@ -1373,6 +1382,8 @@ make_frame (logo_configuration *dc, int wire) /* Make some pizza. */ +#ifdef HAVE_TESS + typedef struct { GLdouble *points; int i; @@ -1423,12 +1434,13 @@ tess_end_cb (void) 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; @@ -1440,18 +1452,19 @@ make_pizza (logo_configuration *dc, int facetted, int wire) 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); @@ -1462,6 +1475,8 @@ make_pizza (logo_configuration *dc, int facetted, int wire) gluTessProperty (tess, GLU_TESS_BOUNDARY_ONLY, wire); gluTessProperty (tess,GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD); +# endif /* HAVE_TESS */ + glPushMatrix(); s = 1.9; @@ -1546,6 +1561,7 @@ make_pizza (logo_configuration *dc, int facetted, int wire) y = p[1]; polys++; } + do_normal (points[0], points[1], -thick2, points[0], points[1], thick2, x, y, thick2); @@ -1556,6 +1572,21 @@ make_pizza (logo_configuration *dc, int facetted, int wire) 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++) @@ -1583,6 +1614,7 @@ make_pizza (logo_configuration *dc, int facetted, int wire) 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++) { @@ -1599,8 +1631,23 @@ make_pizza (logo_configuration *dc, int facetted, int wire) 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++) { @@ -1640,8 +1687,32 @@ make_pizza (logo_configuration *dc, int facetted, int wire) 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 */ @@ -1748,10 +1819,13 @@ make_pizza (logo_configuration *dc, int facetted, int wire) glEnd(); } +# ifdef HAVE_TESS gluDeleteTess (tess); + free (to->points); +# endif /* HAVE_TESS */ + free (points); free (holes); - free (to->points); glPopMatrix(); @@ -2150,8 +2224,6 @@ draw_logo (ModeInfo *mi) 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) @@ -2170,6 +2242,28 @@ draw_logo (ModeInfo *mi) 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: @@ -2232,9 +2326,13 @@ draw_logo (ModeInfo *mi) 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]); @@ -2253,6 +2351,7 @@ draw_logo (ModeInfo *mi) glScalef (1, scale, scale); if (wire) { + glDisable (GL_LIGHTING); glCallList (dc->frame_list_wire); mi->polygon_count += dc->polys[6]; } @@ -2260,6 +2359,7 @@ draw_logo (ModeInfo *mi) { 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); @@ -2277,14 +2377,20 @@ draw_logo (ModeInfo *mi) 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) @@ -2299,6 +2405,7 @@ draw_logo (ModeInfo *mi) if (wire) { + glDisable (GL_LIGHTING); glCallList (dc->gasket_list_wire); mi->polygon_count += dc->polys[4]; } @@ -2306,9 +2413,11 @@ draw_logo (ModeInfo *mi) { 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 { @@ -2320,12 +2429,12 @@ draw_logo (ModeInfo *mi) 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) @@ -2338,6 +2447,7 @@ draw_logo (ModeInfo *mi) if (wire) { + glDisable (GL_LIGHTING); if (pizza_p) glCallList (dc->pizza_list_wire); else @@ -2352,6 +2462,7 @@ draw_logo (ModeInfo *mi) glCallList (dc->helix_list_facetted); glDisable (GL_LIGHTING); + glColor3fv (dc->color); if (pizza_p) glCallList (dc->pizza_list_wire); @@ -2381,6 +2492,6 @@ draw_logo (ModeInfo *mi) glXSwapBuffers(dpy, window); } -XSCREENSAVER_MODULE_2 ("DNAlogo", dnalogo, logo) +XSCREENSAVER_MODULE_2 ("DNALogo", dnalogo, logo) #endif /* USE_GL */