~ubuntu-branches/ubuntu/quantal/xscreensaver/quantal

« back to all changes in this revision

Viewing changes to hacks/glx/dnalogo.c

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2008-08-28 16:15:25 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080828161525-mxga521aoezxjq8h
Tags: 5.07-0ubuntu1
* Upgrade upstream version
* debian/control: Remove suggest xdaliclock as it is no longer
  included
* Remove 10_jwz-screensaver-randr-patch-3.patch as it has been merged
  upstream.
* Add 24_hacks_xsublim_enable.patch as it seems that xsublim was dropped
  from the build files.  There is nothing in the Changelog about it
  so I believe it was accidental.
* Updating the .desktop files from the XML files using gnome-screensaver's
  utility to do so.  Lots of text updates.  Also:
    * Added: abstractile.desktop
    * Added: cwaves.desktop
    * Added: m6502.desktop
    * Added: skytentacles.desktop
    * Removed: xteevee.desktop
* xscreensaver-gl-extra.files: Added skytentacles
* xscreensaver-data-extra.files: Added abstractile, cwaves and m6502
* xscreensaver-data.files: Remove partial abstractile, m6502 and cwaves

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
                        "*doGasket:         True    \n" \
17
17
                        "*doHelix:          True    \n" \
18
18
                        "*doLadder:         True    \n" \
 
19
                        "*doFrame:          True    \n" \
19
20
                        "*wallFacets:       360     \n" \
20
 
                        "*tubeFacets:       90      \n" \
 
21
                        "*barFacets:        90      \n" \
21
22
                        "*clockwise:        False   \n" \
22
 
                        "*turns:            0.8     \n" \
23
 
                        "*turnSpacing:      2.40    \n" \
24
 
                        "*barSpacing:       0.30    \n" \
25
 
                        "*wallHeight:       0.4     \n" \
26
 
                        "*wallThickness:    0.1     \n" \
27
 
                        "*tubeThickness:    0.075   \n" \
28
 
                        "*wallTaper:        1.047   \n" \
29
 
                        "*gasketSize:       2.15    \n" \
 
23
                        "*turns:            0.69    \n" \
 
24
                        "*turnSpacing:      2.2     \n" \
 
25
                        "*barSpacing:       0.24    \n" \
 
26
                        "*wallHeight:       0.45    \n" \
 
27
                        "*wallThickness:    0.12    \n" \
 
28
                        "*barThickness:     0.058   \n" \
 
29
                        "*wallTaper:        0.95    \n" \
 
30
                        "*gasketSize:       1.88    \n" \
30
31
                        "*gasketDepth:      0.15    \n" \
31
32
                        "*gasketThickness:  0.4     \n" \
 
33
                        "*frameSize:        1.20    \n" \
 
34
                        "*frameDepth:       0.01    \n" \
 
35
                        "*frameThickness:   0.03    \n" \
 
36
                        "*triangleSize:     0.045   \n" \
32
37
                        "*speed:            1.0     \n" \
33
38
                        ".foreground:       #00AA00 \n" \
 
39
                        "*geometry:         =640x640\n" \
34
40
 
35
41
# define refresh_logo 0
36
42
# define release_logo 0
57
63
 
58
64
  GLuint helix_list,  helix_list_wire,  helix_list_facetted;
59
65
  GLuint gasket_list, gasket_list_wire;
 
66
  GLuint frame_list,  frame_list_wire;
 
67
  int polys[7];
60
68
 
61
69
  int wall_facets;
62
 
  int tube_facets;
 
70
  int bar_facets;
63
71
  Bool clockwise;
64
72
  GLfloat color[4];
65
73
 
68
76
  GLfloat bar_spacing;
69
77
  GLfloat wall_height;
70
78
  GLfloat wall_thickness;
71
 
  GLfloat tube_thickness;
 
79
  GLfloat bar_thickness;
72
80
  GLfloat wall_taper;
73
81
 
74
82
  GLfloat gasket_size;
75
83
  GLfloat gasket_depth;
76
84
  GLfloat gasket_thickness;
77
85
 
 
86
  GLfloat frame_size;
 
87
  GLfloat frame_depth;
 
88
  GLfloat frame_thickness;
 
89
  GLfloat triangle_size;
 
90
 
78
91
  GLfloat speed;
79
92
 
80
93
  spinner gasket_spinnerx, gasket_spinnery, gasket_spinnerz;
81
94
  spinner scene_spinnerx,  scene_spinnery;
82
95
  spinner helix_spinnerz;
 
96
  spinner frame_spinner;
83
97
 
84
98
  trackball_state *trackball;
85
99
  Bool button_down_p;
133
147
/* Make the helix
134
148
 */
135
149
 
136
 
static void
 
150
static int
137
151
make_helix (logo_configuration *dc, int facetted, int wire)
138
152
{
139
 
  int wall_facets = dc->wall_facets / (facetted ? 15 : 1);
 
153
  int polys = 0;
 
154
  int wall_facets = dc->wall_facets / (facetted ? 10 : 1);
140
155
  GLfloat th;
141
156
  GLfloat max_th = M_PI * 2 * dc->turns;
142
157
  GLfloat th_inc = M_PI * 2 / wall_facets;
156
171
 
157
172
  z1 = -(dc->turn_spacing * dc->turns / 2);
158
173
 
159
 
  h1 = (dc->wall_taper > 0 ? 0 : dc->wall_height / 2);
160
 
  h1off = (dc->wall_taper > 0 ? -dc->wall_height / 2 : 0);
 
174
  h1    = (dc->wall_taper > 0 ? 0 : dc->wall_height / 2);
 
175
  h1off = (dc->wall_taper > 0 ?    -dc->wall_height / 2 : 0);
161
176
 
162
177
  if (!dc->clockwise)
163
178
    z1 = -z1, z_inc = -z_inc, h1off = -h1off;
176
191
      glVertex3f( x1, y1,  z1 + h1 + h1off);
177
192
      glVertex3f(x1b, y1b, z1 + h1 + h1off);
178
193
      glVertex3f(x1b, y1b, z1 - h1 + h1off);
 
194
      polys++;
179
195
      glEnd();
180
196
    }
