2 /* cylinder drawing demo */
3 /* this demo demonstrates the various join styles */
5 /* required include files */
10 /* ------------------------------------------------------- */
12 /* the arrays in which we will store the polyline */
14 double points [NPTS][3];
15 float colors [NPTS][3];
18 /* some utilities for filling that array */
20 #define PNT(x,y,z) { \
21 points[idx][0] = PSCALE * x; \
22 points[idx][1] = PSCALE * y; \
23 points[idx][2] = PSCALE * z; \
27 #define COL(r,g,b) { \
33 /* the arrays in which we will store the contour */
35 double contour_points [NCONTOUR][2];
38 /* some utilities for filling that array */
39 #define C_PNT(x,y) { \
40 contour_points[cidx][0] = x; \
41 contour_points[cidx][1] = y; \
46 /* ------------------------------------------------------- */
48 * Initialize a bent shape with three segments.
49 * The data format is a polyline.
51 * NOTE that neither the first, nor the last segment are drawn.
52 * The first & last segment serve only to determine that angle
53 * at which the endcaps are drawn.
56 void InitStuff_joinoffset (void)
62 PNT (0.0, -16.0, 0.0);
65 PNT (-16.0, 0.0, 0.0);
74 PNT (0.0, -16.0, 0.0);
77 PNT (-16.0, 0.0, 0.0);
91 gleSetJoinStyle (TUBE_JN_ANGLE | TUBE_CONTOUR_CLOSED | TUBE_JN_CAP);
94 double up_vector[3] = {1.0, 0.0, 0.0};
99 /* ------------------------------------------------------- */
100 /* draw the extrusion */
102 void DrawStuff_joinoffset (void)
104 double moved_contour [NCONTOUR][2];
105 int style, save_style;
108 for (i=0; i<cidx; i++) {
109 moved_contour[i][0] = contour_points [i][0];
110 moved_contour[i][1] = contour_points [i][1] + 0.05 * (lasty-200.0);
113 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
115 /* set up some matrices so that the object spins with the mouse */
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 glTranslatef (0.0, -4.0, -80.0);
130 glRotatef (0.5*lastx, 0.0, 1.0, 0.0);
132 save_style = gleGetJoinStyle ();
134 style &= ~TUBE_JN_MASK;
135 style |= TUBE_JN_RAW;
136 gleSetJoinStyle (style);
138 gleExtrusion (cidx, moved_contour, contour_points, up_vector,
139 idx, points, colors);
141 gleSetJoinStyle (save_style);
146 /* ------------------ end of file ----------------------------- */