2 /* cylinder drawing demo */
3 /* this demo demonstrates the various join styles */
5 /* required include files */
11 /*#include <GL/glut.h>*/
18 /* ------------------------------------------------------- */
20 /* the arrays in which we will store the polyline */
22 static double points [NPTS][3];
23 static float colors [NPTS][3];
26 /* some utilities for filling that array */
28 #define PNT(x,y,z) { \
29 points[idx][0] = PSCALE * x; \
30 points[idx][1] = PSCALE * y; \
31 points[idx][2] = PSCALE * z; \
35 #define COL(r,g,b) { \
41 /* the arrays in which we will store the contour */
43 static double contour_points [NCONTOUR][2];
46 /* some utilities for filling that array */
47 #define C_PNT(x,y) { \
48 contour_points[cidx][0] = x; \
49 contour_points[cidx][1] = y; \
54 /* ------------------------------------------------------- */
56 * Initialize a bent shape with three segments.
57 * The data format is a polyline.
59 * NOTE that neither the first, nor the last segment are drawn.
60 * The first & last segment serve only to determine that angle
61 * at which the endcaps are drawn.
64 void InitStuff_joinoffset (void)
70 PNT (0.0, -16.0, 0.0);
73 PNT (-16.0, 0.0, 0.0);
82 PNT (0.0, -16.0, 0.0);
85 PNT (-16.0, 0.0, 0.0);
99 gleSetJoinStyle (TUBE_JN_ANGLE | TUBE_CONTOUR_CLOSED | TUBE_JN_CAP);
102 static double up_vector[3] = {1.0, 0.0, 0.0};
104 /* controls shape of object */
108 /* ------------------------------------------------------- */
109 /* draw the extrusion */
111 void DrawStuff_joinoffset (void)
113 double moved_contour [NCONTOUR][2];
114 int style, save_style;
117 for (i=0; i<cidx; i++) {
118 moved_contour[i][0] = contour_points [i][0];
119 moved_contour[i][1] = contour_points [i][1] + 0.05 * (lasty-200.0);
122 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
124 /* set up some matrices so that the object spins with the mouse */
126 glScalef (0.5, 0.5, 0.5);
127 glTranslatef (0, 4, 0);
128 /* glTranslatef (0.0, 4.0, -80.0); */
129 /* glRotatef (0.5*lastx, 0.0, 1.0, 0.0); */
131 gleExtrusion (cidx, moved_contour, contour_points, up_vector,
132 idx, points, colors);
137 /* draw a seond copy, this time with the raw style, to compare
140 glScalef (0.5, 0.5, 0.5);
141 glTranslatef (0, -4, 0);
142 /* glTranslatef (0.0, -4.0, -80.0); */
143 /* glRotatef (0.5*lastx, 0.0, 1.0, 0.0); */
145 save_style = gleGetJoinStyle ();
147 style &= ~TUBE_JN_MASK;
148 style |= TUBE_JN_RAW;
149 gleSetJoinStyle (style);
151 gleExtrusion (cidx, moved_contour, contour_points, up_vector,
152 idx, points, colors);
154 gleSetJoinStyle (save_style);
159 /* ------------------ end of file ----------------------------- */