181
197
 
229
245
      glNormal3f(x2, y2, 0);
230
246
      glVertex3f(x2, y2, z2 + h2 + h2off);
231
247
      glVertex3f(x2, y2, z2 - h2 + h2off);
 
248
      polys++;
232
249
      glEnd();
233
250
 
234
251
      /* inner face
241
258
      glNormal3f(-x2b, -y2b, 0);
242
259
      glVertex3f( x2b,  y2b, z2 + h2 + h2off);
243
260
      glVertex3f( x2b,  y2b, z2 - h2 + h2off);
 
261
      polys++;
244
262
      glEnd();
245
263
 
246
264
      /* top face
255
273
      glVertex3f( x2b,  y2b, z2 + h2 + h2off);
256
274
      glVertex3f( x1b,  y1b, z1 + h1 + h1off);
257
275
      glVertex3f( x1,   y1,  z1 + h1 + h1off);
258
 
 
 
276
      polys++;
259
277
      glEnd();
260
278
 
261
279
      /* bottom face
270
288
      glVertex3f( x1b,  y1b, z1 - h1 + h1off);
271
289
      glVertex3f( x2b,  y2b, z2 - h2 + h2off);
272
290
      glVertex3f( x2,   y2,  z2 - h2 + h2off);
 
291
      polys++;
273
292
      glEnd();
274
293
 
275
294
      x1 = x2;
295
314
      glVertex3f(x2,  y2,  z1 + h2 + h2off);
296
315
      glVertex3f(x2b, y2b, z1 + h2 + h2off);
297
316
      glVertex3f(x2b, y2b, z1 - h2 + h2off);
 
317
      polys++;
298
318
      glEnd();
299
319
    }
 
320
  return polys;
300
321
}
301
322
 
302
323
 
303
 
static void
 
324
static int
304
325
make_ladder (logo_configuration *dc, int facetted, int wire)
305
326
{
 
327
  int polys = 0;
306
328
  GLfloat th;
307
329
  GLfloat max_th = dc->turns * M_PI * 2;
308
330
  GLfloat max_z  = dc->turns * dc->turn_spacing;
315
337
  GLfloat usable_th = max_th - dc->wall_taper;
316
338
  GLfloat usable_z  = max_z / (max_th / usable_th);
317
339
  int nbars = usable_z / dc->bar_spacing;
318
 
  GLfloat used_z = (nbars - 1) * dc->bar_spacing;
319
 
  GLfloat pad_z = max_z - used_z;
320
 
  GLfloat pad_ratio = pad_z / max_z;
 
340
  GLfloat used_z, pad_z, pad_ratio;
 
341
 
 
342
  if (! (nbars & 1)) nbars--;  /* always an odd number of bars */
 
343
 
 
344
  used_z = (nbars - 1) * dc->bar_spacing;
 
345
  pad_z = max_z - used_z;
 
346
  pad_ratio = pad_z / max_z;
321
347
 
322
348
  th = (max_th * pad_ratio/2);
323
349
  z  = -(max_z / 2) + (max_z * pad_ratio/2);
327
353
 
328
354
  for (i = 0; i < nbars; i++)
329
355
    {
330
 
      int facets = dc->tube_facets / (facetted ? 14 : 1);
 
356
      int facets = dc->bar_facets / (facetted ? 14 : 1);
331
357
      if (facets <= 3) facets = 3;
332
358
      x = cos (th) * (1 - dc->wall_thickness);
333
359
      y = sin (th) * (1 - dc->wall_thickness);
334
 
      tube ( x,  y, z,
335
 
            -x, -y, z,
336
 
             dc->tube_thickness, 0, facets,
337
 
             True, True, wire);
 
360
      polys += tube ( x,  y, z,
 
361
                     -x, -y, z,
 
362
                      dc->bar_thickness, 0, facets,
 
363
                      True, True, wire);
338
364
      z  += z_inc;
339
365
      th += th_inc;
340
366
    }
 
367
  return polys;
341
368
}
342
369
 
343
370
 
346
373
 */
347
374
 
348
375
 
349
 
static void
 
