2 /* cylinder drawing demo */
3 /* this demo demonstrates the various join styles */
7 /* ------------------------------------------------------- */
9 /* the arrays in which we will store the polyline */
11 static double points [NPTS][3];
12 static float colors [NPTS][3];
15 /* some utilities for filling that array */
17 #define PNT(x,y,z) { \
18 points[idx][0] = PSCALE * x; \
19 points[idx][1] = PSCALE * y; \
20 points[idx][2] = PSCALE * z; \
24 #define COL(r,g,b) { \
30 /* the arrays in which we will store the contour */
32 static double contour_points [NCONTOUR][2];
35 /* some utilities for filling that array */
36 #define C_PNT(x,y) { \
37 contour_points[cidx][0] = x; \
38 contour_points[cidx][1] = y; \
43 /* ------------------------------------------------------- */
45 * Initialize a bent shape with three segments.
46 * The data format is a polyline.
48 * NOTE that neither the first, nor the last segment are drawn.
49 * The first & last segment serve only to determine that angle
50 * at which the endcaps are drawn.
53 void InitStuff_joinoffset (void)
59 PNT (0.0, -16.0, 0.0);
62 PNT (-16.0, 0.0, 0.0);
71 PNT (0.0, -16.0, 0.0);
74 PNT (-16.0, 0.0, 0.0);
88 gleSetJoinStyle (TUBE_JN_ANGLE | TUBE_CONTOUR_CLOSED | TUBE_JN_CAP);
91 static double up_vector[3] = {1.0, 0.0, 0.0};
93 /* controls shape of object */
97 /* ------------------------------------------------------- */
98 /* draw the extrusion */
100 void DrawStuff_joinoffset (void)
102 double moved_contour [NCONTOUR][2];
103 int style, save_style;
106 for (i=0; i<cidx; i++) {
107 moved_contour[i][0] = contour_points [i][0];
108 moved_contour[i][1] = contour_points [i][1] + 0.05 * (lasty-200.0);
111 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
113 /* set up some matrices so that the object spins with the mouse */
115 glScalef (0.5, 0.5, 0.5);
116 glTranslatef (0, 4, 0);
117 /* glTranslatef (0.0, 4.0, -80.0); */
118 /* glRotatef (0.5*lastx, 0.0, 1.0, 0.0); */
120 gleExtrusion (cidx, moved_contour, contour_points, up_vector,
121 idx, points, colors);
126 /* draw a seond copy, this time with the raw style, to compare
129 glScalef (0.5, 0.5, 0.5);
130 glTranslatef (0, -4, 0);
131 /* glTranslatef (0.0, -4.0, -80.0); */
132 /* glRotatef (0.5*lastx, 0.0, 1.0, 0.0); */
134 save_style = gleGetJoinStyle ();
136 style &= ~TUBE_JN_MASK;
137 style |= TUBE_JN_RAW;
138 gleSetJoinStyle (style);
140 gleExtrusion (cidx, moved_contour, contour_points, up_vector,
141 idx, points, colors);
143 gleSetJoinStyle (save_style);
148 /* ------------------ end of file ----------------------------- */