From http://www.jwz.org/xscreensaver/xscreensaver-5.40.tar.gz
[xscreensaver] / hacks / glx / extrusion-helix4.c
1
2 /* 
3  * helicoid (gernalized torus) demo 
4  *
5  * FUNCTION:
6  * This code provides a very simple example of the helicoid primitive.
7  * Most of this code is required to set up OpenGL and GLUT, and very
8  * very little to set up the helix drawer. Don't blink!
9  *
10  * =======> MOUSE HOOKED UP TO AFFINE < ========
11  *
12  * HISTORY:
13  * Written by Linas Vepstas, March 1995
14  */
15
16 #include "extrusion.h"
17
18 /* controls shape of object */
19 extern float lastx;
20 extern float lasty;
21
22 void InitStuff_helix4 (void) 
23 {
24 }
25
26 /* draw the helix shape */
27 void DrawStuff_helix4 (void) 
28 {
29    double affine[2][3];
30    double delta_affine[2][3];
31
32    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
33    glColor3f (0.7, 0.5, 0.3);
34
35    /* set up some matrices so that the object spins with the mouse */
36    glPushMatrix ();
37 /* glTranslatef (0.0, 0.0, -80.0); */
38 /* glRotatef (220.0, 0.0, 1.0, 0.0); */
39 /* glRotatef (65.0, 1.0, 0.0, 0.0); */
40
41    /* Phew. FINALLY, Draw the helix  -- */
42    affine [0][0] = 1.0/ (0.01*lastx);
43    affine [1][0] = 0.0;
44    affine [0][1] = 0.0;
45    affine [1][1] = 0.01*lastx;
46    affine [0][2] = 0.0;
47    affine [1][2] = 0.0;
48
49    delta_affine [0][0] = 0.0;
50    delta_affine [1][0] = 0.03*lasty;
51    delta_affine [0][1] = -0.03*lasty;
52    delta_affine [1][1] = 0.0;
53    delta_affine [0][2] = 0.0;
54    delta_affine [1][2] = 0.0;
55
56    gleSetJoinStyle (TUBE_NORM_EDGE | TUBE_JN_ANGLE | TUBE_JN_CAP);
57    gleHelicoid (1.0, 7.0, -1.0, 
58                -4.0, 6.0, affine, delta_affine, 0.0, 980.0);
59
60    glPopMatrix ();
61
62 }
63 /* ------------------------- end of file ----------------- */