376
static int
350
377
make_gasket (logo_configuration *dc, int wire)
351
378
{
 
379
  int polys = 0;
352
380
  int i;
353
381
  int points_size;
354
382
  int npoints = 0;
360
388
 
361
389
  GLfloat *pointsx0, *pointsy0, *pointsx1, *pointsy1, *normals;
362
390
 
363
 
  GLfloat r0  = 0.780;  /* 395 */
364
 
  GLfloat r1a = 0.855;                /* top of wall below upper left hole */
365
 
  GLfloat r1b = 0.890;                /* center of upper left hole */
366
 
  GLfloat r1c = 0.922;                /* bottom of wall above hole */
367
 
  GLfloat r1  = 0.928;  /* 471 */
368
 
  GLfloat r2  = 0.966;  /* 490 */
369
 
  GLfloat r3  = 0.984;  /* 499 */
 
391
  GLfloat r0  = 0.750;  /* 395 */
 
392
  GLfloat r1a = 0.825;                /* bottom of wall below upper left hole */
 
393
  GLfloat r1b = 0.867;                /* center of upper left hole */
 
394
  GLfloat r1c = 0.909;                /* top of wall above hole */
 
395
  GLfloat r1  = 0.916;  /* 471 */
 
396
  GLfloat r2  = 0.963;  /* 490 */
 
397
  GLfloat r3  = 0.960;  /* 499 */
370
398
  GLfloat r4  = 1.000;  /* 507 */
371
 
  GLfloat r5  = 1.090;  /* 553 */
 
399
  GLfloat r5  = 1.080;  /* 553 */
372
400
 
373
401
  GLfloat ctrl_r[100], ctrl_th[100];
374
402
 
388
416
  POINT (0.872, 3.95);
389
417
 
390
418
  POINT (r4,    4.0);   /* moving clockwise... */
391
 
  POINT (r4,   48.2);
392
 
  POINT (r1,   48.2);
393
 
  POINT (r1,   54.2);
394
 
  POINT (r2,   55.8);
395
 
  POINT (r2,   73.2);
396
 
  POINT (r1,   74.8);
397
 
  POINT (r1,  101.2);
398
 
  POINT (r3,  103.4);
 
419
  POINT (r4,   47.0);
 
420
  POINT (r1,   47.0);
 
421
  POINT (r1,   53.0);
 
422
  POINT (r2,   55.5);
 
423
  POINT (r2,   72.3);
 
424
  POINT (r1,   74.0);
 
425
  POINT (r1,  100.0);
 
426
  POINT (r3,  102.5);
399
427
  POINT (r3,  132.0);
400
 
  POINT (r1,  133.4);
 
428
  POINT (r1,  133.0);
401
429
 
402
430
  POINT (r1,  180.7);
403
431
  POINT (r2,  183.6);
404
 
  POINT (r2,  209.8);
405
 
  POINT (r1,  211.0);
406
 
  POINT (r1,  221.8);
407
 
  POINT (r5,  221.8);
 
432
  POINT (r2,  210.0);
 
433
  POINT (r1,  212.0);
 
434
  POINT (r1,  223.2);
408
435
  POINT (r5,  223.2);
409
 
  POINT (r4,  223.2);
410
 
 
411
 
  POINT (r4,  316.8);      /* upper left indentation */
412
 
  POINT (0.990, 326.87);
413
 
  POINT (0.880, 327.21);
414
 
  POINT (0.872, 327.45);
415
 
  POINT (0.869, 327.80);
416
 
  POINT (0.867, 328.10);
417
 
 
418
 
  POINT (0.867, 328.85);
419
 
  POINT (0.869, 329.15);
420
 
  POINT (0.872, 329.50);
421
 
  POINT (0.880, 329.74);
422
 
  POINT (0.990, 330.08);
423
 
 
424
 
  POINT (r4,  339.0);
 
436
  POINT (r5,  225.0);
 
437
  POINT (r4,  225.0);
 
438
 
 
439
  POINT (r4,    316.8);      /* upper left indentation */
 
440
  POINT (0.990, 316.87);
 
441
  POINT (0.880, 317.21);
 
442
  POINT (0.872, 317.45);
 
443
  POINT (0.869, 317.80);
 
444
  POINT (0.867, 318.10);
 
445
 
 
446
  POINT (0.867, 318.85);
 
447
  POINT (0.869, 319.15);
 
448
  POINT (0.872, 319.50);
 
449
  POINT (0.880, 319.74);
 
450
  POINT (0.990, 320.08);
 
451
 
 
452
  POINT (r4,  338.5);
425
453
  if (! wire)
426
454
    {
427
 
      POINT (r1a, 339.0);      /* cut-out disc */
428
 
      POINT (r1a, 343.0);
 
455
      POINT (r1a, 338.5);      /* cut-out disc */
 
456
      POINT (r1a, 343.5);
429
457
    }
430
 
  POINT (r4,  343.0);
 
458
  POINT (r4,  343.5);
431
459
  POINT (r4,  356.0);
432
460
 
433
461
  POINT (0.872, 356.05);   /* top indentation, left half */
506
534
          glBegin (GL_LINE_LOOP);
507
535
          for (i = 0; i < npoints; i++)
508
536
            glVertex3f (pointsx0[i], pointsy0[i], z);
 
537
          polys += npoints;
509
538
          glEnd();
510
539
 
511
540
          /* outside edge */
512
541
          glBegin (GL_LINE_LOOP);
513
542
          for (i = 0; i < npoints; i++)
514
543
            glVertex3f (pointsx1[i], pointsy1[i], z);
 
544
          polys += npoints;
515
545
          glEnd();
516
546
# else
517
547
          for (i = 1; i < npoints; i++)
523
553
              glVertex3f (pointsx1[i-1], pointsy1[i-1], z);
524
554
              glEnd();
525
555
            }
 
556
          polys += npoints;
526
557
# endif
527
558
        }
528
559
#if 1
536
567
          glVertex3f (pointsx1[i], pointsy1[i], -thick2);
537
568
          glVertex3f (pointsx1[i], pointsy1[i],  thick2);
538
569
        }
 
570
      polys += npoints;
539
571
      glEnd();
540
572
#endif
541
573
    }
550
582
          glVertex3f (pointsx0[i], pointsy0[i], -thick2);
551
583
          glVertex3f (pointsx1[i], pointsy1[i], -thick2);
552
584
        }
 
585
      polys += npoints;
553
586
      glEnd();
554
587
 
555
588
      /* bottom */
561
594
          glVertex3f (pointsx0[i], pointsy0[i], thick2);
562
595
          glVertex3f (pointsx1[i], pointsy1[i], thick2);
563
596
        }
 
