~ubuntu-branches/ubuntu/dapper/xscreensaver/dapper-updates

« back to all changes in this revision

Viewing changes to hacks/glx/morph3d.c

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Hildebrandt
  • Date: 2005-04-09 00:06:43 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050409000643-z0abtifbt9s20pcc
Tags: 4.21-3
Patch by Joachim Breitner to check more frequently if DPMS kicked in (closes: #303374, #286664).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- Mode: C; tab-width: 4 -*- */
2
2
/* morph3d --- Shows 3D morphing objects */
3
3
 
4
 
#if !defined( lint ) && !defined( SABER )
5
 
static const char sccsid[] = "@(#)morph3d.c     4.07 97/11/24 xlockmore";
6
 
 
 
4
#if 0
 
5
static const char sccsid[] = "@(#)morph3d.c     5.01 2001/03/01 xlockmore";
7
6
#endif
8
7
 
9
8
#undef DEBUG_CULL_FACE
21
20
 * event will the author be liable for any lost revenue or profits or
22
21
 * other special, indirect and consequential damages.
23
22
 *
24
 
 * The original code for this mode was written by Marcelo Fernandes Vianna 
 
23
 * The original code for this mode was written by Marcelo Fernandes Vianna
25
24
 * (me...) and was inspired on a WindowsNT(R)'s screen saver (Flower Box).
26
 
 * It was written from scratch and it was not based on any other source code. 
27
 
 * 
28
 
 * Porting it to xlock (the final objective of this code since the moment I 
29
 
 * decided to create it) was possible by comparing the original Mesa's gear 
 
25
 * It was written from scratch and it was not based on any other source code.
 
26
 *
 
27
 * Porting it to xlock (the final objective of this code since the moment I
 
28
 * decided to create it) was possible by comparing the original Mesa's gear
30
29
 * demo with it's ported version to xlock, so thanks for Danny Sung (look at
31
30
 * gear.c) for his indirect help.
32
31
 *
37
36
 * mode, please refer to the Mesa package (ftp iris.ssec.wisc.edu on /pub/Mesa)
38
37
 *
39
38
 * Since I'm not a native English speaker, my apologies for any grammatical
40
 
 * mistake.
 
39
 * mistakes.
41
40
 *
42
41
 * My e-mail address is
43
 
 * m-vianna@usa.net
 
42
 * mfvianna@centroin.com.br
44
43
 *
45
44
 * Marcelo F. Vianna (Feb-13-1997)
46
45
 *
47
46
 * Revision History:
48
 
 * 27-Jul-97: Speed ups by Marcelo F. Vianna.
49
 
 * 08-May-97: Speed ups by Marcelo F. Vianna.
 
47
 * 05-Apr-2002: Removed all gllist uses (fix some bug with nvidia driver)
 
48
 * 01-Mar-2001: Added FPS stuff E.Lassauge <lassauge@mail.dotcom.fr>
 
49
 * 27-Jul-1997: Speed ups by Marcelo F. Vianna.
 
50
 * 08-May-1997: Speed ups by Marcelo F. Vianna.
50
51
 *
51
52
 */
52
53
 
53
 
/*-
54
 
 * PURIFY 3.0a on SunOS4 reports an unitialized memory read on each of
55
 
 * the glCallList() functions below when using MesaGL 2.1.  This has
56
 
 * been fixed in MesaGL 2.2 and later releases.
57
 
 */
58
 
 
59
 
/*-
60
 
 * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock.
61
 
 * otherwise caddr_t is not defined correctly
62
 
 */
63
 
 
64
 
#include <X11/Intrinsic.h>
65
 
 
66
54
#ifdef STANDALONE
 
55
# define MODE_moebius
67
56
# define PROGCLASS              "Morph3d"
68
57
# define HACK_INIT              init_morph3d
69
58
# define HACK_DRAW              draw_morph3d
70
 
# define HACK_RESHAPE   reshape_morph3d
 
