1 
2 /*
3  * FILE:
4  * tube_gc.h
5  *
6  * FUNCTION:
7  * This file defines all of the extrusion library state info
8  * (i.e. the GLE graphics context).  The GLE library is 'almost'
9  * thread-safe, in that there really is only one global to worry
10  * about.  It should be a straight-forward change to move this
11  * single global pointer into a per-thread storage (i.e. so
12  * its fetched with pthread_getspecific()).  If you develop
13  * patches to enable this, please send them in to me --
14  *
15  * HISTORY:
16  * Linas Vepstas <linas@linas.org> --- February 1993
17  * Added auto texture coord generation hooks, Linas April 1994
18  *
19  * Copyright (C) 1993,1994 Linas Vepstas <linas@linas.org>
20  */
21 
22 #ifndef GLE_TUBE_GC_H_
23 #define GLE_TUBE_GC_H_
24 
25 typedef double gleTwoVec[2];
26 
27 typedef struct {
28 
29    /* public methods */
30    void (*bgn_gen_texture) (int, double);
31    void (*n3f_gen_texture) (float *);
32    void (*n3d_gen_texture) (double *);
33    void (*v3f_gen_texture) (float *, int, int);
34    void (*v3d_gen_texture) (double *, int, int);
35    void (*end_gen_texture) (void);
36 
37    /* protected members -- "general knowledge" stuff */
38    /* The joinstyle is set by the JoinStyle subroutine,
39     * and controls the rendering of the tubing joins. */
40    int join_style;
41 
42    /* The 'slices' parameter controls the number of 'pie slices'
43     * used to generate cones and cylinders. */
44    int slices;
45    gleTwoVec *circle;   /* 2D contour for circle */
46    gleTwoVec *norm;     /* normal vectors for circle */
47 
48    /* arguments passed into extrusion code */
49    int ncp;     /* number of contour points */
50    gleTwoVec *contour;    /* 2D contour */
51    gleTwoVec *cont_normal;  /* 2D contour normals */
52    gleDouble *up;               /* up vector */
53    int npoints;  /* number of points in polyline */
54    gleVector *point_array;     /* path */
55    gleColor *color_array;         /* path colors */
56    gleAffine *xform_array;  /* contour xforms */
57 
58    /* private members, used by texturing code */
59    int num_vert;
60    int segment_number;
61    double segment_length;
62    double accum_seg_len;
63    double prev_x;
64    double prev_y;
65 
66    void (*save_bgn_gen_texture) (int, double);
67    void (*save_n3f_gen_texture) (float *);
68    void (*save_n3d_gen_texture) (double *);
69    void (*save_v3f_gen_texture) (float *, int, int);
70    void (*save_v3d_gen_texture) (double *, int, int);
71    void (*save_end_gen_texture) (void);
72 
73 } gleGC;
74 
75 extern gleGC *_gle_gc;
76 extern gleGC * gleCreateGC (void);
77 
78 #define INIT_GC() {if (!_gle_gc) { _gle_gc = gleCreateGC(); atexit (gleDestroyGC);} }
79 #define extrusion_join_style (_gle_gc->join_style)
80 
81 #define __TESS_SLICES (_gle_gc->slices)
82 #define __TESS_CIRCLE (_gle_gc->circle)
83 #define __TESS_NORM   (_gle_gc->norm)
84 
85 #define __TUBE_CLOSE_CONTOUR (extrusion_join_style & TUBE_CONTOUR_CLOSED)
86 #define __TUBE_DRAW_CAP (extrusion_join_style & TUBE_JN_CAP)
87 #define __TUBE_DRAW_FACET_NORMALS (extrusion_join_style & TUBE_NORM_FACET)
88 #define __TUBE_DRAW_PATH_EDGE_NORMALS (extrusion_join_style & TUBE_NORM_PATH_EDGE)
89 
90 #define __TUBE_STYLE (extrusion_join_style & TUBE_JN_MASK)
91 #define __TUBE_RAW_JOIN (extrusion_join_style & TUBE_JN_RAW)
92 #define __TUBE_CUT_JOIN (extrusion_join_style & TUBE_JN_CUT)
93 #define __TUBE_ANGLE_JOIN (extrusion_join_style & TUBE_JN_ANGLE)
94 #define __TUBE_ROUND_JOIN (extrusion_join_style & TUBE_JN_ROUND)
95 
96 #endif /* GLE_TUBE_GC_H_ */
97 
98 /* ======================= END OF FILE ========================== */
99