597
      polys += npoints;
564
598
      glEnd();
565
599
 
566
600
      /* inside edge */
572
606
          glVertex3f ( pointsx0[i],  pointsy0[i],  thick2);
573
607
          glVertex3f ( pointsx0[i],  pointsy0[i], -thick2);
574
608
        }
 
609
      polys += npoints;
575
610
      glEnd();
576
611
 
577
612
      /* outside edge */
624
659
                glVertex3f (xz, yz,  thick2);
625
660
              }
626
661
          }
 
662
        polys += npoints;
627
663
      }
628
664
      glEnd();
629
665
    }
634
670
    GLfloat th;
635
671
    npoints = 0;
636
672
 
637
 
    th = 339.0 * d2r;
 
673
    th = 338.5 * d2r;
638
674
    pointsx0[npoints] = r1c * cos(th) * dc->gasket_size;
639
675
    pointsy0[npoints] = r1c * sin(th) * dc->gasket_size;
640
676
    npoints++;
642
678
    pointsy0[npoints] = r4 * sin(th) * dc->gasket_size;
643
679
    npoints++;
644
680
 
645
 
    th = 343.0 * d2r;
 
681
    th = 343.5 * d2r;
646
682
    pointsx0[npoints] = r1c * cos(th) * dc->gasket_size;
647
683
    pointsy0[npoints] = r1c * sin(th) * dc->gasket_size;
648
684
    npoints++;
661
697
        glVertex3f (pointsx0[3], pointsy0[3], -thick2);
662
698
        glVertex3f (pointsx0[2], pointsy0[2], -thick2);
663
699
        glEnd();
 
700
        polys++;
664
701
 
665
702
        /* back wall */
666
703
        glNormal3f (0, 0, 1);
671
708
        glVertex3f (pointsx0[3], pointsy0[3],  thick2);
672
709
        glVertex3f (pointsx0[2], pointsy0[2],  thick2);
673
710
        glEnd();
 
711
        polys++;
674
712
      }
675
713
 
676
714
    /* top wall */
684
722
    glNormal3f (pointsx0[1], pointsy0[1], 0);
685
723
    glVertex3f (pointsx0[1], pointsy0[1], -thick2);
686
724
    glEnd();
 
725
    polys++;
687
726
 
688
727
 
689
728
    /* Now make a donut.
690
729
     */
691
730
    {
692
731
      int nsteps = 12;
693
 
      GLfloat r0 = 0.026;
 
732
      GLfloat r0 = 0.04;
694
733
      GLfloat r1 = 0.060;
695
734
      GLfloat th, cth, sth;
696
735
 
713
752
          pointsx1[npoints] = r1 * cth;
714
753
          pointsy1[npoints] = r1 * sth;
715
754
          npoints++;
 
755
          polys++;
716
756
        }
717
757
 
718
758
      pointsx0[npoints] = pointsx0[0];
726
766
          glBegin (GL_LINE_LOOP);
727
767
          for (i = 0; i < npoints; i++)
728
768
            glVertex3f (pointsx0[i], pointsy0[i], -thick2);
 
769
          polys += npoints;
729
770
          glEnd();
730
771
          glBegin (GL_LINE_LOOP);
731
772
          for (i = 0; i < npoints; i++)
732
773
            glVertex3f (pointsx0[i], pointsy0[i],  thick2);
 
774
          polys += npoints;
733
775
          glEnd();
734
776
# if 0
735
777
          glBegin (GL_LINE_LOOP);
736
778
          for (i = 0; i < npoints; i++)
737
779
            glVertex3f (pointsx1[i], pointsy1[i], -thick2);
 
780
          polys += npoints;
738
781
          glEnd();
739
782
          glBegin (GL_LINE_LOOP);
740
783
          for (i = 0; i < npoints; i++)
741
784
            glVertex3f (pointsx1[i], pointsy1[i],  thick2);
 
785
          polys += npoints;
742
786
          glEnd();
743
787
# endif
744
788
        }
753
797
              glVertex3f (pointsx0[i], pointsy0[i], -thick2);
754
798
              glVertex3f (pointsx1[i], pointsy1[i], -thick2);
755
799
            }
 
800
          polys += npoints;
756
801
          glEnd();
757
802
 
758
803
          /* bottom */
764
809
              glVertex3f (pointsx0[i], pointsy0[i],  thick2);
765
810
              glVertex3f (pointsx1[i], pointsy1[i],  thick2);
766
811
            }
 
812
          polys += npoints;
767
813
          glEnd();
768
814
        }
769
815
 
776
822
          glVertex3f ( pointsx0[i],  pointsy0[i],  thick2);
777
823
          glVertex3f ( pointsx0[i],  pointsy0[i], -thick2);
778
824
        }
 
825
      polys += npoints;
779
826
      glEnd();
780
827
 
781
828
      glPopMatrix();
786
833
  /* Attach the bottom-right dingus...
787
834
   */
788
835
  {
789
 
    GLfloat w = 0.04;
790
 
    GLfloat h = 0.17;
 
836
    GLfloat w = 0.05;
 
837
    GLfloat h = 0.19;
791
838
    GLfloat th;
792
839
 
793
 
    glRotatef (50, 0, 0, 1);
 
840
    glRotatef (49.5, 0, 0, 1);
794
841
    glScalef (dc->gasket_size, dc->gasket_size, 1);
795
842
    glTranslatef (0, (r0+r1)/2, 0);
796
843
 
811
858
        glNormal3f (-1, 0, 0);
812
859
        glVertex3f (-w/2, -h/2,  thick2); glVertex3f (-w/2,  h/2,  thick2);
813
860
        glVertex3f (-w/2,  h/2, -thick2); glVertex3f (-w/2, -h/2, -thick2);
 
861
        polys++;
814
862
        glEnd();
815
863
      }
