. More Watcom C++ warnings fixed in Mesa.
[mesa.git] / src / glu / mesa / nurbs.h
1 /* $Id: nurbs.h,v 1.2 1999/11/11 03:21:43 kendallb Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
6 * Copyright (C) 1995-1999 Brian Paul
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23
24 /*
25 * $Log: nurbs.h,v $
26 * Revision 1.2 1999/11/11 03:21:43 kendallb
27 *
28 * . Updated GL/gl.h with GLCALLACKP and GLAPIENTRYP macros for compatibility
29 * with the IBM VisualAge C++ compiler. Eventually some more code will be
30 * needed in the headers to enable the reversal of (__stdcall*) to (*__stdcall)
31 * for the IBM compilers, however we currently build using our own header files
32 * that already handle this.
33 *
34 * . Changed instances of (GLCALLBACK*) to GLCALLBACKP for compatibility
35 * with the IBM VisualAge C++ compiler in src-glu.
36 *
37 * . Misc cleanups for warnings generated with Watcom C++ in src-glu. Compiles
38 * with 0 warnings now.
39 *
40 * . tess_hash.c: line 244 - Why is this function stubbed out? I removed the
41 * code with a #if 0 to avoid a compiler warning, but it looks dangerous.
42 *
43 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
44 * Imported sources
45 *
46 * Revision 1.5 1999/02/27 13:55:31 brianp
47 * fixed BeOS-related GLU typedef problems
48 *
49 * Revision 1.4 1999/01/03 03:23:15 brianp
50 * now using GLAPIENTRY and GLCALLBACK keywords (Ted Jump)
51 *
52 * Revision 1.3 1997/05/27 03:18:23 brianp
53 * minor clean-up
54 *
55 * Revision 1.2 1997/05/27 03:00:16 brianp
56 * incorporated Bogdan's new NURBS code
57 *
58 * Revision 1.1 1996/09/27 01:19:39 brianp
59 * Initial revision
60 *
61 */
62
63
64 /*
65 * NURBS implementation written by Bogdan Sikorski (bogdan@cira.it)
66 * See README2 for more info.
67 */
68
69
70 #ifndef NURBS_H
71 #define NURBS_H
72
73
74 #define EPSILON 1e-06 /* epsilon for double precision compares */
75
76 typedef enum
77 {
78 GLU_NURBS_CURVE, GLU_NURBS_SURFACE, GLU_NURBS_TRIM, GLU_NURBS_NO_TRIM,
79 GLU_NURBS_TRIM_DONE, GLU_NURBS_NONE
80 } GLU_nurbs_enum;
81
82 typedef enum
83 {
84 GLU_TRIM_NURBS, GLU_TRIM_PWL
85 } GLU_trim_enum;
86
87 typedef struct
88 {
89 GLint sknot_count;
90 GLfloat *sknot;
91 GLint tknot_count;
92 GLfloat *tknot;
93 GLint s_stride;
94 GLint t_stride;
95 GLfloat *ctrlarray;
96 GLint sorder;
97 GLint torder;
98 GLint dim;
99 GLenum type;
100 } surface_attribs;
101
102 typedef struct
103 {
104 surface_attribs geom;
105 surface_attribs color;
106 surface_attribs texture;
107 surface_attribs normal;
108 } nurbs_surface;
109
110 typedef struct
111 {
112 GLint knot_count;
113 GLfloat *knot;
114 GLint stride;
115 GLfloat *ctrlarray;
116 GLint order;
117 GLint dim;
118 GLenum type;
119 } curve_attribs;
120
121 typedef struct
122 {
123 GLint pt_count;
124 GLfloat *ctrlarray;
125 GLint stride;
126 GLint dim;
127 GLenum type;
128 } pwl_curve_attribs;
129
130 typedef struct
131 {
132 curve_attribs geom;
133 curve_attribs color;
134 curve_attribs texture;
135 curve_attribs normal;
136 } nurbs_curve;
137
138 typedef struct trim_list_str
139 {
140 GLU_trim_enum trim_type;
141 union
142 {
143 pwl_curve_attribs pwl_curve;
144 curve_attribs nurbs_curve;
145 } curve;
146 struct trim_list_str *next;
147 } trim_list;
148
149 typedef struct seg_trim_str
150 {
151 GLfloat *points;
152 GLint pt_cnt,seg_array_len;
153 struct seg_trim_str *next;
154 } trim_segments;
155
156 typedef struct nurbs_trim_str
157 {
158 trim_list *trim_loop;
159 trim_segments *segments;
160 struct nurbs_trim_str *next;
161 } nurbs_trim;
162
163 typedef struct
164 {
165 GLfloat model[16],proj[16],viewport[4];
166 } culling_and_sampling_str;
167
168 struct GLUnurbs {
169 GLboolean culling;
170 GLenum error;
171 void (GLCALLBACKP error_callback)( GLenum err );
172 GLenum display_mode;
173 GLU_nurbs_enum nurbs_type;
174 GLboolean auto_load_matrix;
175 culling_and_sampling_str
176 sampling_matrices;
177 GLenum sampling_method;
178 GLfloat sampling_tolerance;
179 GLfloat parametric_tolerance;
180 GLint u_step, v_step;
181 nurbs_surface surface;
182 nurbs_curve curve;
183 nurbs_trim *trim;
184 };
185
186 typedef struct
187 {
188 GLfloat *knot;
189 GLint nknots;
190 GLfloat *unified_knot;
191 GLint unified_nknots;
192 GLint order;
193 GLint t_min,t_max;
194 GLint delta_nknots;
195 GLboolean open_at_begin,open_at_end;
196 GLfloat *new_knot;
197 GLfloat *alpha;
198 } knot_str_type;
199
200 typedef struct
201 {
202 GLfloat *geom_ctrl;
203 GLint geom_s_stride,geom_t_stride;
204 GLfloat **geom_offsets;
205 GLint geom_s_pt_cnt,geom_t_pt_cnt;
206 GLfloat *color_ctrl;
207 GLint color_s_stride,color_t_stride;
208 GLfloat **color_offsets;
209 GLint color_s_pt_cnt,color_t_pt_cnt;
210 GLfloat *normal_ctrl;
211 GLint normal_s_stride,normal_t_stride;
212 GLfloat **normal_offsets;
213 GLint normal_s_pt_cnt,normal_t_pt_cnt;
214 GLfloat *texture_ctrl;
215 GLint texture_s_stride,texture_t_stride;
216 GLfloat **texture_offsets;
217 GLint texture_s_pt_cnt,texture_t_pt_cnt;
218 GLint s_bezier_cnt,t_bezier_cnt;
219 } new_ctrl_type;
220
221 extern void call_user_error( GLUnurbsObj *nobj, GLenum error );
222
223 extern GLenum test_knot(GLint nknots, GLfloat *knot, GLint order);
224
225 extern GLenum explode_knot(knot_str_type *the_knot);
226
227 extern GLenum calc_alphas(knot_str_type *the_knot);
228
229 extern GLenum calc_new_ctrl_pts(GLfloat *ctrl,GLint stride,knot_str_type *the_knot,
230 GLint dim,GLfloat **new_ctrl,GLint *ncontrol);
231
232 extern GLenum glu_do_sampling_crv(GLUnurbsObj *nobj, GLfloat *new_ctrl,GLint n_ctrl,
233 GLint order,GLint dim,GLint **factors);
234
235 extern GLenum glu_do_sampling_3D(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl,
236 int **sfactors, GLint **tfactors);
237
238 extern GLenum glu_do_sampling_uv(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl,
239 int **sfactors, GLint **tfactors);
240
241 extern GLenum glu_do_sampling_param_3D(GLUnurbsObj *nobj, new_ctrl_type *new_ctrl,
242 int **sfactors, GLint **tfactors);
243
244 extern GLboolean fine_culling_test_2D(GLUnurbsObj *nobj, GLfloat *ctrl, GLint n_ctrl,
245 GLint stride, GLint dim);
246
247 extern GLboolean fine_culling_test_3D(GLUnurbsObj *nobj, GLfloat *ctrl,
248 GLint s_n_ctrl, GLint t_n_ctrl, GLint s_stride, GLint t_stride, GLint dim);
249
250 extern void do_nurbs_curve( GLUnurbsObj *nobj);
251
252 extern void do_nurbs_surface( GLUnurbsObj *nobj);
253
254 extern GLenum patch_trimming(GLUnurbsObj *nobj,new_ctrl_type *new_ctrl,
255 GLint *sfactors, GLint *tfactors);
256
257 extern void collect_unified_knot(knot_str_type *dest, knot_str_type *src,
258 GLfloat maximal_min_knot, GLfloat minimal_max_knot);
259
260 extern GLenum select_knot_working_range(GLUnurbsObj *nobj,knot_str_type *geom_knot,
261 knot_str_type *color_knot, knot_str_type *normal_knot,
262 knot_str_type *texture_knot);
263
264 extern void free_unified_knots(knot_str_type *geom_knot, knot_str_type *color_knot,
265 knot_str_type *normal_knot, knot_str_type *texture_knot);
266
267
268
269 #endif