59
# define HACK_RESHAPE   reshape
71
60
# define morph3d_opts   xlockmore_opts
72
61
# define DEFAULTS               "*delay:                40000   \n"             \
73
62
                                                "*showFPS:      False   \n"             \
77
66
# include "xlock.h"             /* from the xlockmore distribution */
78
67
#endif /* !STANDALONE */
79
68
 
80
 
#ifdef USE_GL
 
69
#ifdef MODE_moebius
81
70
 
82
71
ModeSpecOpt morph3d_opts =
83
 
{0, NULL, 0, NULL, NULL};
 
72
{0, (XrmOptionDescRec *) NULL, 0, (argtype *) NULL, (OptionStruct *) NULL};
84
73
 
85
74
#ifdef USE_MODULES
86
75
ModStruct   morph3d_description =
87
76
{"morph3d", "init_morph3d", "draw_morph3d", "release_morph3d",
88
 
 "draw_morph3d", "change_morph3d", NULL, &morph3d_opts,
 
77
 "draw_morph3d", "change_morph3d", (char *) NULL, &morph3d_opts,
89
78
 1000, 0, 1, 1, 4, 1.0, "",
90
79
 "Shows GL morphing polyhedra", 0, NULL};
91
80
 
173
162
static float MaterialGray[] =
174
163
{0.5, 0.5, 0.5, 1.0};
175
164
 
176
 
static morph3dstruct *morph3d = NULL;
 
165
static morph3dstruct *morph3d = (morph3dstruct *) NULL;
177
166
 
178
167
#define TRIANGLE(Edge, Amp, Divisions, Z, VS)                                                                    \
179
168
{                                                                                                                \
180
 
  GLfloat   Xf,Yf,Xa,Yb,Xf2,Yf2,Yf_2,Yb2,Yb_2;                                                                   \
 
169
  GLfloat   Xf,Yf,Xa,Yb=0.0,Xf2=0.0,Yf2=0.0,Yf_2=0.0,Yb2,Yb_2;                                                   \
181
170
  GLfloat   Factor=0.0,Factor1,Factor2;                                                                          \
182
171
  GLfloat   VertX,VertY,VertZ,NeiAX,NeiAY,NeiAZ,NeiBX,NeiBY,NeiBZ;                                               \
183
172
  GLfloat   Ax,Ay;                                                                                               \
343
332
static void
344
333
draw_tetra(ModeInfo * mi)
345
334
{
346
 
        GLuint      list;
347
 
 
348
335
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
349
336
 
350
337
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[0]);
351
338
 
352
 
        list = glGenLists(1);
353
 
        glNewList(list, GL_COMPILE_AND_EXECUTE);
354
339
        TRIANGLE(2, mp->seno, mp->edgedivisions, 0.5 / SQRT6, mp->VisibleSpikes);
355
 
        glEndList();
356
340
 
357
341
        glPushMatrix();
358
342
        glRotatef(180, 0, 0, 1);
359
343
        glRotatef(-tetraangle, 1, 0, 0);
360
344
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[1]);
361
 
        glCallList(list);
 
345
        TRIANGLE(2, mp->seno, mp->edgedivisions, 0.5 / SQRT6, mp->VisibleSpikes);
362
346
        glPopMatrix();
363
347
        glPushMatrix();
364
348
        glRotatef(180, 0, 1, 0);
365
349
        glRotatef(-180 + tetraangle, 0.5, SQRT3 / 2, 0);
366
350
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[2]);
367
 
        glCallList(list);
 
351
        TRIANGLE(2, mp->seno, mp->edgedivisions, 0.5 / SQRT6, mp->VisibleSpikes);
368
352
        glPopMatrix();
369
353
        glRotatef(180, 0, 1, 0);
370
354
        glRotatef(-180 + tetraangle, 0.5, -SQRT3 / 2, 0);
371
355
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[3]);
372
 
        glCallList(list);