816
864
 
820
868
        pointsx0[npoints] = w/2 * cos(th);
821
869
        pointsy0[npoints] = w/2 * sin(th);
822
870
        npoints++;
 
871
        polys++;
823
872
      }
824
873
 
825
874
    /* front inside curve */
829
878
    if (! wire) glVertex3f (0, h/2, -thick2);
830
879
    for (i = 0; i < npoints; i++)
831
880
      glVertex3f (pointsx0[i], h/2 + pointsy0[i], -thick2);
 
881
    polys += npoints;
832
882
    glEnd();
833
883
 
834
884
    /* front outside curve */
837
887
    if (! wire) glVertex3f (0, -h/2, -thick2);
838
888
    for (i = 0; i < npoints; i++)
839
889
      glVertex3f (pointsx0[i], -h/2 - pointsy0[i], -thick2);
 
890
    polys += npoints;
840
891
    glEnd();
841
892
 
842
893
    /* back inside curve */
846
897
    if (! wire) glVertex3f (0, h/2, thick2);
847
898
    for (i = 0; i < npoints; i++)
848
899
      glVertex3f (pointsx0[i], h/2 + pointsy0[i], thick2);
 
900
    polys += npoints;
849
901
    glEnd();
850
902
 
851
903
    /* back outside curve */
854
906
    if (! wire) glVertex3f (0, -h/2, thick2);
855
907
    for (i = 0; i < npoints; i++)
856
908
      glVertex3f (pointsx0[i], -h/2 - pointsy0[i], thick2);
 
909
    polys += npoints;
857
910
    glEnd();
858
911
 
859
912
    /* inside curve */
865
918
        glVertex3f (pointsx0[i], h/2 + pointsy0[i],  thick2);
866
919
        glVertex3f (pointsx0[i], h/2 + pointsy0[i], -thick2);
867
920
      }
 
921
    polys += npoints;
868
922
    glEnd();
869
923
 
870
924
    /* outside curve */
876
930
        glVertex3f (pointsx0[i], -h/2 - pointsy0[i],  thick2);
877
931
        glVertex3f (pointsx0[i], -h/2 - pointsy0[i], -thick2);
878
932
      }
 
933
    polys += npoints;
879
934
    glEnd();
880
935
  }
881
936
 
886
941
  free (normals);
887
942
 
888
943
  glPopMatrix();
889
 
}
 
944
  return polys;
 
945
}
 
946
 
 
947
static int
 
948
make_frame (logo_configuration *dc, int wire)
 
