c74fc59c8678e998305c4a42ce3c666c4ff0eb3e
[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 /* required include files */
17 #ifdef HAVE_CONFIG_H
18 #include <config.h>
19 #endif
20
21 #include <GL/gl.h>
22 /*#include <GL/glut.h>*/
23 #ifdef HAVE_GLE3
24 #include <GL/gle.h>
25 #else
26 #include <GL/tube.h>
27 #endif
28
29 /*  most recent mouse postion */
30 extern float lastx;
31 extern float lasty;
32 extern float rot_x;
33 extern float rot_y;
34 extern float rot_z;
35
36 void InitStuff_helix4 (void) 
37 {
38 }
39
40 /* draw the helix shape */
41 void DrawStuff_helix4 (void) 
42 {
43    double affine[2][3];
44    double delta_affine[2][3];
45
46    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
47    glColor3f (0.7, 0.5, 0.3);
48
49    /* set up some matrices so that the object spins with the mouse */
50    glPushMatrix ();
51    glTranslatef (0.0, 0.0, -80.0);
52    glRotatef(rot_x, 1, 0, 0);
53    glRotatef(rot_y, 0, 1, 0);
54    glRotatef(rot_z, 0, 0, 1);
55 /*     glRotatef (220.0, 0.0, 1.0, 0.0); */
56 /*     glRotatef (65.0, 1.0, 0.0, 0.0); */
57
58    /* Phew. FINALLY, Draw the helix  -- */
59    affine [0][0] = 1.0/ (0.01*lastx);
60    affine [1][0] = 0.0;
61    affine [0][1] = 0.0;
62    affine [1][1] = 0.01*lastx;
63    affine [0][2] = 0.0;
64    affine [1][2] = 0.0;
65
66    delta_affine [0][0] = 0.0;
67    delta_affine [1][0] = 0.03*lasty;
68    delta_affine [0][1] = -0.03*lasty;
69    delta_affine [1][1] = 0.0;
70    delta_affine [0][2] = 0.0;
71    delta_affine [1][2] = 0.0;
72
73    gleSetJoinStyle (TUBE_NORM_EDGE | TUBE_JN_ANGLE | TUBE_JN_CAP);
74    gleHelicoid (1.0, 7.0, -1.0, 
75                -4.0, 6.0, affine, delta_affine, 0.0, 980.0);
76
77    glPopMatrix ();
78
79 }
80 /* ------------------------- end of file ----------------- */