373
 
 
374
 
        glDeleteLists(list, 1);
 
356
        TRIANGLE(2, mp->seno, mp->edgedivisions, 0.5 / SQRT6, mp->VisibleSpikes);
375
357
}
376
358
 
377
359
static void
378
360
draw_cube(ModeInfo * mi)
379
361
{
380
 
        GLuint      list;
381
 
 
382
362
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
383
363
 
384
 
 
385
364
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[0]);
386
365
 
387
 
        list = glGenLists(1);
388
 
        glNewList(list, GL_COMPILE_AND_EXECUTE);
389
366
        SQUARE(2, mp->seno, mp->edgedivisions, 0.5, mp->VisibleSpikes)
390
 
                glEndList();
391
367
 
392
368
        glRotatef(cubeangle, 1, 0, 0);
393
369
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[1]);
394
 
        glCallList(list);
 
370
        SQUARE(2, mp->seno, mp->edgedivisions, 0.5, mp->VisibleSpikes)
395
371
        glRotatef(cubeangle, 1, 0, 0);
396
372
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[2]);
397
 
        glCallList(list);
 
373
        SQUARE(2, mp->seno, mp->edgedivisions, 0.5, mp->VisibleSpikes)
398
374
        glRotatef(cubeangle, 1, 0, 0);
399
375
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[3]);
400
 
        glCallList(list);
 
376
        SQUARE(2, mp->seno, mp->edgedivisions, 0.5, mp->VisibleSpikes)
401
377
        glRotatef(cubeangle, 0, 1, 0);
402
378
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[4]);
403
 
        glCallList(list);
 
379
        SQUARE(2, mp->seno, mp->edgedivisions, 0.5, mp->VisibleSpikes)
404
380
        glRotatef(2 * cubeangle, 0, 1, 0);
405
381
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[5]);
406
 
        glCallList(list);
407
 
 
408
 
        glDeleteLists(list, 1);
 
382
        SQUARE(2, mp->seno, mp->edgedivisions, 0.5, mp->VisibleSpikes)
409
383
}
410
384
 
411
385
static void
412
386
draw_octa(ModeInfo * mi)
413
387
{
414
 
        GLuint      list;
415
 
 
416
388
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
417
389
 
418
390
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[0]);
419
 
 
420
 
        list = glGenLists(1);
421
 
        glNewList(list, GL_COMPILE_AND_EXECUTE);
422
391
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
423
 
        glEndList();
424
392
 
425
393
        glPushMatrix();
426
394
        glRotatef(180, 0, 0, 1);
427
395
        glRotatef(-180 + octaangle, 1, 0, 0);
428
396
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[1]);
429
 
        glCallList(list);
 
397
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
430
398
        glPopMatrix();
431
399
        glPushMatrix();
432
400
        glRotatef(180, 0, 1, 0);
433
401
        glRotatef(-octaangle, 0.5, SQRT3 / 2, 0);
434
402
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[2]);
435
 
        glCallList(list);
 
403
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
436
404
        glPopMatrix();
437
405
        glPushMatrix();
438
406
        glRotatef(180, 0, 1, 0);
439
407
        glRotatef(-octaangle, 0.5, -SQRT3 / 2, 0);
440
408
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[3]);
441
 
        glCallList(list);
 
409
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
442
410
        glPopMatrix();
443
411
        glRotatef(180, 1, 0, 0);
444
412
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[4]);
445
 
        glCallList(list);
 
413
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
446
414
        glPushMatrix();
447
415
        glRotatef(180, 0, 0, 1);
448
416
        glRotatef(-180 + octaangle, 1, 0, 0);
449
417
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[5]);
450
 
        glCallList(list);
 
418
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
451
419
        glPopMatrix();
452
420
        glPushMatrix();
453
421
        glRotatef(180, 0, 1, 0);
454
422
        glRotatef(-octaangle, 0.5, SQRT3 / 2, 0);
455
423
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[6]);
456
 
        glCallList(list);
 