949
{
 
950
  int polys = 0;
 
951
  int i, j;
 
952
  GLfloat x[20], y[20];
 
953
  GLfloat corner_cut = 0.5;
 
954
 
 
955
  glPushMatrix();
 
956
  glRotatef (90, 0, 1, 0);
 
957
  glScalef (4 * dc->frame_size,
 
958
            4 * dc->frame_size,
 
959
            4 * dc->frame_size);
 
960
 
 
961
  x[0] = -dc->frame_thickness;
 
962
  x[1] = -dc->frame_thickness * corner_cut;
 
963
  x[2] = 0;
 
964
  x[3] = 0.5 - dc->triangle_size;
 
965
  x[4] = 0.5;
 
966
  x[5] = 0.5 + dc->triangle_size;
 
967
  x[6] = 1;
 
968
  x[7] = 1 + dc->frame_thickness * corner_cut;
 
969
  x[8] = 1 + dc->frame_thickness;
 
970
 
 
971
  y[0] = -dc->frame_thickness;
 
972
  y[1] = -dc->frame_thickness * corner_cut;
 
973
  y[2] = 0;
 
974
  y[3] = dc->triangle_size;
 
975
 
 
976
  /* front and back
 
977
   */
 
978
  glTranslatef (-0.5, -0.5, dc->frame_depth / 4);
 
979
  if (! wire)
 
980
    for (j = 0; j <= 1; j++)
 
981
      {
 
982
        if (j) glTranslatef (0, 0, -dc->frame_depth / 2);
 
983
        glFrontFace (j ? GL_CCW : GL_CW);
 
984
        for (i = 0; i < 4; i++)
 
985
          {
 
986
            glNormal3f (0, 0, (j ? -1 : 1));
 
987
            glBegin (wire ? GL_LINES : GL_QUAD_STRIP);
 
988
            glVertex3f (x[0], y[1], 0); glVertex3f (x[0], y[2], 0);
 
989
            glVertex3f (x[1], y[0], 0); glVertex3f (x[1], y[2], 0);
 
990
            glVertex3f (x[3], y[0], 0); glVertex3f (x[3], y[2], 0);
 
991
            glVertex3f (x[4], y[0], 0); glVertex3f (x[4], y[3], 0);
 
992
            glVertex3f (x[5], y[0], 0); glVertex3f (x[5], y[2], 0); 
 
993
            glVertex3f (x[7], y[0], 0); glVertex3f (x[7], y[2], 0);
 
994
            glVertex3f (x[8], y[1], 0); glVertex3f (x[8], y[2], 0);
 
995
            polys += 6;
 
996
            glEnd ();
 
997
            glTranslatef (0.5, 0.5, 0);
 
998
            glRotatef (90, 0, 0, 1);
 
999
            glTranslatef (-0.5, -0.5, 0);
 
1000
          }
 
1001
      }
 
1002
 
 
1003
  /* ledges
 
1004
   */
 
1005
  glFrontFace (GL_CCW);
 
1006
  for (i = 0; i < 4; i++)
 
1007
    {
 
1008
      glNormal3f (0, 1, 0);
 
1009
      glBegin (wire ? GL_LINES : GL_QUAD_STRIP);
 
1010
      glVertex3f (x[2], y[2], 0); glVertex3f (x[2], y[2], dc->frame_depth/2); 
 
1011
      glVertex3f (x[3], y[2], 0); glVertex3f (x[3], y[2], dc->frame_depth/2); 
 
1012
      glVertex3f (x[4], y[3], 0); glVertex3f (x[4], y[3], dc->frame_depth/2); 
 
1013
      glVertex3f (x[5], y[2], 0); glVertex3f (x[5], y[2], dc->frame_depth/2); 
 
1014
      glVertex3f (x[6], y[2], 0); glVertex3f (x[6], y[2], dc->frame_depth/2); 
 
1015
      polys += 4;
 
1016
      glEnd ();
 
1017
 
 
1018
      glNormal3f (0, -1, 0);
 
1019
      glBegin (wire ? GL_LINE_LOOP : GL_QUADS);
 
1020
      glVertex3f (x[7], y[0], 0); 
 
1021
      glVertex3f (x[7], y[0], dc->frame_depth/2); 
 
1022
      glVertex3f (x[1], y[0], dc->frame_depth/2); 
 
1023
      glVertex3f (x[1], y[0], 0); 
 
1024
      polys++;
 
1025
      glEnd ();
 
1026
 
 
1027
      glNormal3f (1, -1, 0);
 
1028
      glBegin (wire ? GL_LINE_LOOP : GL_QUADS);
 
1029
      glVertex3f (x[8], y[1], 0); 
 
1030
      glVertex3f (x[8], y[1], dc->frame_depth/2); 
 
1031
      glVertex3f (x[7], y[0], dc->frame_depth/2); 
 
1032
      glVertex3f (x[7], y[0], 0); 
 
1033
      polys++;
 
1034
      glEnd ();
 
1035
 
 
1036
      if (wire) 
 
1037
        {
 
1038
          glNormal3f (0, 1, 0);
 
1039
          for (j = 0; j <= 1; j++)
 
1040
            {
 
1041
              glBegin (GL_LINE_STRIP);
 
1042
              glVertex3f (x[2], y[2], j*dc->frame_depth/2);
 
1043
              glVertex3f (x[3], y[2], j*dc->frame_depth/2);
 
1044
              glVertex3f (x[4], y[3], j*dc->frame_depth/2);
 
1045
              glVertex3f (x[5], y[2], j*dc->frame_depth/2);
 
1046
              glVertex3f (x[6], y[2], j*dc->frame_depth/2);
 
1047
              polys += 4;
 
1048
              glEnd ();
 
1049
            }
 
1050
        }
 
1051
 
 
1052
      glTranslatef (0.5, 0.5, 0);
 
1053
      glRotatef (90, 0, 0, 1);
 
1054
      glTranslatef (-0.5, -0.5, 0);
 
1055
    }
 
1056
 
 
1057
  glPopMatrix();
 
1058
  return polys;
 
1059
}
 
1060
 
890
1061
 
891
1062
 
892
1063
/* Window management, etc
945
1116
  logo_configuration *dc;
946
1117
  int do_gasket = get_boolean_resource(mi->dpy, "doGasket", "Boolean");
947
1118
  int do_helix = get_boolean_resource(mi->dpy, "doHelix", "Boolean");
948
 
  int do_ladder = do_helix && get_boolean_resource(mi->dpy, "doLadder", "Boolean");
 
1119
  int do_ladder = (do_helix && 
 
1120
                   get_boolean_resource(mi->dpy, "doLadder", "Boolean"));
 
1121
  int do_frame = get_boolean_resource(mi->dpy, "doFrame", "Boolean");
 
1122
  GLfloat helix_rot = 147.0;
949
1123
 
950
1124
  if (!do_gasket && !do_helix)
951
1125
    {
970
1144
  }
971
1145
 
972
1146
  dc->wall_facets    = get_integer_resource(mi->dpy, "wallFacets",  "Integer");
973
 
  dc->tube_facets    = get_integer_resource(mi->dpy, "tubeFacets",  "Integer");
 
1147
  dc->bar_facets     = get_integer_resource(mi->dpy, "barFacets",   "Integer");
974
1148
  dc->clockwise      = get_boolean_resource(mi->dpy, "clockwise",   "Boolean");
975
1149
  dc->turns          = get_float_resource(mi->dpy, "turns",         "Float");
976
1150
  dc->turn_spacing   = get_float_resource(mi->dpy, "turnSpacing",   "Float");
977
1151
  dc->bar_spacing    = get_float_resource(mi->dpy, "barSpacing",    "Float");
978
1152
  dc->wall_height    = get_float_resource(mi->dpy, "wallHeight",    "Float");
979
1153
  dc->wall_thickness = get_float_resource(mi->dpy, "wallThickness", "Float");
980
 
  dc->tube_thickness = get_float_resource(mi->dpy, "tubeThickness", "Float");
 
1154
  dc->bar_thickness  = get_float_resource(mi->dpy, "barThickness",  "Float");
981
1155
  dc->wall_taper     = get_float_resource(mi->dpy, "wallTaper",     "Float");
982
1156
 
983
 
  dc->gasket_size      = get_float_resource(mi->dpy, "gasketSize",      "Float");
984
 
  dc->gasket_depth     = get_float_resource(mi->dpy, "gasketDepth",     "Float");
985
 
  dc->gasket_thickness = get_float_resource(mi->dpy, "gasketThickness", "Float");
 
1157
  dc->gasket_size      = get_float_resource(mi->dpy,"gasketSize",     "Float");
 
1158
  dc->gasket_depth     = get_float_resource(mi->dpy,"gasketDepth",    "Float");
 
1159
  dc->gasket_thickness = get_float_resource(mi->dpy,"gasketThickness","Float");
 
1160
 
 
1161
  dc->frame_size      = get_float_resource(mi->dpy, "frameSize",      "Float");
 
1162
  dc->frame_depth     = get_float_resource(mi->dpy, "frameDepth",     "Float");
 
1163
  dc->frame_thickness = get_float_resource(mi->dpy, "frameThickness", "Float");
 
1164
  dc->triangle_size   = get_float_resource(mi->dpy, "triangleSize",   "Float");
986
1165
 
987
1166
  dc->speed          = get_float_resource(mi->dpy, "speed",         "Float");
988
1167
 
1017
1196
  dc->helix_spinnerz.probability  = 0.6;
1018
1197
  dc->scene_spinnerx.probability  = 0.1;
1019
1198
  dc->scene_spinnery.probability  = 0.0;
 
1199
  dc->frame_spinner.probability   = 5.0;
 
1200
 
 
1201
  /* start the frame off-screen */
 