424
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
457
425
        glPopMatrix();
458
426
        glRotatef(180, 0, 1, 0);
459
427
        glRotatef(-octaangle, 0.5, -SQRT3 / 2, 0);
460
428
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[7]);
461
 
        glCallList(list);
462
 
 
463
 
        glDeleteLists(list, 1);
 
429
        TRIANGLE(2, mp->seno, mp->edgedivisions, 1 / SQRT6, mp->VisibleSpikes);
464
430
}
465
431
 
466
432
static void
467
433
draw_dodeca(ModeInfo * mi)
468
434
{
469
 
        GLuint      list;
470
 
 
471
435
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
472
436
 
473
437
#define TAU ((SQRT5+1)/2)
474
438
 
475
439
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[0]);
476
440
 
477
 
        list = glGenLists(1);
478
 
        glNewList(list, GL_COMPILE_AND_EXECUTE);
479
441
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
480
 
        glEndList();
481
442
 
482
443
        glPushMatrix();
483
444
        glRotatef(180, 0, 0, 1);
484
445
        glPushMatrix();
485
446
        glRotatef(-dodecaangle, 1, 0, 0);
486
447
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[1]);
487
 
        glCallList(list);
 
448
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
488
449
        glPopMatrix();
489
450
        glPushMatrix();
490
451
        glRotatef(-dodecaangle, cos72, sin72, 0);
491
452
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[2]);
492
 
        glCallList(list);
 
453
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
493
454
        glPopMatrix();
494
455
        glPushMatrix();
495
456
        glRotatef(-dodecaangle, cos72, -sin72, 0);
496
457
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[3]);
497
 
        glCallList(list);
 
458
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
498
459
        glPopMatrix();
499
460
        glPushMatrix();
500
461
        glRotatef(dodecaangle, cos36, -sin36, 0);
501
462
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[4]);
502
 
        glCallList(list);
 
463
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
503
464
        glPopMatrix();
504
465
        glRotatef(dodecaangle, cos36, sin36, 0);
505
466
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[5]);
506
 
        glCallList(list);
 
467
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
507
468
        glPopMatrix();
508
469
        glRotatef(180, 1, 0, 0);
509
470
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[6]);
510
 
        glCallList(list);
 
471
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
511
472
        glRotatef(180, 0, 0, 1);
512
473
        glPushMatrix();
513
474
        glRotatef(-dodecaangle, 1, 0, 0);
514
475
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[7]);
515
 
        glCallList(list);
 
476
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
516
477
        glPopMatrix();
517
478
        glPushMatrix();
518
479
        glRotatef(-dodecaangle, cos72, sin72, 0);
519
480
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[8]);
520
 
        glCallList(list);
 
481
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
521
482
        glPopMatrix();
522
483
        glPushMatrix();
523
484
        glRotatef(-dodecaangle, cos72, -sin72, 0);
524
485
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[9]);
525
 
        glCallList(list);
 
486
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
526
487
        glPopMatrix();
527
488
        glPushMatrix();
528
489
        glRotatef(dodecaangle, cos36, -sin36, 0);
529
490
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[10]);
530
 
        glCallList(list);
 
491
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
531
492
        glPopMatrix();
532
493
        glRotatef(dodecaangle, cos36, sin36, 0);
533
494
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[11]);
534
 
        glCallList(list);
535
 
 
536
 
        glDeleteLists(list, 1);
 
495
        PENTAGON(1, mp->seno, mp->edgedivisions, sqr(TAU) * sqrt((TAU + 2) / 5) / 2, mp->VisibleSpikes);
537
496
}
538
497
 
539
498
static void
540
499
draw_icosa(ModeInfo * mi)
541
500
{
542
 
        GLuint      list;
543
 
 
544
501
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
545
502
 
546
503
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[0]);
547
504
 
548
 
        list = glGenLists(1);
549
 
        glNewList(list, GL_COMPILE_AND_EXECUTE);
550
505
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
551
 
        glEndList();
552
506
 
553
507
        glPushMatrix();
554
508
 
556
510
        glRotatef(180, 0, 0, 1);
557
511
        glRotatef(-icoangle, 1, 0, 0);
558
512
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[1]);
559
 
        glCallList(list);
 
513
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
560
514
        glPushMatrix();
561
515
        glRotatef(180, 0, 1, 0);
562
516
        glRotatef(-180 + icoangle, 0.5, SQRT3 / 2, 0);
563
517
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[2]);
564
 
        glCallList(list);
 
518
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
565
519
        glPopMatrix();
566
520
        glRotatef(180, 0, 1, 0);
567
521
        glRotatef(-180 + icoangle, 0.5, -SQRT3 / 2, 0);
568
522
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[3]);
569
 
        glCallList(list);
 
523
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
570
524
        glPopMatrix();
571
525
        glPushMatrix();
572
526
        glRotatef(180, 0, 1, 0);
573
527
        glRotatef(-180 + icoangle, 0.5, SQRT3 / 2, 0);
574
528
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[4]);
575
 
        glCallList(list);
 
529
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
576
530
        glPushMatrix();
577
531
        glRotatef(180, 0, 1, 0);
578
532
        glRotatef(-180 + icoangle, 0.5, SQRT3 / 2, 0);
579
533
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[5]);
580
 
        glCallList(list);
 
534
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
581
535
        glPopMatrix();
582
536
        glRotatef(180, 0, 0, 1);
583
537
        glRotatef(-icoangle, 1, 0, 0);
584
538
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[6]);
585
 
        glCallList(list);
 
539
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
586
540
        glPopMatrix();
587
541
        glRotatef(180, 0, 1, 0);
588
542
        glRotatef(-180 + icoangle, 0.5, -SQRT3 / 2, 0);
589
543
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[7]);
590
 
        glCallList(list);
 
544
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
591
545
        glPushMatrix();
592
546
        glRotatef(180, 0, 1, 0);
593
547
        glRotatef(-180 + icoangle, 0.5, -SQRT3 / 2, 0);
594
548
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[8]);
595
 
        glCallList(list);
 
549
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
596
550
        glPopMatrix();
597
551
        glRotatef(180, 0, 0, 1);
598
552
        glRotatef(-icoangle, 1, 0, 0);
599
553
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[9]);
600
 
        glCallList(list);
 
554
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
601
555
        glPopMatrix();
602
556
        glRotatef(180, 1, 0, 0);
603
557
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[10]);
604
 
        glCallList(list);
 
558
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
605
559
        glPushMatrix();
606
560
        glRotatef(180, 0, 0, 1);
607
561
        glRotatef(-icoangle, 1, 0, 0);
608
562
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[11]);
609
 
        glCallList(list);
 
563
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
610
564
        glPushMatrix();
611
565
        glRotatef(180, 0, 1, 0);
612
566
        glRotatef(-180 + icoangle, 0.5, SQRT3 / 2, 0);
613
567
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[12]);
614
 
        glCallList(list);
 
568
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
615
569
        glPopMatrix();
616
570
        glRotatef(180, 0, 1, 0);
617
571
        glRotatef(-180 + icoangle, 0.5, -SQRT3 / 2, 0);
618
572
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[13]);
619
 
        glCallList(list);
 
573
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
620
574
        glPopMatrix();
621
575
        glPushMatrix();
622
576
        glRotatef(180, 0, 1, 0);
623
577
        glRotatef(-180 + icoangle, 0.5, SQRT3 / 2, 0);
624
578
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[14]);
625
 
        glCallList(list);
 
579
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
626
580
        glPushMatrix();
627
581
        glRotatef(180, 0, 1, 0);
628
582
        glRotatef(-180 + icoangle, 0.5, SQRT3 / 2, 0);
629
583
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[15]);
630
 
        glCallList(list);
 
584
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
631
585
        glPopMatrix();