1202
  dc->frame_spinner.spinning_p = True;
 
1203
  dc->frame_spinner.position = 0.3;
 
1204
  dc->frame_spinner.speed = 0.001;
1020
1205
 
1021
1206
  if (dc->speed > 0)    /* start off with the gasket in motion */
1022
1207
    {
1029
1214
  glPushMatrix();
1030
1215
  dc->helix_list = glGenLists (1);
1031
1216
  glNewList (dc->helix_list, GL_COMPILE);
1032
 
  glRotatef(126, 0, 0, 1);
1033
 
  if (do_ladder) make_ladder (dc, 0, 0);
1034
 
  if (do_helix)  make_helix  (dc, 0, 0);
 
1217
  glRotatef(helix_rot, 0, 0, 1);
 
1218
  if (do_ladder) dc->polys[0] += make_ladder (dc, 0, 0);
 
1219
  if (do_helix)  dc->polys[0] += make_helix  (dc, 0, 0);
1035
1220
  glRotatef(180, 0, 0, 1);
1036
 
  if (do_helix)  make_helix  (dc, 0, 0);
 
1221
  if (do_helix)  dc->polys[0] += make_helix  (dc, 0, 0);
1037
1222
  glEndList ();
1038
1223
  glPopMatrix();
1039
1224
 
1040
1225
  glPushMatrix();
1041
1226
  dc->helix_list_wire = glGenLists (1);
1042
1227
  glNewList (dc->helix_list_wire, GL_COMPILE);
1043
 
  /* glRotatef(126, 0, 0, 1); wtf? */
1044
 
  if (do_ladder) make_ladder (dc, 1, 1);
1045
 
  if (do_helix)  make_helix  (dc, 1, 1);
 
1228
/*  glRotatef(helix_rot, 0, 0, 1); wtf? */
 
1229
  if (do_ladder) dc->polys[1] += make_ladder (dc, 1, 1);
 
1230
  if (do_helix)  dc->polys[1] += make_helix  (dc, 1, 1);
1046
1231
  glRotatef(180, 0, 0, 1);
1047
 
  if (do_helix)  make_helix  (dc, 1, 1);
 
1232
  if (do_helix)  dc->polys[1] += make_helix  (dc, 1, 1);
1048
1233
  glEndList ();
1049
1234
  glPopMatrix();
1050
1235
 
1051
1236
  glPushMatrix();
1052
1237
  dc->helix_list_facetted = glGenLists (1);
1053
1238
  glNewList (dc->helix_list_facetted, GL_COMPILE);
1054
 
  glRotatef(126, 0, 0, 1);
1055
 
  if (do_ladder) make_ladder (dc, 1, 0);
1056
 
  if (do_helix)  make_helix  (dc, 1, 0);
 
1239
  glRotatef(helix_rot, 0, 0, 1);
 
1240
  if (do_ladder) dc->polys[2] += make_ladder (dc, 1, 0);
 
1241
  if (do_helix)  dc->polys[2] += make_helix  (dc, 1, 0);
1057
1242
  glRotatef(180, 0, 0, 1);
1058
 
  if (do_helix)  make_helix  (dc, 1, 0);
 
1243
  if (do_helix)  dc->polys[2] += make_helix  (dc, 1, 0);
1059
1244
  glEndList ();
1060
1245
  glPopMatrix();
1061
1246
 
1062
1247
  dc->gasket_list = glGenLists (1);
1063
1248
  glNewList (dc->gasket_list, GL_COMPILE);
1064
 
  if (do_gasket) make_gasket (dc, 0);
 
1249
  if (do_gasket) dc->polys[3] += make_gasket (dc, 0);
1065
1250
  glEndList ();
1066
1251
 
1067
1252
  dc->gasket_list_wire = glGenLists (1);
1068
1253
  glNewList (dc->gasket_list_wire, GL_COMPILE);
1069
 
  if (do_gasket) make_gasket (dc, 1);
 
1254
  if (do_gasket) dc->polys[4] += make_gasket (dc, 1);
 
1255
  glEndList ();
 
1256
 
 
1257
  dc->frame_list = glGenLists (1);
 
1258
  glNewList (dc->frame_list, GL_COMPILE);
 
1259
  if (do_frame) dc->polys[5] += make_frame (dc, 0);
 
1260
  glEndList ();
 
1261
 
 
1262
  dc->frame_list_wire = glGenLists (1);
 
1263
  glNewList (dc->frame_list_wire, GL_COMPILE);
 
1264
  if (do_frame) dc->polys[6] += make_frame (dc, 1);
1070
1265
  glEndList ();
1071
1266
 
1072
1267
  /* When drawing both solid and wireframe objects,
1179
1374
  if (!dc->glx_context)
1180
1375
    return;
1181
1376
 
 
1377
  mi->polygon_count = 0;
1182
1378
  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(dc->glx_context));
1183
1379
 
1184
1380
  if (dc->wire_overlay == 0 &&
1193
1389
  tick_spinner (mi, &dc->helix_spinnerz);
1194
1390
  tick_spinner (mi, &dc->scene_spinnerx);
1195
1391
  tick_spinner (mi, &dc->scene_spinnery);
 
1392
  tick_spinner (mi, &dc->frame_spinner);
1196
1393
  link_spinners (mi, &dc->scene_spinnerx, &dc->scene_spinnery);
1197
1394
 
1198
1395
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1199
1396
 
1200
1397
  glPushMatrix ();
1201
1398
  {
1202
 
    glScalef(3.3, 3.3, 3.3);
 
1399
    glScalef(3, 3, 3);
 
1400
 
 
1401
    glColor3f(dc->color[0], dc->color[1], dc->color[2]);
 
1402
 
 
1403
    /* Draw frame before trackball rotation */
 
1404
    {
 
1405
      GLfloat p = (dc->frame_spinner.position >= 0
 
1406
                   ? dc->frame_spinner.position
 
1407
                   : -dc->frame_spinner.position);
 
1408
      GLfloat size = (p > 0.5 ? 1-p : p);
 
1409
      GLfloat scale = 1 + (size * 10);
 
1410
      glPushMatrix();
 
1411
      /* gltrackball_rotate (dc->trackball); */
 
1412
      glRotatef(90, 1, 0, 0);
 
1413
      glRotatef(90, 0, 0, 1);
 
1414
 
 
1415
      glScalef (1, scale, scale);
 
1416
      if (wire)
 
1417
        {
 
1418
          glCallList (dc->frame_list_wire);
 
1419
          mi->polygon_count += dc->polys[6];
 
1420
        }
 
1421
      else if (dc->wire_overlay != 0)
 
1422
        {
 
1423
          glCallList (dc->frame_list);
 
1424
          glDisable (GL_LIGHTING);
 
1425
          glCallList (dc->frame_list_wire);
 
1426
          mi->polygon_count += dc->polys[6];
 
1427
          if (!wire) glEnable (GL_LIGHTING);
 
1428
        }
 
1429
      else
 
1430
        {
 
1431
          glCallList (dc->frame_list);
 
1432
          mi->polygon_count += dc->polys[5];
 
1433
        }
 
1434
      glPopMatrix();
 
1435
    }
1203
1436
 
1204
1437
    gltrackball_rotate (dc->trackball);
1205
1438
 
1206
1439
    glRotatef(90, 1, 0, 0);
1207
1440
    glRotatef(90, 0, 0, 1);
1208
1441
 
1209
 
    glColor3f(dc->color[0], dc->color[1], dc->color[2]);
1210
 
 
1211
1442
    glRotatef (360 * sin (M_PI/2 * dc->scene_spinnerx.position), 0, 1, 0);
1212
1443
    glRotatef (360 * sin (M_PI/2 * dc->scene_spinnery.position), 0, 0, 1);
1213
1444
 
1229
1460
      glMaterialf  (GL_FRONT_AND_BACK, GL_SHININESS, shininess);
1230
1461
 
1231
1462
      if (wire)
1232
 
        glCallList (dc->gasket_list_wire);
 
1463
        {
 
1464
          glCallList (dc->gasket_list_wire);
 
1465
          mi->polygon_count += dc->polys[4];
 
1466
        }
1233
1467
      else if (dc->wire_overlay != 0)
1234
1468
        {
1235
1469
          glCallList (dc->gasket_list);
1236
1470
          glDisable (GL_LIGHTING);
1237
1471
          glCallList (dc->gasket_list_wire);
 
1472
          mi->polygon_count += dc->polys[4];
1238
1473
          if (!wire) glEnable (GL_LIGHTING);
1239
1474
        }
1240
1475
      else
1241
 
        glCallList (dc->gasket_list);
 
1476
        {
 
1477
          glCallList (dc->gasket_list);
 
1478
          mi->polygon_count += dc->polys[3];
 
1479
        }
1242
1480
    }
1243
1481
    glPopMatrix();
1244
1482
 
1245
1483
    glRotatef (360 * sin (M_PI/2 * dc->helix_spinnerz.position), 0, 0, 1);
1246
1484
 
1247
1485
    if (wire)
1248
 
      glCallList (dc->helix_list_wire);
 
1486
      {
 
1487
        glCallList (dc->helix_list_wire);
 
1488
        mi->polygon_count += dc->polys[1];
 
1489
      }
1249
1490
    else if (dc->wire_overlay != 0)
1250
1491
      {
1251
1492
        glCallList (dc->helix_list_facetted);
1252
1493
        glDisable (GL_LIGHTING);
1253
1494
        glCallList (dc->helix_list_wire);
 
1495
        mi->polygon_count += dc->polys[2];
1254
1496
        if (!wire) glEnable (GL_LIGHTING);
1255
1497
      }
1256
1498
    else
1257
 
      glCallList (dc->helix_list);
 
1499
      {
 
1500
        glCallList (dc->helix_list);
 
1501
        mi->polygon_count += dc->polys[0];
 
1502
      }
1258
1503
  }
1259
1504
  glPopMatrix();
1260
1505