632
586
        glRotatef(180, 0, 0, 1);
633
587
        glRotatef(-icoangle, 1, 0, 0);
634
588
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[16]);
635
 
        glCallList(list);
 
589
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
636
590
        glPopMatrix();
637
591
        glRotatef(180, 0, 1, 0);
638
592
        glRotatef(-180 + icoangle, 0.5, -SQRT3 / 2, 0);
639
593
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[17]);
640
 
        glCallList(list);
 
594
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
641
595
        glPushMatrix();
642
596
        glRotatef(180, 0, 1, 0);
643
597
        glRotatef(-180 + icoangle, 0.5, -SQRT3 / 2, 0);
644
598
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[18]);
645
 
        glCallList(list);
 
599
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
646
600
        glPopMatrix();
647
601
        glRotatef(180, 0, 0, 1);
648
602
        glRotatef(-icoangle, 1, 0, 0);
649
603
        glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->MaterialColor[19]);
650
 
        glCallList(list);
651
 
 
652
 
        glDeleteLists(list, 1);
 
604
        TRIANGLE(1.5, mp->seno, mp->edgedivisions, (3 * SQRT3 + SQRT15) / 12, mp->VisibleSpikes);
653
605
}
654
606
 
655
607
void
656
 
reshape_morph3d(ModeInfo * mi, int width, int height)
 
608
reshape(ModeInfo * mi, int width, int height)
657
609
{
658
610
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
659
611
 
779
731
void
780
732
init_morph3d(ModeInfo * mi)
781
733
{
782
 
        int         screen = MI_SCREEN(mi);
783
734
        morph3dstruct *mp;
784
735
 
785
736
        if (morph3d == NULL) {
787
738
                                            sizeof (morph3dstruct))) == NULL)
788
739
                        return;
789
740
        }
790
 
        mp = &morph3d[screen];
 
741
        mp = &morph3d[MI_SCREEN(mi)];
791
742
        mp->step = NRAND(90);
792
743
        mp->VisibleSpikes = 1;
793
744
 
794
745
        if ((mp->glx_context = init_GL(mi)) != NULL) {
795
746
 
796
 
                reshape_morph3d(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
 
747
                reshape(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
 
748
                glDrawBuffer(GL_BACK);
797
749
                mp->object = MI_COUNT(mi);
798
750
                if (mp->object <= 0 || mp->object > 5)
799
751
                        mp->object = NRAND(5) + 1;
806
758
void
807
759
draw_morph3d(ModeInfo * mi)
808
760
{
809
 
        morph3dstruct *mp = &morph3d[MI_SCREEN(mi)];
810
 
 
811
761
        Display    *display = MI_DISPLAY(mi);
812
762
        Window      window = MI_WINDOW(mi);
 
763
        morph3dstruct *mp;
 
764
 
 
765
        if (morph3d == NULL)
 
766
                return;
 
767
        mp = &morph3d[MI_SCREEN(mi)];
 
768
 
 
769
        MI_IS_DRAWN(mi) = True;
813
770
 
814
771
        if (!mp->glx_context)
815
772
                return;
816
773
 
817
 
        glDrawBuffer(GL_BACK);
818
774
        glXMakeCurrent(display, window, *(mp->glx_context));
819
775
 
820
776
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
858
814
 
859
815
        glPopMatrix();
860
816
 
861
 
    if (mi->fps_p) do_fps (mi);
862
 
 
863
 
        glFlush();
864
 
 
 
817
        if (MI_IS_FPS(mi)) do_fps (mi);
865
818
        glXSwapBuffers(display, window);
866
819
 
867
820
        mp->step += 0.05;
884
837
{
885
838
        if (morph3d != NULL) {
886
839
                (void) free((void *) morph3d);
887
 
                morph3d = NULL;
 
840
                morph3d = (morph3dstruct *) NULL;
888
841
        }
889
842
        FreeAllGL(mi);
890
843
}