1 | /* $Id: eval.c,v 1.3 2000-05-23 20:40:32 jeroen Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * eval.c was written by
|
---|
30 | * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
|
---|
31 | * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
|
---|
32 | *
|
---|
33 | * My original implementation of evaluators was simplistic and didn't
|
---|
34 | * compute surface normal vectors properly. Bernd and Volker applied
|
---|
35 | * used more sophisticated methods to get better results.
|
---|
36 | *
|
---|
37 | * Thanks guys!
|
---|
38 | */
|
---|
39 |
|
---|
40 |
|
---|
41 | #ifdef PC_HEADER
|
---|
42 | #include "all.h"
|
---|
43 | #else
|
---|
44 | #include "glheader.h"
|
---|
45 | #include "types.h"
|
---|
46 | #include "context.h"
|
---|
47 | #include "eval.h"
|
---|
48 | #include "macros.h"
|
---|
49 | #include "mmath.h"
|
---|
50 | #include "mem.h"
|
---|
51 | #include "types.h"
|
---|
52 | #include "vbcull.h"
|
---|
53 | #include "vbfill.h"
|
---|
54 | #include "vbxform.h"
|
---|
55 | #endif
|
---|
56 |
|
---|
57 |
|
---|
58 | static GLfloat inv_tab[MAX_EVAL_ORDER];
|
---|
59 |
|
---|
60 | /*
|
---|
61 | * Do one-time initialization for evaluators.
|
---|
62 | */
|
---|
63 | void gl_init_eval( void )
|
---|
64 | {
|
---|
65 | static int init_flag = 0;
|
---|
66 | GLuint i;
|
---|
67 |
|
---|
68 | /* Compute a table of nCr (combination) values used by the
|
---|
69 | * Bernstein polynomial generator.
|
---|
70 | */
|
---|
71 |
|
---|
72 | /* KW: precompute 1/x for useful x.
|
---|
73 | */
|
---|
74 | if (init_flag==0)
|
---|
75 | {
|
---|
76 | for (i = 1 ; i < MAX_EVAL_ORDER ; i++)
|
---|
77 | inv_tab[i] = 1.0 / i;
|
---|
78 | }
|
---|
79 |
|
---|
80 | init_flag = 1;
|
---|
81 | }
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 | /*
|
---|
86 | * Horner scheme for Bezier curves
|
---|
87 | *
|
---|
88 | * Bezier curves can be computed via a Horner scheme.
|
---|
89 | * Horner is numerically less stable than the de Casteljau
|
---|
90 | * algorithm, but it is faster. For curves of degree n
|
---|
91 | * the complexity of Horner is O(n) and de Casteljau is O(n^2).
|
---|
92 | * Since stability is not important for displaying curve
|
---|
93 | * points I decided to use the Horner scheme.
|
---|
94 | *
|
---|
95 | * A cubic Bezier curve with control points b0, b1, b2, b3 can be
|
---|
96 | * written as
|
---|
97 | *
|
---|
98 | * (([3] [3] ) [3] ) [3]
|
---|
99 | * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
|
---|
100 | *
|
---|
101 | * [n]
|
---|
102 | * where s=1-t and the binomial coefficients [i]. These can
|
---|
103 | * be computed iteratively using the identity:
|
---|
104 | *
|
---|
105 | * [n] [n ] [n]
|
---|
106 | * [i] = (n-i+1)/i * [i-1] and [0] = 1
|
---|
107 | */
|
---|
108 |
|
---|
109 |
|
---|
110 | static void
|
---|
111 | horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t,
|
---|
112 | GLuint dim, GLuint order)
|
---|
113 | {
|
---|
114 | GLfloat s, powert;
|
---|
115 | GLuint i, k, bincoeff;
|
---|
116 |
|
---|
117 | if(order >= 2)
|
---|
118 | {
|
---|
119 | bincoeff = order-1;
|
---|
120 | s = 1.0-t;
|
---|
121 |
|
---|
122 | for(k=0; k<dim; k++)
|
---|
123 | out[k] = s*cp[k] + bincoeff*t*cp[dim+k];
|
---|
124 |
|
---|
125 | for(i=2, cp+=2*dim, powert=t*t; i<order; i++, powert*=t, cp +=dim)
|
---|
126 | {
|
---|
127 | bincoeff *= order-i;
|
---|
128 | bincoeff *= inv_tab[i];
|
---|
129 |
|
---|
130 | for(k=0; k<dim; k++)
|
---|
131 | out[k] = s*out[k] + bincoeff*powert*cp[k];
|
---|
132 | }
|
---|
133 | }
|
---|
134 | else /* order=1 -> constant curve */
|
---|
135 | {
|
---|
136 | for(k=0; k<dim; k++)
|
---|
137 | out[k] = cp[k];
|
---|
138 | }
|
---|
139 | }
|
---|
140 |
|
---|
141 | /*
|
---|
142 | * Tensor product Bezier surfaces
|
---|
143 | *
|
---|
144 | * Again the Horner scheme is used to compute a point on a
|
---|
145 | * TP Bezier surface. First a control polygon for a curve
|
---|
146 | * on the surface in one parameter direction is computed,
|
---|
147 | * then the point on the curve for the other parameter
|
---|
148 | * direction is evaluated.
|
---|
149 | *
|
---|
150 | * To store the curve control polygon additional storage
|
---|
151 | * for max(uorder,vorder) points is needed in the
|
---|
152 | * control net cn.
|
---|
153 | */
|
---|
154 |
|
---|
155 | static void
|
---|
156 | horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v,
|
---|
157 | GLuint dim, GLuint uorder, GLuint vorder)
|
---|
158 | {
|
---|
159 | GLfloat *cp = cn + uorder*vorder*dim;
|
---|
160 | GLuint i, uinc = vorder*dim;
|
---|
161 |
|
---|
162 | if(vorder > uorder)
|
---|
163 | {
|
---|
164 | if(uorder >= 2)
|
---|
165 | {
|
---|
166 | GLfloat s, poweru;
|
---|
167 | GLuint j, k, bincoeff;
|
---|
168 |
|
---|
169 | /* Compute the control polygon for the surface-curve in u-direction */
|
---|
170 | for(j=0; j<vorder; j++)
|
---|
171 | {
|
---|
172 | GLfloat *ucp = &cn[j*dim];
|
---|
173 |
|
---|
174 | /* Each control point is the point for parameter u on a */
|
---|
175 | /* curve defined by the control polygons in u-direction */
|
---|
176 | bincoeff = uorder-1;
|
---|
177 | s = 1.0-u;
|
---|
178 |
|
---|
179 | for(k=0; k<dim; k++)
|
---|
180 | cp[j*dim+k] = s*ucp[k] + bincoeff*u*ucp[uinc+k];
|
---|
181 |
|
---|
182 | for(i=2, ucp+=2*uinc, poweru=u*u; i<uorder;
|
---|
183 | i++, poweru*=u, ucp +=uinc)
|
---|
184 | {
|
---|
185 | bincoeff *= uorder-i;
|
---|
186 | bincoeff *= inv_tab[i];
|
---|
187 |
|
---|
188 | for(k=0; k<dim; k++)
|
---|
189 | cp[j*dim+k] = s*cp[j*dim+k] + bincoeff*poweru*ucp[k];
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | /* Evaluate curve point in v */
|
---|
194 | horner_bezier_curve(cp, out, v, dim, vorder);
|
---|
195 | }
|
---|
196 | else /* uorder=1 -> cn defines a curve in v */
|
---|
197 | horner_bezier_curve(cn, out, v, dim, vorder);
|
---|
198 | }
|
---|
199 | else /* vorder <= uorder */
|
---|
200 | {
|
---|
201 | if(vorder > 1)
|
---|
202 | {
|
---|
203 | GLuint i;
|
---|
204 |
|
---|
205 | /* Compute the control polygon for the surface-curve in u-direction */
|
---|
206 | for(i=0; i<uorder; i++, cn += uinc)
|
---|
207 | {
|
---|
208 | /* For constant i all cn[i][j] (j=0..vorder) are located */
|
---|
209 | /* on consecutive memory locations, so we can use */
|
---|
210 | /* horner_bezier_curve to compute the control points */
|
---|
211 |
|
---|
212 | horner_bezier_curve(cn, &cp[i*dim], v, dim, vorder);
|
---|
213 | }
|
---|
214 |
|
---|
215 | /* Evaluate curve point in u */
|
---|
216 | horner_bezier_curve(cp, out, u, dim, uorder);
|
---|
217 | }
|
---|
218 | else /* vorder=1 -> cn defines a curve in u */
|
---|
219 | horner_bezier_curve(cn, out, u, dim, uorder);
|
---|
220 | }
|
---|
221 | }
|
---|
222 |
|
---|
223 | /*
|
---|
224 | * The direct de Casteljau algorithm is used when a point on the
|
---|
225 | * surface and the tangent directions spanning the tangent plane
|
---|
226 | * should be computed (this is needed to compute normals to the
|
---|
227 | * surface). In this case the de Casteljau algorithm approach is
|
---|
228 | * nicer because a point and the partial derivatives can be computed
|
---|
229 | * at the same time. To get the correct tangent length du and dv
|
---|
230 | * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
|
---|
231 | * Since only the directions are needed, this scaling step is omitted.
|
---|
232 | *
|
---|
233 | * De Casteljau needs additional storage for uorder*vorder
|
---|
234 | * values in the control net cn.
|
---|
235 | */
|
---|
236 |
|
---|
237 | static void
|
---|
238 | de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
|
---|
239 | GLfloat u, GLfloat v, GLuint dim,
|
---|
240 | GLuint uorder, GLuint vorder)
|
---|
241 | {
|
---|
242 | GLfloat *dcn = cn + uorder*vorder*dim;
|
---|
243 | GLfloat us = 1.0-u, vs = 1.0-v;
|
---|
244 | GLuint h, i, j, k;
|
---|
245 | GLuint minorder = uorder < vorder ? uorder : vorder;
|
---|
246 | GLuint uinc = vorder*dim;
|
---|
247 | GLuint dcuinc = vorder;
|
---|
248 |
|
---|
249 | /* Each component is evaluated separately to save buffer space */
|
---|
250 | /* This does not drasticaly decrease the performance of the */
|
---|
251 | /* algorithm. If additional storage for (uorder-1)*(vorder-1) */
|
---|
252 | /* points would be available, the components could be accessed */
|
---|
253 | /* in the innermost loop which could lead to less cache misses. */
|
---|
254 |
|
---|
255 | #define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)]
|
---|
256 | #define DCN(I, J) dcn[(I)*dcuinc+(J)]
|
---|
257 | if(minorder < 3)
|
---|
258 | {
|
---|
259 | if(uorder==vorder)
|
---|
260 | {
|
---|
261 | for(k=0; k<dim; k++)
|
---|
262 | {
|
---|
263 | /* Derivative direction in u */
|
---|
264 | du[k] = vs*(CN(1,0,k) - CN(0,0,k)) +
|
---|
265 | v*(CN(1,1,k) - CN(0,1,k));
|
---|
266 |
|
---|
267 | /* Derivative direction in v */
|
---|
268 | dv[k] = us*(CN(0,1,k) - CN(0,0,k)) +
|
---|
269 | u*(CN(1,1,k) - CN(1,0,k));
|
---|
270 |
|
---|
271 | /* bilinear de Casteljau step */
|
---|
272 | out[k] = us*(vs*CN(0,0,k) + v*CN(0,1,k)) +
|
---|
273 | u*(vs*CN(1,0,k) + v*CN(1,1,k));
|
---|
274 | }
|
---|
275 | }
|
---|
276 | else if(minorder == uorder)
|
---|
277 | {
|
---|
278 | for(k=0; k<dim; k++)
|
---|
279 | {
|
---|
280 | /* bilinear de Casteljau step */
|
---|
281 | DCN(1,0) = CN(1,0,k) - CN(0,0,k);
|
---|
282 | DCN(0,0) = us*CN(0,0,k) + u*CN(1,0,k);
|
---|
283 |
|
---|
284 | for(j=0; j<vorder-1; j++)
|
---|
285 | {
|
---|
286 | /* for the derivative in u */
|
---|
287 | DCN(1,j+1) = CN(1,j+1,k) - CN(0,j+1,k);
|
---|
288 | DCN(1,j) = vs*DCN(1,j) + v*DCN(1,j+1);
|
---|
289 |
|
---|
290 | /* for the `point' */
|
---|
291 | DCN(0,j+1) = us*CN(0,j+1,k) + u*CN(1,j+1,k);
|
---|
292 | DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
|
---|
293 | }
|
---|
294 |
|
---|
295 | /* remaining linear de Casteljau steps until the second last step */
|
---|
296 | for(h=minorder; h<vorder-1; h++)
|
---|
297 | for(j=0; j<vorder-h; j++)
|
---|
298 | {
|
---|
299 | /* for the derivative in u */
|
---|
300 | DCN(1,j) = vs*DCN(1,j) + v*DCN(1,j+1);
|
---|
301 |
|
---|
302 | /* for the `point' */
|
---|
303 | DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
|
---|
304 | }
|
---|
305 |
|
---|
306 | /* derivative direction in v */
|
---|
307 | dv[k] = DCN(0,1) - DCN(0,0);
|
---|
308 |
|
---|
309 | /* derivative direction in u */
|
---|
310 | du[k] = vs*DCN(1,0) + v*DCN(1,1);
|
---|
311 |
|
---|
312 | /* last linear de Casteljau step */
|
---|
313 | out[k] = vs*DCN(0,0) + v*DCN(0,1);
|
---|
314 | }
|
---|
315 | }
|
---|
316 | else /* minorder == vorder */
|
---|
317 | {
|
---|
318 | for(k=0; k<dim; k++)
|
---|
319 | {
|
---|
320 | /* bilinear de Casteljau step */
|
---|
321 | DCN(0,1) = CN(0,1,k) - CN(0,0,k);
|
---|
322 | DCN(0,0) = vs*CN(0,0,k) + v*CN(0,1,k);
|
---|
323 | for(i=0; i<uorder-1; i++)
|
---|
324 | {
|
---|
325 | /* for the derivative in v */
|
---|
326 | DCN(i+1,1) = CN(i+1,1,k) - CN(i+1,0,k);
|
---|
327 | DCN(i,1) = us*DCN(i,1) + u*DCN(i+1,1);
|
---|
328 |
|
---|
329 | /* for the `point' */
|
---|
330 | DCN(i+1,0) = vs*CN(i+1,0,k) + v*CN(i+1,1,k);
|
---|
331 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
332 | }
|
---|
333 |
|
---|
334 | /* remaining linear de Casteljau steps until the second last step */
|
---|
335 | for(h=minorder; h<uorder-1; h++)
|
---|
336 | for(i=0; i<uorder-h; i++)
|
---|
337 | {
|
---|
338 | /* for the derivative in v */
|
---|
339 | DCN(i,1) = us*DCN(i,1) + u*DCN(i+1,1);
|
---|
340 |
|
---|
341 | /* for the `point' */
|
---|
342 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
343 | }
|
---|
344 |
|
---|
345 | /* derivative direction in u */
|
---|
346 | du[k] = DCN(1,0) - DCN(0,0);
|
---|
347 |
|
---|
348 | /* derivative direction in v */
|
---|
349 | dv[k] = us*DCN(0,1) + u*DCN(1,1);
|
---|
350 |
|
---|
351 | /* last linear de Casteljau step */
|
---|
352 | out[k] = us*DCN(0,0) + u*DCN(1,0);
|
---|
353 | }
|
---|
354 | }
|
---|
355 | }
|
---|
356 | else if(uorder == vorder)
|
---|
357 | {
|
---|
358 | for(k=0; k<dim; k++)
|
---|
359 | {
|
---|
360 | /* first bilinear de Casteljau step */
|
---|
361 | for(i=0; i<uorder-1; i++)
|
---|
362 | {
|
---|
363 | DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
|
---|
364 | for(j=0; j<vorder-1; j++)
|
---|
365 | {
|
---|
366 | DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
|
---|
367 | DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
|
---|
368 | }
|
---|
369 | }
|
---|
370 |
|
---|
371 | /* remaining bilinear de Casteljau steps until the second last step */
|
---|
372 | for(h=2; h<minorder-1; h++)
|
---|
373 | for(i=0; i<uorder-h; i++)
|
---|
374 | {
|
---|
375 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
376 | for(j=0; j<vorder-h; j++)
|
---|
377 | {
|
---|
378 | DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
|
---|
379 | DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
|
---|
380 | }
|
---|
381 | }
|
---|
382 |
|
---|
383 | /* derivative direction in u */
|
---|
384 | du[k] = vs*(DCN(1,0) - DCN(0,0)) +
|
---|
385 | v*(DCN(1,1) - DCN(0,1));
|
---|
386 |
|
---|
387 | /* derivative direction in v */
|
---|
388 | dv[k] = us*(DCN(0,1) - DCN(0,0)) +
|
---|
389 | u*(DCN(1,1) - DCN(1,0));
|
---|
390 |
|
---|
391 | /* last bilinear de Casteljau step */
|
---|
392 | out[k] = us*(vs*DCN(0,0) + v*DCN(0,1)) +
|
---|
393 | u*(vs*DCN(1,0) + v*DCN(1,1));
|
---|
394 | }
|
---|
395 | }
|
---|
396 | else if(minorder == uorder)
|
---|
397 | {
|
---|
398 | for(k=0; k<dim; k++)
|
---|
399 | {
|
---|
400 | /* first bilinear de Casteljau step */
|
---|
401 | for(i=0; i<uorder-1; i++)
|
---|
402 | {
|
---|
403 | DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
|
---|
404 | for(j=0; j<vorder-1; j++)
|
---|
405 | {
|
---|
406 | DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
|
---|
407 | DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
|
---|
408 | }
|
---|
409 | }
|
---|
410 |
|
---|
411 | /* remaining bilinear de Casteljau steps until the second last step */
|
---|
412 | for(h=2; h<minorder-1; h++)
|
---|
413 | for(i=0; i<uorder-h; i++)
|
---|
414 | {
|
---|
415 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
416 | for(j=0; j<vorder-h; j++)
|
---|
417 | {
|
---|
418 | DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
|
---|
419 | DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
|
---|
420 | }
|
---|
421 | }
|
---|
422 |
|
---|
423 | /* last bilinear de Casteljau step */
|
---|
424 | DCN(2,0) = DCN(1,0) - DCN(0,0);
|
---|
425 | DCN(0,0) = us*DCN(0,0) + u*DCN(1,0);
|
---|
426 | for(j=0; j<vorder-1; j++)
|
---|
427 | {
|
---|
428 | /* for the derivative in u */
|
---|
429 | DCN(2,j+1) = DCN(1,j+1) - DCN(0,j+1);
|
---|
430 | DCN(2,j) = vs*DCN(2,j) + v*DCN(2,j+1);
|
---|
431 |
|
---|
432 | /* for the `point' */
|
---|
433 | DCN(0,j+1) = us*DCN(0,j+1 ) + u*DCN(1,j+1);
|
---|
434 | DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
|
---|
435 | }
|
---|
436 |
|
---|
437 | /* remaining linear de Casteljau steps until the second last step */
|
---|
438 | for(h=minorder; h<vorder-1; h++)
|
---|
439 | for(j=0; j<vorder-h; j++)
|
---|
440 | {
|
---|
441 | /* for the derivative in u */
|
---|
442 | DCN(2,j) = vs*DCN(2,j) + v*DCN(2,j+1);
|
---|
443 |
|
---|
444 | /* for the `point' */
|
---|
445 | DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
|
---|
446 | }
|
---|
447 |
|
---|
448 | /* derivative direction in v */
|
---|
449 | dv[k] = DCN(0,1) - DCN(0,0);
|
---|
450 |
|
---|
451 | /* derivative direction in u */
|
---|
452 | du[k] = vs*DCN(2,0) + v*DCN(2,1);
|
---|
453 |
|
---|
454 | /* last linear de Casteljau step */
|
---|
455 | out[k] = vs*DCN(0,0) + v*DCN(0,1);
|
---|
456 | }
|
---|
457 | }
|
---|
458 | else /* minorder == vorder */
|
---|
459 | {
|
---|
460 | for(k=0; k<dim; k++)
|
---|
461 | {
|
---|
462 | /* first bilinear de Casteljau step */
|
---|
463 | for(i=0; i<uorder-1; i++)
|
---|
464 | {
|
---|
465 | DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
|
---|
466 | for(j=0; j<vorder-1; j++)
|
---|
467 | {
|
---|
468 | DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
|
---|
469 | DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
|
---|
470 | }
|
---|
471 | }
|
---|
472 |
|
---|
473 | /* remaining bilinear de Casteljau steps until the second last step */
|
---|
474 | for(h=2; h<minorder-1; h++)
|
---|
475 | for(i=0; i<uorder-h; i++)
|
---|
476 | {
|
---|
477 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
478 | for(j=0; j<vorder-h; j++)
|
---|
479 | {
|
---|
480 | DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
|
---|
481 | DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
|
---|
482 | }
|
---|
483 | }
|
---|
484 |
|
---|
485 | /* last bilinear de Casteljau step */
|
---|
486 | DCN(0,2) = DCN(0,1) - DCN(0,0);
|
---|
487 | DCN(0,0) = vs*DCN(0,0) + v*DCN(0,1);
|
---|
488 | for(i=0; i<uorder-1; i++)
|
---|
489 | {
|
---|
490 | /* for the derivative in v */
|
---|
491 | DCN(i+1,2) = DCN(i+1,1) - DCN(i+1,0);
|
---|
492 | DCN(i,2) = us*DCN(i,2) + u*DCN(i+1,2);
|
---|
493 |
|
---|
494 | /* for the `point' */
|
---|
495 | DCN(i+1,0) = vs*DCN(i+1,0) + v*DCN(i+1,1);
|
---|
496 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
497 | }
|
---|
498 |
|
---|
499 | /* remaining linear de Casteljau steps until the second last step */
|
---|
500 | for(h=minorder; h<uorder-1; h++)
|
---|
501 | for(i=0; i<uorder-h; i++)
|
---|
502 | {
|
---|
503 | /* for the derivative in v */
|
---|
504 | DCN(i,2) = us*DCN(i,2) + u*DCN(i+1,2);
|
---|
505 |
|
---|
506 | /* for the `point' */
|
---|
507 | DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
|
---|
508 | }
|
---|
509 |
|
---|
510 | /* derivative direction in u */
|
---|
511 | du[k] = DCN(1,0) - DCN(0,0);
|
---|
512 |
|
---|
513 | /* derivative direction in v */
|
---|
514 | dv[k] = us*DCN(0,2) + u*DCN(1,2);
|
---|
515 |
|
---|
516 | /* last linear de Casteljau step */
|
---|
517 | out[k] = us*DCN(0,0) + u*DCN(1,0);
|
---|
518 | }
|
---|
519 | }
|
---|
520 | #undef DCN
|
---|
521 | #undef CN
|
---|
522 | }
|
---|
523 |
|
---|
524 | /*
|
---|
525 | * Return the number of components per control point for any type of
|
---|
526 | * evaluator. Return 0 if bad target.
|
---|
527 | * See table 5.1 in the OpenGL 1.2 spec.
|
---|
528 | */
|
---|
529 | GLuint _mesa_evaluator_components( GLenum target )
|
---|
530 | {
|
---|
531 | switch (target) {
|
---|
532 | case GL_MAP1_VERTEX_3: return 3;
|
---|
533 | case GL_MAP1_VERTEX_4: return 4;
|
---|
534 | case GL_MAP1_INDEX: return 1;
|
---|
535 | case GL_MAP1_COLOR_4: return 4;
|
---|
536 | case GL_MAP1_NORMAL: return 3;
|
---|
537 | case GL_MAP1_TEXTURE_COORD_1: return 1;
|
---|
538 | case GL_MAP1_TEXTURE_COORD_2: return 2;
|
---|
539 | case GL_MAP1_TEXTURE_COORD_3: return 3;
|
---|
540 | case GL_MAP1_TEXTURE_COORD_4: return 4;
|
---|
541 | case GL_MAP2_VERTEX_3: return 3;
|
---|
542 | case GL_MAP2_VERTEX_4: return 4;
|
---|
543 | case GL_MAP2_INDEX: return 1;
|
---|
544 | case GL_MAP2_COLOR_4: return 4;
|
---|
545 | case GL_MAP2_NORMAL: return 3;
|
---|
546 | case GL_MAP2_TEXTURE_COORD_1: return 1;
|
---|
547 | case GL_MAP2_TEXTURE_COORD_2: return 2;
|
---|
548 | case GL_MAP2_TEXTURE_COORD_3: return 3;
|
---|
549 | case GL_MAP2_TEXTURE_COORD_4: return 4;
|
---|
550 | default: return 0;
|
---|
551 | }
|
---|
552 | }
|
---|
553 |
|
---|
554 |
|
---|
555 | /**********************************************************************/
|
---|
556 | /*** Copy and deallocate control points ***/
|
---|
557 | /**********************************************************************/
|
---|
558 |
|
---|
559 |
|
---|
560 | /*
|
---|
561 | * Copy 1-parametric evaluator control points from user-specified
|
---|
562 | * memory space to a buffer of contiguous control points.
|
---|
563 | * Input: see glMap1f for details
|
---|
564 | * Return: pointer to buffer of contiguous control points or NULL if out
|
---|
565 | * of memory.
|
---|
566 | */
|
---|
567 | GLfloat *gl_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
|
---|
568 | const GLfloat *points )
|
---|
569 | {
|
---|
570 | GLfloat *buffer, *p;
|
---|
571 | GLint i, k, size = _mesa_evaluator_components(target);
|
---|
572 |
|
---|
573 | if (!points || size==0) {
|
---|
574 | return NULL;
|
---|
575 | }
|
---|
576 |
|
---|
577 | buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
|
---|
578 |
|
---|
579 | if(buffer)
|
---|
580 | for(i=0, p=buffer; i<uorder; i++, points+=ustride)
|
---|
581 | for(k=0; k<size; k++)
|
---|
582 | *p++ = points[k];
|
---|
583 |
|
---|
584 | return buffer;
|
---|
585 | }
|
---|
586 |
|
---|
587 |
|
---|
588 |
|
---|
589 | /*
|
---|
590 | * Same as above but convert doubles to floats.
|
---|
591 | */
|
---|
592 | GLfloat *gl_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
|
---|
593 | const GLdouble *points )
|
---|
594 | {
|
---|
595 | GLfloat *buffer, *p;
|
---|
596 | GLint i, k, size = _mesa_evaluator_components(target);
|
---|
597 |
|
---|
598 | if (!points || size==0) {
|
---|
599 | return NULL;
|
---|
600 | }
|
---|
601 |
|
---|
602 | buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
|
---|
603 |
|
---|
604 | if(buffer)
|
---|
605 | for(i=0, p=buffer; i<uorder; i++, points+=ustride)
|
---|
606 | for(k=0; k<size; k++)
|
---|
607 | *p++ = (GLfloat) points[k];
|
---|
608 |
|
---|
609 | return buffer;
|
---|
610 | }
|
---|
611 |
|
---|
612 |
|
---|
613 |
|
---|
614 | /*
|
---|
615 | * Copy 2-parametric evaluator control points from user-specified
|
---|
616 | * memory space to a buffer of contiguous control points.
|
---|
617 | * Additional memory is allocated to be used by the horner and
|
---|
618 | * de Casteljau evaluation schemes.
|
---|
619 | *
|
---|
620 | * Input: see glMap2f for details
|
---|
621 | * Return: pointer to buffer of contiguous control points or NULL if out
|
---|
622 | * of memory.
|
---|
623 | */
|
---|
624 | GLfloat *gl_copy_map_points2f( GLenum target,
|
---|
625 | GLint ustride, GLint uorder,
|
---|
626 | GLint vstride, GLint vorder,
|
---|
627 | const GLfloat *points )
|
---|
628 | {
|
---|
629 | GLfloat *buffer, *p;
|
---|
630 | GLint i, j, k, size, dsize, hsize;
|
---|
631 | GLint uinc;
|
---|
632 |
|
---|
633 | size = _mesa_evaluator_components(target);
|
---|
634 |
|
---|
635 | if (!points || size==0) {
|
---|
636 | return NULL;
|
---|
637 | }
|
---|
638 |
|
---|
639 | /* max(uorder, vorder) additional points are used in */
|
---|
640 | /* horner evaluation and uorder*vorder additional */
|
---|
641 | /* values are needed for de Casteljau */
|
---|
642 | dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder;
|
---|
643 | hsize = (uorder > vorder ? uorder : vorder)*size;
|
---|
644 |
|
---|
645 | if(hsize>dsize)
|
---|
646 | buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
|
---|
647 | else
|
---|
648 | buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
|
---|
649 |
|
---|
650 | /* compute the increment value for the u-loop */
|
---|
651 | uinc = ustride - vorder*vstride;
|
---|
652 |
|
---|
653 | if (buffer)
|
---|
654 | for (i=0, p=buffer; i<uorder; i++, points += uinc)
|
---|
655 | for (j=0; j<vorder; j++, points += vstride)
|
---|
656 | for (k=0; k<size; k++)
|
---|
657 | *p++ = points[k];
|
---|
658 |
|
---|
659 | return buffer;
|
---|
660 | }
|
---|
661 |
|
---|
662 |
|
---|
663 |
|
---|
664 | /*
|
---|
665 | * Same as above but convert doubles to floats.
|
---|
666 | */
|
---|
667 | GLfloat *gl_copy_map_points2d(GLenum target,
|
---|
668 | GLint ustride, GLint uorder,
|
---|
669 | GLint vstride, GLint vorder,
|
---|
670 | const GLdouble *points )
|
---|
671 | {
|
---|
672 | GLfloat *buffer, *p;
|
---|
673 | GLint i, j, k, size, hsize, dsize;
|
---|
674 | GLint uinc;
|
---|
675 |
|
---|
676 | size = _mesa_evaluator_components(target);
|
---|
677 |
|
---|
678 | if (!points || size==0) {
|
---|
679 | return NULL;
|
---|
680 | }
|
---|
681 |
|
---|
682 | /* max(uorder, vorder) additional points are used in */
|
---|
683 | /* horner evaluation and uorder*vorder additional */
|
---|
684 | /* values are needed for de Casteljau */
|
---|
685 | dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder;
|
---|
686 | hsize = (uorder > vorder ? uorder : vorder)*size;
|
---|
687 |
|
---|
688 | if(hsize>dsize)
|
---|
689 | buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
|
---|
690 | else
|
---|
691 | buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
|
---|
692 |
|
---|
693 | /* compute the increment value for the u-loop */
|
---|
694 | uinc = ustride - vorder*vstride;
|
---|
695 |
|
---|
696 | if (buffer)
|
---|
697 | for (i=0, p=buffer; i<uorder; i++, points += uinc)
|
---|
698 | for (j=0; j<vorder; j++, points += vstride)
|
---|
699 | for (k=0; k<size; k++)
|
---|
700 | *p++ = (GLfloat) points[k];
|
---|
701 |
|
---|
702 | return buffer;
|
---|
703 | }
|
---|
704 |
|
---|
705 |
|
---|
706 | #if 00
|
---|
707 | /*
|
---|
708 | * This function is called by the display list deallocator function to
|
---|
709 | * specify that a given set of control points are no longer needed.
|
---|
710 | */
|
---|
711 | void gl_free_control_points( GLcontext* ctx, GLenum target, GLfloat *data )
|
---|
712 | {
|
---|
713 | struct gl_1d_map *map1 = NULL;
|
---|
714 | struct gl_2d_map *map2 = NULL;
|
---|
715 |
|
---|
716 | switch (target) {
|
---|
717 | case GL_MAP1_VERTEX_3:
|
---|
718 | map1 = &ctx->EvalMap.Map1Vertex3;
|
---|
719 | break;
|
---|
720 | case GL_MAP1_VERTEX_4:
|
---|
721 | map1 = &ctx->EvalMap.Map1Vertex4;
|
---|
722 | break;
|
---|
723 | case GL_MAP1_INDEX:
|
---|
724 | map1 = &ctx->EvalMap.Map1Index;
|
---|
725 | break;
|
---|
726 | case GL_MAP1_COLOR_4:
|
---|
727 | map1 = &ctx->EvalMap.Map1Color4;
|
---|
728 | break;
|
---|
729 | case GL_MAP1_NORMAL:
|
---|
730 | map1 = &ctx->EvalMap.Map1Normal;
|
---|
731 | break;
|
---|
732 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
733 | map1 = &ctx->EvalMap.Map1Texture1;
|
---|
734 | break;
|
---|
735 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
736 | map1 = &ctx->EvalMap.Map1Texture2;
|
---|
737 | break;
|
---|
738 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
739 | map1 = &ctx->EvalMap.Map1Texture3;
|
---|
740 | break;
|
---|
741 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
742 | map1 = &ctx->EvalMap.Map1Texture4;
|
---|
743 | break;
|
---|
744 | case GL_MAP2_VERTEX_3:
|
---|
745 | map2 = &ctx->EvalMap.Map2Vertex3;
|
---|
746 | break;
|
---|
747 | case GL_MAP2_VERTEX_4:
|
---|
748 | map2 = &ctx->EvalMap.Map2Vertex4;
|
---|
749 | break;
|
---|
750 | case GL_MAP2_INDEX:
|
---|
751 | map2 = &ctx->EvalMap.Map2Index;
|
---|
752 | break;
|
---|
753 | case GL_MAP2_COLOR_4:
|
---|
754 | map2 = &ctx->EvalMap.Map2Color4;
|
---|
755 | break;
|
---|
756 | case GL_MAP2_NORMAL:
|
---|
757 | map2 = &ctx->EvalMap.Map2Normal;
|
---|
758 | break;
|
---|
759 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
760 | map2 = &ctx->EvalMap.Map2Texture1;
|
---|
761 | break;
|
---|
762 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
763 | map2 = &ctx->EvalMap.Map2Texture2;
|
---|
764 | break;
|
---|
765 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
766 | map2 = &ctx->EvalMap.Map2Texture3;
|
---|
767 | break;
|
---|
768 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
769 | map2 = &ctx->EvalMap.Map2Texture4;
|
---|
770 | break;
|
---|
771 | default:
|
---|
772 | gl_error( ctx, GL_INVALID_ENUM, "gl_free_control_points" );
|
---|
773 | return;
|
---|
774 | }
|
---|
775 |
|
---|
776 | if (map1) {
|
---|
777 | if (data==map1->Points) {
|
---|
778 | /* The control points in the display list are currently */
|
---|
779 | /* being used so we can mark them as discard-able. */
|
---|
780 | map1->Retain = GL_FALSE;
|
---|
781 | }
|
---|
782 | else {
|
---|
783 | /* The control points in the display list are not currently */
|
---|
784 | /* being used. */
|
---|
785 | FREE( data );
|
---|
786 | }
|
---|
787 | }
|
---|
788 | if (map2) {
|
---|
789 | if (data==map2->Points) {
|
---|
790 | /* The control points in the display list are currently */
|
---|
791 | /* being used so we can mark them as discard-able. */
|
---|
792 | map2->Retain = GL_FALSE;
|
---|
793 | }
|
---|
794 | else {
|
---|
795 | /* The control points in the display list are not currently */
|
---|
796 | /* being used. */
|
---|
797 | FREE( data );
|
---|
798 | }
|
---|
799 | }
|
---|
800 |
|
---|
801 | }
|
---|
802 | #endif
|
---|
803 |
|
---|
804 |
|
---|
805 |
|
---|
806 | /**********************************************************************/
|
---|
807 | /*** API entry points ***/
|
---|
808 | /**********************************************************************/
|
---|
809 |
|
---|
810 |
|
---|
811 | /*
|
---|
812 | * This does the work of glMap1[fd].
|
---|
813 | */
|
---|
814 | static void
|
---|
815 | map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
|
---|
816 | GLint uorder, const GLvoid *points, GLenum type )
|
---|
817 | {
|
---|
818 | GET_CURRENT_CONTEXT(ctx);
|
---|
819 | GLint k;
|
---|
820 | GLfloat *pnts;
|
---|
821 |
|
---|
822 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap1");
|
---|
823 |
|
---|
824 | ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
|
---|
825 |
|
---|
826 | if (u1 == u2) {
|
---|
827 | gl_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" );
|
---|
828 | return;
|
---|
829 | }
|
---|
830 | if (uorder < 1 || uorder > MAX_EVAL_ORDER) {
|
---|
831 | gl_error( ctx, GL_INVALID_VALUE, "glMap1(order)" );
|
---|
832 | return;
|
---|
833 | }
|
---|
834 | if (!points) {
|
---|
835 | gl_error( ctx, GL_INVALID_VALUE, "glMap1(points)" );
|
---|
836 | return;
|
---|
837 | }
|
---|
838 |
|
---|
839 | k = _mesa_evaluator_components( target );
|
---|
840 | if (k == 0) {
|
---|
841 | gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
|
---|
842 | }
|
---|
843 |
|
---|
844 | if (ustride < k) {
|
---|
845 | gl_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" );
|
---|
846 | return;
|
---|
847 | }
|
---|
848 |
|
---|
849 | /* make copy of the control points */
|
---|
850 | if (type == GL_FLOAT)
|
---|
851 | pnts = gl_copy_map_points1f(target, ustride, uorder, (GLfloat*) points);
|
---|
852 | else
|
---|
853 | pnts = gl_copy_map_points1d(target, ustride, uorder, (GLdouble*) points);
|
---|
854 |
|
---|
855 | switch (target) {
|
---|
856 | case GL_MAP1_VERTEX_3:
|
---|
857 | ctx->EvalMap.Map1Vertex3.Order = uorder;
|
---|
858 | ctx->EvalMap.Map1Vertex3.u1 = u1;
|
---|
859 | ctx->EvalMap.Map1Vertex3.u2 = u2;
|
---|
860 | ctx->EvalMap.Map1Vertex3.du = 1.0 / (u2 - u1);
|
---|
861 | if (ctx->EvalMap.Map1Vertex3.Points)
|
---|
862 | FREE( ctx->EvalMap.Map1Vertex3.Points );
|
---|
863 | ctx->EvalMap.Map1Vertex3.Points = pnts;
|
---|
864 | break;
|
---|
865 | case GL_MAP1_VERTEX_4:
|
---|
866 | ctx->EvalMap.Map1Vertex4.Order = uorder;
|
---|
867 | ctx->EvalMap.Map1Vertex4.u1 = u1;
|
---|
868 | ctx->EvalMap.Map1Vertex4.u2 = u2;
|
---|
869 | ctx->EvalMap.Map1Vertex4.du = 1.0 / (u2 - u1);
|
---|
870 | if (ctx->EvalMap.Map1Vertex4.Points)
|
---|
871 | FREE( ctx->EvalMap.Map1Vertex4.Points );
|
---|
872 | ctx->EvalMap.Map1Vertex4.Points = pnts;
|
---|
873 | break;
|
---|
874 | case GL_MAP1_INDEX:
|
---|
875 | ctx->EvalMap.Map1Index.Order = uorder;
|
---|
876 | ctx->EvalMap.Map1Index.u1 = u1;
|
---|
877 | ctx->EvalMap.Map1Index.u2 = u2;
|
---|
878 | ctx->EvalMap.Map1Index.du = 1.0 / (u2 - u1);
|
---|
879 | if (ctx->EvalMap.Map1Index.Points)
|
---|
880 | FREE( ctx->EvalMap.Map1Index.Points );
|
---|
881 | ctx->EvalMap.Map1Index.Points = pnts;
|
---|
882 | break;
|
---|
883 | case GL_MAP1_COLOR_4:
|
---|
884 | ctx->EvalMap.Map1Color4.Order = uorder;
|
---|
885 | ctx->EvalMap.Map1Color4.u1 = u1;
|
---|
886 | ctx->EvalMap.Map1Color4.u2 = u2;
|
---|
887 | ctx->EvalMap.Map1Color4.du = 1.0 / (u2 - u1);
|
---|
888 | if (ctx->EvalMap.Map1Color4.Points)
|
---|
889 | FREE( ctx->EvalMap.Map1Color4.Points );
|
---|
890 | ctx->EvalMap.Map1Color4.Points = pnts;
|
---|
891 | break;
|
---|
892 | case GL_MAP1_NORMAL:
|
---|
893 | ctx->EvalMap.Map1Normal.Order = uorder;
|
---|
894 | ctx->EvalMap.Map1Normal.u1 = u1;
|
---|
895 | ctx->EvalMap.Map1Normal.u2 = u2;
|
---|
896 | ctx->EvalMap.Map1Normal.du = 1.0 / (u2 - u1);
|
---|
897 | if (ctx->EvalMap.Map1Normal.Points)
|
---|
898 | FREE( ctx->EvalMap.Map1Normal.Points );
|
---|
899 | ctx->EvalMap.Map1Normal.Points = pnts;
|
---|
900 | break;
|
---|
901 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
902 | ctx->EvalMap.Map1Texture1.Order = uorder;
|
---|
903 | ctx->EvalMap.Map1Texture1.u1 = u1;
|
---|
904 | ctx->EvalMap.Map1Texture1.u2 = u2;
|
---|
905 | ctx->EvalMap.Map1Texture1.du = 1.0 / (u2 - u1);
|
---|
906 | if (ctx->EvalMap.Map1Texture1.Points)
|
---|
907 | FREE( ctx->EvalMap.Map1Texture1.Points );
|
---|
908 | ctx->EvalMap.Map1Texture1.Points = pnts;
|
---|
909 | break;
|
---|
910 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
911 | ctx->EvalMap.Map1Texture2.Order = uorder;
|
---|
912 | ctx->EvalMap.Map1Texture2.u1 = u1;
|
---|
913 | ctx->EvalMap.Map1Texture2.u2 = u2;
|
---|
914 | ctx->EvalMap.Map1Texture2.du = 1.0 / (u2 - u1);
|
---|
915 | if (ctx->EvalMap.Map1Texture2.Points)
|
---|
916 | FREE( ctx->EvalMap.Map1Texture2.Points );
|
---|
917 | ctx->EvalMap.Map1Texture2.Points = pnts;
|
---|
918 | break;
|
---|
919 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
920 | ctx->EvalMap.Map1Texture3.Order = uorder;
|
---|
921 | ctx->EvalMap.Map1Texture3.u1 = u1;
|
---|
922 | ctx->EvalMap.Map1Texture3.u2 = u2;
|
---|
923 | ctx->EvalMap.Map1Texture3.du = 1.0 / (u2 - u1);
|
---|
924 | if (ctx->EvalMap.Map1Texture3.Points)
|
---|
925 | FREE( ctx->EvalMap.Map1Texture3.Points );
|
---|
926 | ctx->EvalMap.Map1Texture3.Points = pnts;
|
---|
927 | break;
|
---|
928 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
929 | ctx->EvalMap.Map1Texture4.Order = uorder;
|
---|
930 | ctx->EvalMap.Map1Texture4.u1 = u1;
|
---|
931 | ctx->EvalMap.Map1Texture4.u2 = u2;
|
---|
932 | ctx->EvalMap.Map1Texture4.du = 1.0 / (u2 - u1);
|
---|
933 | if (ctx->EvalMap.Map1Texture4.Points)
|
---|
934 | FREE( ctx->EvalMap.Map1Texture4.Points );
|
---|
935 | ctx->EvalMap.Map1Texture4.Points = pnts;
|
---|
936 | break;
|
---|
937 | default:
|
---|
938 | gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
|
---|
939 | }
|
---|
940 | }
|
---|
941 |
|
---|
942 | void
|
---|
943 | _mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
|
---|
944 | GLint order, const GLfloat *points )
|
---|
945 | {
|
---|
946 | map1(target, u1, u2, stride, order, points, GL_FLOAT);
|
---|
947 | }
|
---|
948 |
|
---|
949 |
|
---|
950 | void
|
---|
951 | _mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
|
---|
952 | GLint order, const GLdouble *points )
|
---|
953 | {
|
---|
954 | map1(target, u1, u2, stride, order, points, GL_DOUBLE);
|
---|
955 | }
|
---|
956 |
|
---|
957 |
|
---|
958 | static void
|
---|
959 | map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
|
---|
960 | GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
|
---|
961 | const GLvoid *points, GLenum type )
|
---|
962 | {
|
---|
963 | GET_CURRENT_CONTEXT(ctx);
|
---|
964 | GLint k;
|
---|
965 | GLfloat *pnts;
|
---|
966 |
|
---|
967 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap2");
|
---|
968 |
|
---|
969 | if (u1==u2) {
|
---|
970 | gl_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" );
|
---|
971 | return;
|
---|
972 | }
|
---|
973 |
|
---|
974 | if (v1==v2) {
|
---|
975 | gl_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" );
|
---|
976 | return;
|
---|
977 | }
|
---|
978 |
|
---|
979 | if (uorder<1 || uorder>MAX_EVAL_ORDER) {
|
---|
980 | gl_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" );
|
---|
981 | return;
|
---|
982 | }
|
---|
983 |
|
---|
984 | if (vorder<1 || vorder>MAX_EVAL_ORDER) {
|
---|
985 | gl_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" );
|
---|
986 | return;
|
---|
987 | }
|
---|
988 |
|
---|
989 | k = _mesa_evaluator_components( target );
|
---|
990 | if (k==0) {
|
---|
991 | gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
|
---|
992 | }
|
---|
993 |
|
---|
994 | if (ustride < k) {
|
---|
995 | gl_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" );
|
---|
996 | return;
|
---|
997 | }
|
---|
998 | if (vstride < k) {
|
---|
999 | gl_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" );
|
---|
1000 | return;
|
---|
1001 | }
|
---|
1002 |
|
---|
1003 | /* make copy of the control points */
|
---|
1004 | if (type == GL_FLOAT)
|
---|
1005 | pnts = gl_copy_map_points2f(target, ustride, uorder,
|
---|
1006 | vstride, vorder, (GLfloat*) points);
|
---|
1007 | else
|
---|
1008 | pnts = gl_copy_map_points2d(target, ustride, uorder,
|
---|
1009 | vstride, vorder, (GLdouble*) points);
|
---|
1010 |
|
---|
1011 | switch (target) {
|
---|
1012 | case GL_MAP2_VERTEX_3:
|
---|
1013 | ctx->EvalMap.Map2Vertex3.Uorder = uorder;
|
---|
1014 | ctx->EvalMap.Map2Vertex3.u1 = u1;
|
---|
1015 | ctx->EvalMap.Map2Vertex3.u2 = u2;
|
---|
1016 | ctx->EvalMap.Map2Vertex3.du = 1.0 / (u2 - u1);
|
---|
1017 | ctx->EvalMap.Map2Vertex3.Vorder = vorder;
|
---|
1018 | ctx->EvalMap.Map2Vertex3.v1 = v1;
|
---|
1019 | ctx->EvalMap.Map2Vertex3.v2 = v2;
|
---|
1020 | ctx->EvalMap.Map2Vertex3.dv = 1.0 / (v2 - v1);
|
---|
1021 | if (ctx->EvalMap.Map2Vertex3.Points)
|
---|
1022 | FREE( ctx->EvalMap.Map2Vertex3.Points );
|
---|
1023 | ctx->EvalMap.Map2Vertex3.Points = pnts;
|
---|
1024 | break;
|
---|
1025 | case GL_MAP2_VERTEX_4:
|
---|
1026 | ctx->EvalMap.Map2Vertex4.Uorder = uorder;
|
---|
1027 | ctx->EvalMap.Map2Vertex4.u1 = u1;
|
---|
1028 | ctx->EvalMap.Map2Vertex4.u2 = u2;
|
---|
1029 | ctx->EvalMap.Map2Vertex4.du = 1.0 / (u2 - u1);
|
---|
1030 | ctx->EvalMap.Map2Vertex4.Vorder = vorder;
|
---|
1031 | ctx->EvalMap.Map2Vertex4.v1 = v1;
|
---|
1032 | ctx->EvalMap.Map2Vertex4.v2 = v2;
|
---|
1033 | ctx->EvalMap.Map2Vertex4.dv = 1.0 / (v2 - v1);
|
---|
1034 | if (ctx->EvalMap.Map2Vertex4.Points)
|
---|
1035 | FREE( ctx->EvalMap.Map2Vertex4.Points );
|
---|
1036 | ctx->EvalMap.Map2Vertex4.Points = pnts;
|
---|
1037 | break;
|
---|
1038 | case GL_MAP2_INDEX:
|
---|
1039 | ctx->EvalMap.Map2Index.Uorder = uorder;
|
---|
1040 | ctx->EvalMap.Map2Index.u1 = u1;
|
---|
1041 | ctx->EvalMap.Map2Index.u2 = u2;
|
---|
1042 | ctx->EvalMap.Map2Index.du = 1.0 / (u2 - u1);
|
---|
1043 | ctx->EvalMap.Map2Index.Vorder = vorder;
|
---|
1044 | ctx->EvalMap.Map2Index.v1 = v1;
|
---|
1045 | ctx->EvalMap.Map2Index.v2 = v2;
|
---|
1046 | ctx->EvalMap.Map2Index.dv = 1.0 / (v2 - v1);
|
---|
1047 | if (ctx->EvalMap.Map2Index.Points)
|
---|
1048 | FREE( ctx->EvalMap.Map2Index.Points );
|
---|
1049 | ctx->EvalMap.Map2Index.Points = pnts;
|
---|
1050 | break;
|
---|
1051 | case GL_MAP2_COLOR_4:
|
---|
1052 | ctx->EvalMap.Map2Color4.Uorder = uorder;
|
---|
1053 | ctx->EvalMap.Map2Color4.u1 = u1;
|
---|
1054 | ctx->EvalMap.Map2Color4.u2 = u2;
|
---|
1055 | ctx->EvalMap.Map2Color4.du = 1.0 / (u2 - u1);
|
---|
1056 | ctx->EvalMap.Map2Color4.Vorder = vorder;
|
---|
1057 | ctx->EvalMap.Map2Color4.v1 = v1;
|
---|
1058 | ctx->EvalMap.Map2Color4.v2 = v2;
|
---|
1059 | ctx->EvalMap.Map2Color4.dv = 1.0 / (v2 - v1);
|
---|
1060 | if (ctx->EvalMap.Map2Color4.Points)
|
---|
1061 | FREE( ctx->EvalMap.Map2Color4.Points );
|
---|
1062 | ctx->EvalMap.Map2Color4.Points = pnts;
|
---|
1063 | break;
|
---|
1064 | case GL_MAP2_NORMAL:
|
---|
1065 | ctx->EvalMap.Map2Normal.Uorder = uorder;
|
---|
1066 | ctx->EvalMap.Map2Normal.u1 = u1;
|
---|
1067 | ctx->EvalMap.Map2Normal.u2 = u2;
|
---|
1068 | ctx->EvalMap.Map2Normal.du = 1.0 / (u2 - u1);
|
---|
1069 | ctx->EvalMap.Map2Normal.Vorder = vorder;
|
---|
1070 | ctx->EvalMap.Map2Normal.v1 = v1;
|
---|
1071 | ctx->EvalMap.Map2Normal.v2 = v2;
|
---|
1072 | ctx->EvalMap.Map2Normal.dv = 1.0 / (v2 - v1);
|
---|
1073 | if (ctx->EvalMap.Map2Normal.Points)
|
---|
1074 | FREE( ctx->EvalMap.Map2Normal.Points );
|
---|
1075 | ctx->EvalMap.Map2Normal.Points = pnts;
|
---|
1076 | break;
|
---|
1077 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1078 | ctx->EvalMap.Map2Texture1.Uorder = uorder;
|
---|
1079 | ctx->EvalMap.Map2Texture1.u1 = u1;
|
---|
1080 | ctx->EvalMap.Map2Texture1.u2 = u2;
|
---|
1081 | ctx->EvalMap.Map2Texture1.du = 1.0 / (u2 - u1);
|
---|
1082 | ctx->EvalMap.Map2Texture1.Vorder = vorder;
|
---|
1083 | ctx->EvalMap.Map2Texture1.v1 = v1;
|
---|
1084 | ctx->EvalMap.Map2Texture1.v2 = v2;
|
---|
1085 | ctx->EvalMap.Map2Texture1.dv = 1.0 / (v2 - v1);
|
---|
1086 | if (ctx->EvalMap.Map2Texture1.Points)
|
---|
1087 | FREE( ctx->EvalMap.Map2Texture1.Points );
|
---|
1088 | ctx->EvalMap.Map2Texture1.Points = pnts;
|
---|
1089 | break;
|
---|
1090 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1091 | ctx->EvalMap.Map2Texture2.Uorder = uorder;
|
---|
1092 | ctx->EvalMap.Map2Texture2.u1 = u1;
|
---|
1093 | ctx->EvalMap.Map2Texture2.u2 = u2;
|
---|
1094 | ctx->EvalMap.Map2Texture2.du = 1.0 / (u2 - u1);
|
---|
1095 | ctx->EvalMap.Map2Texture2.Vorder = vorder;
|
---|
1096 | ctx->EvalMap.Map2Texture2.v1 = v1;
|
---|
1097 | ctx->EvalMap.Map2Texture2.v2 = v2;
|
---|
1098 | ctx->EvalMap.Map2Texture2.dv = 1.0 / (v2 - v1);
|
---|
1099 | if (ctx->EvalMap.Map2Texture2.Points)
|
---|
1100 | FREE( ctx->EvalMap.Map2Texture2.Points );
|
---|
1101 | ctx->EvalMap.Map2Texture2.Points = pnts;
|
---|
1102 | break;
|
---|
1103 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1104 | ctx->EvalMap.Map2Texture3.Uorder = uorder;
|
---|
1105 | ctx->EvalMap.Map2Texture3.u1 = u1;
|
---|
1106 | ctx->EvalMap.Map2Texture3.u2 = u2;
|
---|
1107 | ctx->EvalMap.Map2Texture3.du = 1.0 / (u2 - u1);
|
---|
1108 | ctx->EvalMap.Map2Texture3.Vorder = vorder;
|
---|
1109 | ctx->EvalMap.Map2Texture3.v1 = v1;
|
---|
1110 | ctx->EvalMap.Map2Texture3.v2 = v2;
|
---|
1111 | ctx->EvalMap.Map2Texture3.dv = 1.0 / (v2 - v1);
|
---|
1112 | if (ctx->EvalMap.Map2Texture3.Points)
|
---|
1113 | FREE( ctx->EvalMap.Map2Texture3.Points );
|
---|
1114 | ctx->EvalMap.Map2Texture3.Points = pnts;
|
---|
1115 | break;
|
---|
1116 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1117 | ctx->EvalMap.Map2Texture4.Uorder = uorder;
|
---|
1118 | ctx->EvalMap.Map2Texture4.u1 = u1;
|
---|
1119 | ctx->EvalMap.Map2Texture4.u2 = u2;
|
---|
1120 | ctx->EvalMap.Map2Texture4.du = 1.0 / (u2 - u1);
|
---|
1121 | ctx->EvalMap.Map2Texture4.Vorder = vorder;
|
---|
1122 | ctx->EvalMap.Map2Texture4.v1 = v1;
|
---|
1123 | ctx->EvalMap.Map2Texture4.v2 = v2;
|
---|
1124 | ctx->EvalMap.Map2Texture4.dv = 1.0 / (v2 - v1);
|
---|
1125 | if (ctx->EvalMap.Map2Texture4.Points)
|
---|
1126 | FREE( ctx->EvalMap.Map2Texture4.Points );
|
---|
1127 | ctx->EvalMap.Map2Texture4.Points = pnts;
|
---|
1128 | break;
|
---|
1129 | default:
|
---|
1130 | gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
|
---|
1131 | }
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 |
|
---|
1135 | void
|
---|
1136 | _mesa_Map2f( GLenum target,
|
---|
1137 | GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
|
---|
1138 | GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
|
---|
1139 | const GLfloat *points)
|
---|
1140 | {
|
---|
1141 | map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
|
---|
1142 | points, GL_FLOAT);
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 |
|
---|
1146 | void
|
---|
1147 | _mesa_Map2d( GLenum target,
|
---|
1148 | GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
|
---|
1149 | GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
|
---|
1150 | const GLdouble *points )
|
---|
1151 | {
|
---|
1152 | map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
|
---|
1153 | points, GL_DOUBLE);
|
---|
1154 | }
|
---|
1155 |
|
---|
1156 |
|
---|
1157 |
|
---|
1158 | void
|
---|
1159 | _mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
|
---|
1160 | {
|
---|
1161 | GET_CURRENT_CONTEXT(ctx);
|
---|
1162 | GLint i, n;
|
---|
1163 | GLfloat *data;
|
---|
1164 |
|
---|
1165 | switch (query) {
|
---|
1166 | case GL_COEFF:
|
---|
1167 | switch (target) {
|
---|
1168 | case GL_MAP1_COLOR_4:
|
---|
1169 | data = ctx->EvalMap.Map1Color4.Points;
|
---|
1170 | n = ctx->EvalMap.Map1Color4.Order * 4;
|
---|
1171 | break;
|
---|
1172 | case GL_MAP1_INDEX:
|
---|
1173 | data = ctx->EvalMap.Map1Index.Points;
|
---|
1174 | n = ctx->EvalMap.Map1Index.Order;
|
---|
1175 | break;
|
---|
1176 | case GL_MAP1_NORMAL:
|
---|
1177 | data = ctx->EvalMap.Map1Normal.Points;
|
---|
1178 | n = ctx->EvalMap.Map1Normal.Order * 3;
|
---|
1179 | break;
|
---|
1180 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1181 | data = ctx->EvalMap.Map1Texture1.Points;
|
---|
1182 | n = ctx->EvalMap.Map1Texture1.Order * 1;
|
---|
1183 | break;
|
---|
1184 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1185 | data = ctx->EvalMap.Map1Texture2.Points;
|
---|
1186 | n = ctx->EvalMap.Map1Texture2.Order * 2;
|
---|
1187 | break;
|
---|
1188 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1189 | data = ctx->EvalMap.Map1Texture3.Points;
|
---|
1190 | n = ctx->EvalMap.Map1Texture3.Order * 3;
|
---|
1191 | break;
|
---|
1192 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1193 | data = ctx->EvalMap.Map1Texture4.Points;
|
---|
1194 | n = ctx->EvalMap.Map1Texture4.Order * 4;
|
---|
1195 | break;
|
---|
1196 | case GL_MAP1_VERTEX_3:
|
---|
1197 | data = ctx->EvalMap.Map1Vertex3.Points;
|
---|
1198 | n = ctx->EvalMap.Map1Vertex3.Order * 3;
|
---|
1199 | break;
|
---|
1200 | case GL_MAP1_VERTEX_4:
|
---|
1201 | data = ctx->EvalMap.Map1Vertex4.Points;
|
---|
1202 | n = ctx->EvalMap.Map1Vertex4.Order * 4;
|
---|
1203 | break;
|
---|
1204 | case GL_MAP2_COLOR_4:
|
---|
1205 | data = ctx->EvalMap.Map2Color4.Points;
|
---|
1206 | n = ctx->EvalMap.Map2Color4.Uorder
|
---|
1207 | * ctx->EvalMap.Map2Color4.Vorder * 4;
|
---|
1208 | break;
|
---|
1209 | case GL_MAP2_INDEX:
|
---|
1210 | data = ctx->EvalMap.Map2Index.Points;
|
---|
1211 | n = ctx->EvalMap.Map2Index.Uorder
|
---|
1212 | * ctx->EvalMap.Map2Index.Vorder;
|
---|
1213 | break;
|
---|
1214 | case GL_MAP2_NORMAL:
|
---|
1215 | data = ctx->EvalMap.Map2Normal.Points;
|
---|
1216 | n = ctx->EvalMap.Map2Normal.Uorder
|
---|
1217 | * ctx->EvalMap.Map2Normal.Vorder * 3;
|
---|
1218 | break;
|
---|
1219 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1220 | data = ctx->EvalMap.Map2Texture1.Points;
|
---|
1221 | n = ctx->EvalMap.Map2Texture1.Uorder
|
---|
1222 | * ctx->EvalMap.Map2Texture1.Vorder * 1;
|
---|
1223 | break;
|
---|
1224 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1225 | data = ctx->EvalMap.Map2Texture2.Points;
|
---|
1226 | n = ctx->EvalMap.Map2Texture2.Uorder
|
---|
1227 | * ctx->EvalMap.Map2Texture2.Vorder * 2;
|
---|
1228 | break;
|
---|
1229 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1230 | data = ctx->EvalMap.Map2Texture3.Points;
|
---|
1231 | n = ctx->EvalMap.Map2Texture3.Uorder
|
---|
1232 | * ctx->EvalMap.Map2Texture3.Vorder * 3;
|
---|
1233 | break;
|
---|
1234 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1235 | data = ctx->EvalMap.Map2Texture4.Points;
|
---|
1236 | n = ctx->EvalMap.Map2Texture4.Uorder
|
---|
1237 | * ctx->EvalMap.Map2Texture4.Vorder * 4;
|
---|
1238 | break;
|
---|
1239 | case GL_MAP2_VERTEX_3:
|
---|
1240 | data = ctx->EvalMap.Map2Vertex3.Points;
|
---|
1241 | n = ctx->EvalMap.Map2Vertex3.Uorder
|
---|
1242 | * ctx->EvalMap.Map2Vertex3.Vorder * 3;
|
---|
1243 | break;
|
---|
1244 | case GL_MAP2_VERTEX_4:
|
---|
1245 | data = ctx->EvalMap.Map2Vertex4.Points;
|
---|
1246 | n = ctx->EvalMap.Map2Vertex4.Uorder
|
---|
1247 | * ctx->EvalMap.Map2Vertex4.Vorder * 4;
|
---|
1248 | break;
|
---|
1249 | default:
|
---|
1250 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
|
---|
1251 | return;
|
---|
1252 | }
|
---|
1253 | if (data) {
|
---|
1254 | for (i=0;i<n;i++) {
|
---|
1255 | v[i] = data[i];
|
---|
1256 | }
|
---|
1257 | }
|
---|
1258 | break;
|
---|
1259 | case GL_ORDER:
|
---|
1260 | switch (target) {
|
---|
1261 | case GL_MAP1_COLOR_4:
|
---|
1262 | *v = ctx->EvalMap.Map1Color4.Order;
|
---|
1263 | break;
|
---|
1264 | case GL_MAP1_INDEX:
|
---|
1265 | *v = ctx->EvalMap.Map1Index.Order;
|
---|
1266 | break;
|
---|
1267 | case GL_MAP1_NORMAL:
|
---|
1268 | *v = ctx->EvalMap.Map1Normal.Order;
|
---|
1269 | break;
|
---|
1270 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1271 | *v = ctx->EvalMap.Map1Texture1.Order;
|
---|
1272 | break;
|
---|
1273 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1274 | *v = ctx->EvalMap.Map1Texture2.Order;
|
---|
1275 | break;
|
---|
1276 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1277 | *v = ctx->EvalMap.Map1Texture3.Order;
|
---|
1278 | break;
|
---|
1279 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1280 | *v = ctx->EvalMap.Map1Texture4.Order;
|
---|
1281 | break;
|
---|
1282 | case GL_MAP1_VERTEX_3:
|
---|
1283 | *v = ctx->EvalMap.Map1Vertex3.Order;
|
---|
1284 | break;
|
---|
1285 | case GL_MAP1_VERTEX_4:
|
---|
1286 | *v = ctx->EvalMap.Map1Vertex4.Order;
|
---|
1287 | break;
|
---|
1288 | case GL_MAP2_COLOR_4:
|
---|
1289 | v[0] = ctx->EvalMap.Map2Color4.Uorder;
|
---|
1290 | v[1] = ctx->EvalMap.Map2Color4.Vorder;
|
---|
1291 | break;
|
---|
1292 | case GL_MAP2_INDEX:
|
---|
1293 | v[0] = ctx->EvalMap.Map2Index.Uorder;
|
---|
1294 | v[1] = ctx->EvalMap.Map2Index.Vorder;
|
---|
1295 | break;
|
---|
1296 | case GL_MAP2_NORMAL:
|
---|
1297 | v[0] = ctx->EvalMap.Map2Normal.Uorder;
|
---|
1298 | v[1] = ctx->EvalMap.Map2Normal.Vorder;
|
---|
1299 | break;
|
---|
1300 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1301 | v[0] = ctx->EvalMap.Map2Texture1.Uorder;
|
---|
1302 | v[1] = ctx->EvalMap.Map2Texture1.Vorder;
|
---|
1303 | break;
|
---|
1304 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1305 | v[0] = ctx->EvalMap.Map2Texture2.Uorder;
|
---|
1306 | v[1] = ctx->EvalMap.Map2Texture2.Vorder;
|
---|
1307 | break;
|
---|
1308 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1309 | v[0] = ctx->EvalMap.Map2Texture3.Uorder;
|
---|
1310 | v[1] = ctx->EvalMap.Map2Texture3.Vorder;
|
---|
1311 | break;
|
---|
1312 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1313 | v[0] = ctx->EvalMap.Map2Texture4.Uorder;
|
---|
1314 | v[1] = ctx->EvalMap.Map2Texture4.Vorder;
|
---|
1315 | break;
|
---|
1316 | case GL_MAP2_VERTEX_3:
|
---|
1317 | v[0] = ctx->EvalMap.Map2Vertex3.Uorder;
|
---|
1318 | v[1] = ctx->EvalMap.Map2Vertex3.Vorder;
|
---|
1319 | break;
|
---|
1320 | case GL_MAP2_VERTEX_4:
|
---|
1321 | v[0] = ctx->EvalMap.Map2Vertex4.Uorder;
|
---|
1322 | v[1] = ctx->EvalMap.Map2Vertex4.Vorder;
|
---|
1323 | break;
|
---|
1324 | default:
|
---|
1325 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
|
---|
1326 | return;
|
---|
1327 | }
|
---|
1328 | break;
|
---|
1329 | case GL_DOMAIN:
|
---|
1330 | switch (target) {
|
---|
1331 | case GL_MAP1_COLOR_4:
|
---|
1332 | v[0] = ctx->EvalMap.Map1Color4.u1;
|
---|
1333 | v[1] = ctx->EvalMap.Map1Color4.u2;
|
---|
1334 | break;
|
---|
1335 | case GL_MAP1_INDEX:
|
---|
1336 | v[0] = ctx->EvalMap.Map1Index.u1;
|
---|
1337 | v[1] = ctx->EvalMap.Map1Index.u2;
|
---|
1338 | break;
|
---|
1339 | case GL_MAP1_NORMAL:
|
---|
1340 | v[0] = ctx->EvalMap.Map1Normal.u1;
|
---|
1341 | v[1] = ctx->EvalMap.Map1Normal.u2;
|
---|
1342 | break;
|
---|
1343 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1344 | v[0] = ctx->EvalMap.Map1Texture1.u1;
|
---|
1345 | v[1] = ctx->EvalMap.Map1Texture1.u2;
|
---|
1346 | break;
|
---|
1347 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1348 | v[0] = ctx->EvalMap.Map1Texture2.u1;
|
---|
1349 | v[1] = ctx->EvalMap.Map1Texture2.u2;
|
---|
1350 | break;
|
---|
1351 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1352 | v[0] = ctx->EvalMap.Map1Texture3.u1;
|
---|
1353 | v[1] = ctx->EvalMap.Map1Texture3.u2;
|
---|
1354 | break;
|
---|
1355 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1356 | v[0] = ctx->EvalMap.Map1Texture4.u1;
|
---|
1357 | v[1] = ctx->EvalMap.Map1Texture4.u2;
|
---|
1358 | break;
|
---|
1359 | case GL_MAP1_VERTEX_3:
|
---|
1360 | v[0] = ctx->EvalMap.Map1Vertex3.u1;
|
---|
1361 | v[1] = ctx->EvalMap.Map1Vertex3.u2;
|
---|
1362 | break;
|
---|
1363 | case GL_MAP1_VERTEX_4:
|
---|
1364 | v[0] = ctx->EvalMap.Map1Vertex4.u1;
|
---|
1365 | v[1] = ctx->EvalMap.Map1Vertex4.u2;
|
---|
1366 | break;
|
---|
1367 | case GL_MAP2_COLOR_4:
|
---|
1368 | v[0] = ctx->EvalMap.Map2Color4.u1;
|
---|
1369 | v[1] = ctx->EvalMap.Map2Color4.u2;
|
---|
1370 | v[2] = ctx->EvalMap.Map2Color4.v1;
|
---|
1371 | v[3] = ctx->EvalMap.Map2Color4.v2;
|
---|
1372 | break;
|
---|
1373 | case GL_MAP2_INDEX:
|
---|
1374 | v[0] = ctx->EvalMap.Map2Index.u1;
|
---|
1375 | v[1] = ctx->EvalMap.Map2Index.u2;
|
---|
1376 | v[2] = ctx->EvalMap.Map2Index.v1;
|
---|
1377 | v[3] = ctx->EvalMap.Map2Index.v2;
|
---|
1378 | break;
|
---|
1379 | case GL_MAP2_NORMAL:
|
---|
1380 | v[0] = ctx->EvalMap.Map2Normal.u1;
|
---|
1381 | v[1] = ctx->EvalMap.Map2Normal.u2;
|
---|
1382 | v[2] = ctx->EvalMap.Map2Normal.v1;
|
---|
1383 | v[3] = ctx->EvalMap.Map2Normal.v2;
|
---|
1384 | break;
|
---|
1385 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1386 | v[0] = ctx->EvalMap.Map2Texture1.u1;
|
---|
1387 | v[1] = ctx->EvalMap.Map2Texture1.u2;
|
---|
1388 | v[2] = ctx->EvalMap.Map2Texture1.v1;
|
---|
1389 | v[3] = ctx->EvalMap.Map2Texture1.v2;
|
---|
1390 | break;
|
---|
1391 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1392 | v[0] = ctx->EvalMap.Map2Texture2.u1;
|
---|
1393 | v[1] = ctx->EvalMap.Map2Texture2.u2;
|
---|
1394 | v[2] = ctx->EvalMap.Map2Texture2.v1;
|
---|
1395 | v[3] = ctx->EvalMap.Map2Texture2.v2;
|
---|
1396 | break;
|
---|
1397 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1398 | v[0] = ctx->EvalMap.Map2Texture3.u1;
|
---|
1399 | v[1] = ctx->EvalMap.Map2Texture3.u2;
|
---|
1400 | v[2] = ctx->EvalMap.Map2Texture3.v1;
|
---|
1401 | v[3] = ctx->EvalMap.Map2Texture3.v2;
|
---|
1402 | break;
|
---|
1403 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1404 | v[0] = ctx->EvalMap.Map2Texture4.u1;
|
---|
1405 | v[1] = ctx->EvalMap.Map2Texture4.u2;
|
---|
1406 | v[2] = ctx->EvalMap.Map2Texture4.v1;
|
---|
1407 | v[3] = ctx->EvalMap.Map2Texture4.v2;
|
---|
1408 | break;
|
---|
1409 | case GL_MAP2_VERTEX_3:
|
---|
1410 | v[0] = ctx->EvalMap.Map2Vertex3.u1;
|
---|
1411 | v[1] = ctx->EvalMap.Map2Vertex3.u2;
|
---|
1412 | v[2] = ctx->EvalMap.Map2Vertex3.v1;
|
---|
1413 | v[3] = ctx->EvalMap.Map2Vertex3.v2;
|
---|
1414 | break;
|
---|
1415 | case GL_MAP2_VERTEX_4:
|
---|
1416 | v[0] = ctx->EvalMap.Map2Vertex4.u1;
|
---|
1417 | v[1] = ctx->EvalMap.Map2Vertex4.u2;
|
---|
1418 | v[2] = ctx->EvalMap.Map2Vertex4.v1;
|
---|
1419 | v[3] = ctx->EvalMap.Map2Vertex4.v2;
|
---|
1420 | break;
|
---|
1421 | default:
|
---|
1422 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
|
---|
1423 | }
|
---|
1424 | break;
|
---|
1425 | default:
|
---|
1426 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" );
|
---|
1427 | }
|
---|
1428 | }
|
---|
1429 |
|
---|
1430 |
|
---|
1431 | void
|
---|
1432 | _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
|
---|
1433 | {
|
---|
1434 | GET_CURRENT_CONTEXT(ctx);
|
---|
1435 | GLint i, n;
|
---|
1436 | GLfloat *data;
|
---|
1437 |
|
---|
1438 | switch (query) {
|
---|
1439 | case GL_COEFF:
|
---|
1440 | switch (target) {
|
---|
1441 | case GL_MAP1_COLOR_4:
|
---|
1442 | data = ctx->EvalMap.Map1Color4.Points;
|
---|
1443 | n = ctx->EvalMap.Map1Color4.Order * 4;
|
---|
1444 | break;
|
---|
1445 | case GL_MAP1_INDEX:
|
---|
1446 | data = ctx->EvalMap.Map1Index.Points;
|
---|
1447 | n = ctx->EvalMap.Map1Index.Order;
|
---|
1448 | break;
|
---|
1449 | case GL_MAP1_NORMAL:
|
---|
1450 | data = ctx->EvalMap.Map1Normal.Points;
|
---|
1451 | n = ctx->EvalMap.Map1Normal.Order * 3;
|
---|
1452 | break;
|
---|
1453 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1454 | data = ctx->EvalMap.Map1Texture1.Points;
|
---|
1455 | n = ctx->EvalMap.Map1Texture1.Order * 1;
|
---|
1456 | break;
|
---|
1457 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1458 | data = ctx->EvalMap.Map1Texture2.Points;
|
---|
1459 | n = ctx->EvalMap.Map1Texture2.Order * 2;
|
---|
1460 | break;
|
---|
1461 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1462 | data = ctx->EvalMap.Map1Texture3.Points;
|
---|
1463 | n = ctx->EvalMap.Map1Texture3.Order * 3;
|
---|
1464 | break;
|
---|
1465 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1466 | data = ctx->EvalMap.Map1Texture4.Points;
|
---|
1467 | n = ctx->EvalMap.Map1Texture4.Order * 4;
|
---|
1468 | break;
|
---|
1469 | case GL_MAP1_VERTEX_3:
|
---|
1470 | data = ctx->EvalMap.Map1Vertex3.Points;
|
---|
1471 | n = ctx->EvalMap.Map1Vertex3.Order * 3;
|
---|
1472 | break;
|
---|
1473 | case GL_MAP1_VERTEX_4:
|
---|
1474 | data = ctx->EvalMap.Map1Vertex4.Points;
|
---|
1475 | n = ctx->EvalMap.Map1Vertex4.Order * 4;
|
---|
1476 | break;
|
---|
1477 | case GL_MAP2_COLOR_4:
|
---|
1478 | data = ctx->EvalMap.Map2Color4.Points;
|
---|
1479 | n = ctx->EvalMap.Map2Color4.Uorder
|
---|
1480 | * ctx->EvalMap.Map2Color4.Vorder * 4;
|
---|
1481 | break;
|
---|
1482 | case GL_MAP2_INDEX:
|
---|
1483 | data = ctx->EvalMap.Map2Index.Points;
|
---|
1484 | n = ctx->EvalMap.Map2Index.Uorder
|
---|
1485 | * ctx->EvalMap.Map2Index.Vorder;
|
---|
1486 | break;
|
---|
1487 | case GL_MAP2_NORMAL:
|
---|
1488 | data = ctx->EvalMap.Map2Normal.Points;
|
---|
1489 | n = ctx->EvalMap.Map2Normal.Uorder
|
---|
1490 | * ctx->EvalMap.Map2Normal.Vorder * 3;
|
---|
1491 | break;
|
---|
1492 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1493 | data = ctx->EvalMap.Map2Texture1.Points;
|
---|
1494 | n = ctx->EvalMap.Map2Texture1.Uorder
|
---|
1495 | * ctx->EvalMap.Map2Texture1.Vorder * 1;
|
---|
1496 | break;
|
---|
1497 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1498 | data = ctx->EvalMap.Map2Texture2.Points;
|
---|
1499 | n = ctx->EvalMap.Map2Texture2.Uorder
|
---|
1500 | * ctx->EvalMap.Map2Texture2.Vorder * 2;
|
---|
1501 | break;
|
---|
1502 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1503 | data = ctx->EvalMap.Map2Texture3.Points;
|
---|
1504 | n = ctx->EvalMap.Map2Texture3.Uorder
|
---|
1505 | * ctx->EvalMap.Map2Texture3.Vorder * 3;
|
---|
1506 | break;
|
---|
1507 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1508 | data = ctx->EvalMap.Map2Texture4.Points;
|
---|
1509 | n = ctx->EvalMap.Map2Texture4.Uorder
|
---|
1510 | * ctx->EvalMap.Map2Texture4.Vorder * 4;
|
---|
1511 | break;
|
---|
1512 | case GL_MAP2_VERTEX_3:
|
---|
1513 | data = ctx->EvalMap.Map2Vertex3.Points;
|
---|
1514 | n = ctx->EvalMap.Map2Vertex3.Uorder
|
---|
1515 | * ctx->EvalMap.Map2Vertex3.Vorder * 3;
|
---|
1516 | break;
|
---|
1517 | case GL_MAP2_VERTEX_4:
|
---|
1518 | data = ctx->EvalMap.Map2Vertex4.Points;
|
---|
1519 | n = ctx->EvalMap.Map2Vertex4.Uorder
|
---|
1520 | * ctx->EvalMap.Map2Vertex4.Vorder * 4;
|
---|
1521 | break;
|
---|
1522 | default:
|
---|
1523 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
|
---|
1524 | return;
|
---|
1525 | }
|
---|
1526 | if (data) {
|
---|
1527 | for (i=0;i<n;i++) {
|
---|
1528 | v[i] = data[i];
|
---|
1529 | }
|
---|
1530 | }
|
---|
1531 | break;
|
---|
1532 | case GL_ORDER:
|
---|
1533 | switch (target) {
|
---|
1534 | case GL_MAP1_COLOR_4:
|
---|
1535 | *v = ctx->EvalMap.Map1Color4.Order;
|
---|
1536 | break;
|
---|
1537 | case GL_MAP1_INDEX:
|
---|
1538 | *v = ctx->EvalMap.Map1Index.Order;
|
---|
1539 | break;
|
---|
1540 | case GL_MAP1_NORMAL:
|
---|
1541 | *v = ctx->EvalMap.Map1Normal.Order;
|
---|
1542 | break;
|
---|
1543 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1544 | *v = ctx->EvalMap.Map1Texture1.Order;
|
---|
1545 | break;
|
---|
1546 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1547 | *v = ctx->EvalMap.Map1Texture2.Order;
|
---|
1548 | break;
|
---|
1549 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1550 | *v = ctx->EvalMap.Map1Texture3.Order;
|
---|
1551 | break;
|
---|
1552 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1553 | *v = ctx->EvalMap.Map1Texture4.Order;
|
---|
1554 | break;
|
---|
1555 | case GL_MAP1_VERTEX_3:
|
---|
1556 | *v = ctx->EvalMap.Map1Vertex3.Order;
|
---|
1557 | break;
|
---|
1558 | case GL_MAP1_VERTEX_4:
|
---|
1559 | *v = ctx->EvalMap.Map1Vertex4.Order;
|
---|
1560 | break;
|
---|
1561 | case GL_MAP2_COLOR_4:
|
---|
1562 | v[0] = ctx->EvalMap.Map2Color4.Uorder;
|
---|
1563 | v[1] = ctx->EvalMap.Map2Color4.Vorder;
|
---|
1564 | break;
|
---|
1565 | case GL_MAP2_INDEX:
|
---|
1566 | v[0] = ctx->EvalMap.Map2Index.Uorder;
|
---|
1567 | v[1] = ctx->EvalMap.Map2Index.Vorder;
|
---|
1568 | break;
|
---|
1569 | case GL_MAP2_NORMAL:
|
---|
1570 | v[0] = ctx->EvalMap.Map2Normal.Uorder;
|
---|
1571 | v[1] = ctx->EvalMap.Map2Normal.Vorder;
|
---|
1572 | break;
|
---|
1573 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1574 | v[0] = ctx->EvalMap.Map2Texture1.Uorder;
|
---|
1575 | v[1] = ctx->EvalMap.Map2Texture1.Vorder;
|
---|
1576 | break;
|
---|
1577 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1578 | v[0] = ctx->EvalMap.Map2Texture2.Uorder;
|
---|
1579 | v[1] = ctx->EvalMap.Map2Texture2.Vorder;
|
---|
1580 | break;
|
---|
1581 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1582 | v[0] = ctx->EvalMap.Map2Texture3.Uorder;
|
---|
1583 | v[1] = ctx->EvalMap.Map2Texture3.Vorder;
|
---|
1584 | break;
|
---|
1585 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1586 | v[0] = ctx->EvalMap.Map2Texture4.Uorder;
|
---|
1587 | v[1] = ctx->EvalMap.Map2Texture4.Vorder;
|
---|
1588 | break;
|
---|
1589 | case GL_MAP2_VERTEX_3:
|
---|
1590 | v[0] = ctx->EvalMap.Map2Vertex3.Uorder;
|
---|
1591 | v[1] = ctx->EvalMap.Map2Vertex3.Vorder;
|
---|
1592 | break;
|
---|
1593 | case GL_MAP2_VERTEX_4:
|
---|
1594 | v[0] = ctx->EvalMap.Map2Vertex4.Uorder;
|
---|
1595 | v[1] = ctx->EvalMap.Map2Vertex4.Vorder;
|
---|
1596 | break;
|
---|
1597 | default:
|
---|
1598 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
|
---|
1599 | return;
|
---|
1600 | }
|
---|
1601 | break;
|
---|
1602 | case GL_DOMAIN:
|
---|
1603 | switch (target) {
|
---|
1604 | case GL_MAP1_COLOR_4:
|
---|
1605 | v[0] = ctx->EvalMap.Map1Color4.u1;
|
---|
1606 | v[1] = ctx->EvalMap.Map1Color4.u2;
|
---|
1607 | break;
|
---|
1608 | case GL_MAP1_INDEX:
|
---|
1609 | v[0] = ctx->EvalMap.Map1Index.u1;
|
---|
1610 | v[1] = ctx->EvalMap.Map1Index.u2;
|
---|
1611 | break;
|
---|
1612 | case GL_MAP1_NORMAL:
|
---|
1613 | v[0] = ctx->EvalMap.Map1Normal.u1;
|
---|
1614 | v[1] = ctx->EvalMap.Map1Normal.u2;
|
---|
1615 | break;
|
---|
1616 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1617 | v[0] = ctx->EvalMap.Map1Texture1.u1;
|
---|
1618 | v[1] = ctx->EvalMap.Map1Texture1.u2;
|
---|
1619 | break;
|
---|
1620 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1621 | v[0] = ctx->EvalMap.Map1Texture2.u1;
|
---|
1622 | v[1] = ctx->EvalMap.Map1Texture2.u2;
|
---|
1623 | break;
|
---|
1624 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1625 | v[0] = ctx->EvalMap.Map1Texture3.u1;
|
---|
1626 | v[1] = ctx->EvalMap.Map1Texture3.u2;
|
---|
1627 | break;
|
---|
1628 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1629 | v[0] = ctx->EvalMap.Map1Texture4.u1;
|
---|
1630 | v[1] = ctx->EvalMap.Map1Texture4.u2;
|
---|
1631 | break;
|
---|
1632 | case GL_MAP1_VERTEX_3:
|
---|
1633 | v[0] = ctx->EvalMap.Map1Vertex3.u1;
|
---|
1634 | v[1] = ctx->EvalMap.Map1Vertex3.u2;
|
---|
1635 | break;
|
---|
1636 | case GL_MAP1_VERTEX_4:
|
---|
1637 | v[0] = ctx->EvalMap.Map1Vertex4.u1;
|
---|
1638 | v[1] = ctx->EvalMap.Map1Vertex4.u2;
|
---|
1639 | break;
|
---|
1640 | case GL_MAP2_COLOR_4:
|
---|
1641 | v[0] = ctx->EvalMap.Map2Color4.u1;
|
---|
1642 | v[1] = ctx->EvalMap.Map2Color4.u2;
|
---|
1643 | v[2] = ctx->EvalMap.Map2Color4.v1;
|
---|
1644 | v[3] = ctx->EvalMap.Map2Color4.v2;
|
---|
1645 | break;
|
---|
1646 | case GL_MAP2_INDEX:
|
---|
1647 | v[0] = ctx->EvalMap.Map2Index.u1;
|
---|
1648 | v[1] = ctx->EvalMap.Map2Index.u2;
|
---|
1649 | v[2] = ctx->EvalMap.Map2Index.v1;
|
---|
1650 | v[3] = ctx->EvalMap.Map2Index.v2;
|
---|
1651 | break;
|
---|
1652 | case GL_MAP2_NORMAL:
|
---|
1653 | v[0] = ctx->EvalMap.Map2Normal.u1;
|
---|
1654 | v[1] = ctx->EvalMap.Map2Normal.u2;
|
---|
1655 | v[2] = ctx->EvalMap.Map2Normal.v1;
|
---|
1656 | v[3] = ctx->EvalMap.Map2Normal.v2;
|
---|
1657 | break;
|
---|
1658 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1659 | v[0] = ctx->EvalMap.Map2Texture1.u1;
|
---|
1660 | v[1] = ctx->EvalMap.Map2Texture1.u2;
|
---|
1661 | v[2] = ctx->EvalMap.Map2Texture1.v1;
|
---|
1662 | v[3] = ctx->EvalMap.Map2Texture1.v2;
|
---|
1663 | break;
|
---|
1664 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1665 | v[0] = ctx->EvalMap.Map2Texture2.u1;
|
---|
1666 | v[1] = ctx->EvalMap.Map2Texture2.u2;
|
---|
1667 | v[2] = ctx->EvalMap.Map2Texture2.v1;
|
---|
1668 | v[3] = ctx->EvalMap.Map2Texture2.v2;
|
---|
1669 | break;
|
---|
1670 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1671 | v[0] = ctx->EvalMap.Map2Texture3.u1;
|
---|
1672 | v[1] = ctx->EvalMap.Map2Texture3.u2;
|
---|
1673 | v[2] = ctx->EvalMap.Map2Texture3.v1;
|
---|
1674 | v[3] = ctx->EvalMap.Map2Texture3.v2;
|
---|
1675 | break;
|
---|
1676 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1677 | v[0] = ctx->EvalMap.Map2Texture4.u1;
|
---|
1678 | v[1] = ctx->EvalMap.Map2Texture4.u2;
|
---|
1679 | v[2] = ctx->EvalMap.Map2Texture4.v1;
|
---|
1680 | v[3] = ctx->EvalMap.Map2Texture4.v2;
|
---|
1681 | break;
|
---|
1682 | case GL_MAP2_VERTEX_3:
|
---|
1683 | v[0] = ctx->EvalMap.Map2Vertex3.u1;
|
---|
1684 | v[1] = ctx->EvalMap.Map2Vertex3.u2;
|
---|
1685 | v[2] = ctx->EvalMap.Map2Vertex3.v1;
|
---|
1686 | v[3] = ctx->EvalMap.Map2Vertex3.v2;
|
---|
1687 | break;
|
---|
1688 | case GL_MAP2_VERTEX_4:
|
---|
1689 | v[0] = ctx->EvalMap.Map2Vertex4.u1;
|
---|
1690 | v[1] = ctx->EvalMap.Map2Vertex4.u2;
|
---|
1691 | v[2] = ctx->EvalMap.Map2Vertex4.v1;
|
---|
1692 | v[3] = ctx->EvalMap.Map2Vertex4.v2;
|
---|
1693 | break;
|
---|
1694 | default:
|
---|
1695 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
|
---|
1696 | }
|
---|
1697 | break;
|
---|
1698 | default:
|
---|
1699 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" );
|
---|
1700 | }
|
---|
1701 | }
|
---|
1702 |
|
---|
1703 |
|
---|
1704 | void
|
---|
1705 | _mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
|
---|
1706 | {
|
---|
1707 | GET_CURRENT_CONTEXT(ctx);
|
---|
1708 | GLuint i, n;
|
---|
1709 | GLfloat *data;
|
---|
1710 |
|
---|
1711 | switch (query) {
|
---|
1712 | case GL_COEFF:
|
---|
1713 | switch (target) {
|
---|
1714 | case GL_MAP1_COLOR_4:
|
---|
1715 | data = ctx->EvalMap.Map1Color4.Points;
|
---|
1716 | n = ctx->EvalMap.Map1Color4.Order * 4;
|
---|
1717 | break;
|
---|
1718 | case GL_MAP1_INDEX:
|
---|
1719 | data = ctx->EvalMap.Map1Index.Points;
|
---|
1720 | n = ctx->EvalMap.Map1Index.Order;
|
---|
1721 | break;
|
---|
1722 | case GL_MAP1_NORMAL:
|
---|
1723 | data = ctx->EvalMap.Map1Normal.Points;
|
---|
1724 | n = ctx->EvalMap.Map1Normal.Order * 3;
|
---|
1725 | break;
|
---|
1726 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1727 | data = ctx->EvalMap.Map1Texture1.Points;
|
---|
1728 | n = ctx->EvalMap.Map1Texture1.Order * 1;
|
---|
1729 | break;
|
---|
1730 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1731 | data = ctx->EvalMap.Map1Texture2.Points;
|
---|
1732 | n = ctx->EvalMap.Map1Texture2.Order * 2;
|
---|
1733 | break;
|
---|
1734 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1735 | data = ctx->EvalMap.Map1Texture3.Points;
|
---|
1736 | n = ctx->EvalMap.Map1Texture3.Order * 3;
|
---|
1737 | break;
|
---|
1738 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1739 | data = ctx->EvalMap.Map1Texture4.Points;
|
---|
1740 | n = ctx->EvalMap.Map1Texture4.Order * 4;
|
---|
1741 | break;
|
---|
1742 | case GL_MAP1_VERTEX_3:
|
---|
1743 | data = ctx->EvalMap.Map1Vertex3.Points;
|
---|
1744 | n = ctx->EvalMap.Map1Vertex3.Order * 3;
|
---|
1745 | break;
|
---|
1746 | case GL_MAP1_VERTEX_4:
|
---|
1747 | data = ctx->EvalMap.Map1Vertex4.Points;
|
---|
1748 | n = ctx->EvalMap.Map1Vertex4.Order * 4;
|
---|
1749 | break;
|
---|
1750 | case GL_MAP2_COLOR_4:
|
---|
1751 | data = ctx->EvalMap.Map2Color4.Points;
|
---|
1752 | n = ctx->EvalMap.Map2Color4.Uorder
|
---|
1753 | * ctx->EvalMap.Map2Color4.Vorder * 4;
|
---|
1754 | break;
|
---|
1755 | case GL_MAP2_INDEX:
|
---|
1756 | data = ctx->EvalMap.Map2Index.Points;
|
---|
1757 | n = ctx->EvalMap.Map2Index.Uorder
|
---|
1758 | * ctx->EvalMap.Map2Index.Vorder;
|
---|
1759 | break;
|
---|
1760 | case GL_MAP2_NORMAL:
|
---|
1761 | data = ctx->EvalMap.Map2Normal.Points;
|
---|
1762 | n = ctx->EvalMap.Map2Normal.Uorder
|
---|
1763 | * ctx->EvalMap.Map2Normal.Vorder * 3;
|
---|
1764 | break;
|
---|
1765 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1766 | data = ctx->EvalMap.Map2Texture1.Points;
|
---|
1767 | n = ctx->EvalMap.Map2Texture1.Uorder
|
---|
1768 | * ctx->EvalMap.Map2Texture1.Vorder * 1;
|
---|
1769 | break;
|
---|
1770 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1771 | data = ctx->EvalMap.Map2Texture2.Points;
|
---|
1772 | n = ctx->EvalMap.Map2Texture2.Uorder
|
---|
1773 | * ctx->EvalMap.Map2Texture2.Vorder * 2;
|
---|
1774 | break;
|
---|
1775 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1776 | data = ctx->EvalMap.Map2Texture3.Points;
|
---|
1777 | n = ctx->EvalMap.Map2Texture3.Uorder
|
---|
1778 | * ctx->EvalMap.Map2Texture3.Vorder * 3;
|
---|
1779 | break;
|
---|
1780 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1781 | data = ctx->EvalMap.Map2Texture4.Points;
|
---|
1782 | n = ctx->EvalMap.Map2Texture4.Uorder
|
---|
1783 | * ctx->EvalMap.Map2Texture4.Vorder * 4;
|
---|
1784 | break;
|
---|
1785 | case GL_MAP2_VERTEX_3:
|
---|
1786 | data = ctx->EvalMap.Map2Vertex3.Points;
|
---|
1787 | n = ctx->EvalMap.Map2Vertex3.Uorder
|
---|
1788 | * ctx->EvalMap.Map2Vertex3.Vorder * 3;
|
---|
1789 | break;
|
---|
1790 | case GL_MAP2_VERTEX_4:
|
---|
1791 | data = ctx->EvalMap.Map2Vertex4.Points;
|
---|
1792 | n = ctx->EvalMap.Map2Vertex4.Uorder
|
---|
1793 | * ctx->EvalMap.Map2Vertex4.Vorder * 4;
|
---|
1794 | break;
|
---|
1795 | default:
|
---|
1796 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
|
---|
1797 | return;
|
---|
1798 | }
|
---|
1799 | if (data) {
|
---|
1800 | for (i=0;i<n;i++) {
|
---|
1801 | v[i] = ROUNDF(data[i]);
|
---|
1802 | }
|
---|
1803 | }
|
---|
1804 | break;
|
---|
1805 | case GL_ORDER:
|
---|
1806 | switch (target) {
|
---|
1807 | case GL_MAP1_COLOR_4:
|
---|
1808 | *v = ctx->EvalMap.Map1Color4.Order;
|
---|
1809 | break;
|
---|
1810 | case GL_MAP1_INDEX:
|
---|
1811 | *v = ctx->EvalMap.Map1Index.Order;
|
---|
1812 | break;
|
---|
1813 | case GL_MAP1_NORMAL:
|
---|
1814 | *v = ctx->EvalMap.Map1Normal.Order;
|
---|
1815 | break;
|
---|
1816 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1817 | *v = ctx->EvalMap.Map1Texture1.Order;
|
---|
1818 | break;
|
---|
1819 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1820 | *v = ctx->EvalMap.Map1Texture2.Order;
|
---|
1821 | break;
|
---|
1822 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1823 | *v = ctx->EvalMap.Map1Texture3.Order;
|
---|
1824 | break;
|
---|
1825 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1826 | *v = ctx->EvalMap.Map1Texture4.Order;
|
---|
1827 | break;
|
---|
1828 | case GL_MAP1_VERTEX_3:
|
---|
1829 | *v = ctx->EvalMap.Map1Vertex3.Order;
|
---|
1830 | break;
|
---|
1831 | case GL_MAP1_VERTEX_4:
|
---|
1832 | *v = ctx->EvalMap.Map1Vertex4.Order;
|
---|
1833 | break;
|
---|
1834 | case GL_MAP2_COLOR_4:
|
---|
1835 | v[0] = ctx->EvalMap.Map2Color4.Uorder;
|
---|
1836 | v[1] = ctx->EvalMap.Map2Color4.Vorder;
|
---|
1837 | break;
|
---|
1838 | case GL_MAP2_INDEX:
|
---|
1839 | v[0] = ctx->EvalMap.Map2Index.Uorder;
|
---|
1840 | v[1] = ctx->EvalMap.Map2Index.Vorder;
|
---|
1841 | break;
|
---|
1842 | case GL_MAP2_NORMAL:
|
---|
1843 | v[0] = ctx->EvalMap.Map2Normal.Uorder;
|
---|
1844 | v[1] = ctx->EvalMap.Map2Normal.Vorder;
|
---|
1845 | break;
|
---|
1846 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1847 | v[0] = ctx->EvalMap.Map2Texture1.Uorder;
|
---|
1848 | v[1] = ctx->EvalMap.Map2Texture1.Vorder;
|
---|
1849 | break;
|
---|
1850 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1851 | v[0] = ctx->EvalMap.Map2Texture2.Uorder;
|
---|
1852 | v[1] = ctx->EvalMap.Map2Texture2.Vorder;
|
---|
1853 | break;
|
---|
1854 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1855 | v[0] = ctx->EvalMap.Map2Texture3.Uorder;
|
---|
1856 | v[1] = ctx->EvalMap.Map2Texture3.Vorder;
|
---|
1857 | break;
|
---|
1858 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1859 | v[0] = ctx->EvalMap.Map2Texture4.Uorder;
|
---|
1860 | v[1] = ctx->EvalMap.Map2Texture4.Vorder;
|
---|
1861 | break;
|
---|
1862 | case GL_MAP2_VERTEX_3:
|
---|
1863 | v[0] = ctx->EvalMap.Map2Vertex3.Uorder;
|
---|
1864 | v[1] = ctx->EvalMap.Map2Vertex3.Vorder;
|
---|
1865 | break;
|
---|
1866 | case GL_MAP2_VERTEX_4:
|
---|
1867 | v[0] = ctx->EvalMap.Map2Vertex4.Uorder;
|
---|
1868 | v[1] = ctx->EvalMap.Map2Vertex4.Vorder;
|
---|
1869 | break;
|
---|
1870 | default:
|
---|
1871 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
|
---|
1872 | return;
|
---|
1873 | }
|
---|
1874 | break;
|
---|
1875 | case GL_DOMAIN:
|
---|
1876 | switch (target) {
|
---|
1877 | case GL_MAP1_COLOR_4:
|
---|
1878 | v[0] = ROUNDF(ctx->EvalMap.Map1Color4.u1);
|
---|
1879 | v[1] = ROUNDF(ctx->EvalMap.Map1Color4.u2);
|
---|
1880 | break;
|
---|
1881 | case GL_MAP1_INDEX:
|
---|
1882 | v[0] = ROUNDF(ctx->EvalMap.Map1Index.u1);
|
---|
1883 | v[1] = ROUNDF(ctx->EvalMap.Map1Index.u2);
|
---|
1884 | break;
|
---|
1885 | case GL_MAP1_NORMAL:
|
---|
1886 | v[0] = ROUNDF(ctx->EvalMap.Map1Normal.u1);
|
---|
1887 | v[1] = ROUNDF(ctx->EvalMap.Map1Normal.u2);
|
---|
1888 | break;
|
---|
1889 | case GL_MAP1_TEXTURE_COORD_1:
|
---|
1890 | v[0] = ROUNDF(ctx->EvalMap.Map1Texture1.u1);
|
---|
1891 | v[1] = ROUNDF(ctx->EvalMap.Map1Texture1.u2);
|
---|
1892 | break;
|
---|
1893 | case GL_MAP1_TEXTURE_COORD_2:
|
---|
1894 | v[0] = ROUNDF(ctx->EvalMap.Map1Texture2.u1);
|
---|
1895 | v[1] = ROUNDF(ctx->EvalMap.Map1Texture2.u2);
|
---|
1896 | break;
|
---|
1897 | case GL_MAP1_TEXTURE_COORD_3:
|
---|
1898 | v[0] = ROUNDF(ctx->EvalMap.Map1Texture3.u1);
|
---|
1899 | v[1] = ROUNDF(ctx->EvalMap.Map1Texture3.u2);
|
---|
1900 | break;
|
---|
1901 | case GL_MAP1_TEXTURE_COORD_4:
|
---|
1902 | v[0] = ROUNDF(ctx->EvalMap.Map1Texture4.u1);
|
---|
1903 | v[1] = ROUNDF(ctx->EvalMap.Map1Texture4.u2);
|
---|
1904 | break;
|
---|
1905 | case GL_MAP1_VERTEX_3:
|
---|
1906 | v[0] = ROUNDF(ctx->EvalMap.Map1Vertex3.u1);
|
---|
1907 | v[1] = ROUNDF(ctx->EvalMap.Map1Vertex3.u2);
|
---|
1908 | break;
|
---|
1909 | case GL_MAP1_VERTEX_4:
|
---|
1910 | v[0] = ROUNDF(ctx->EvalMap.Map1Vertex4.u1);
|
---|
1911 | v[1] = ROUNDF(ctx->EvalMap.Map1Vertex4.u2);
|
---|
1912 | break;
|
---|
1913 | case GL_MAP2_COLOR_4:
|
---|
1914 | v[0] = ROUNDF(ctx->EvalMap.Map2Color4.u1);
|
---|
1915 | v[1] = ROUNDF(ctx->EvalMap.Map2Color4.u2);
|
---|
1916 | v[2] = ROUNDF(ctx->EvalMap.Map2Color4.v1);
|
---|
1917 | v[3] = ROUNDF(ctx->EvalMap.Map2Color4.v2);
|
---|
1918 | break;
|
---|
1919 | case GL_MAP2_INDEX:
|
---|
1920 | v[0] = ROUNDF(ctx->EvalMap.Map2Index.u1);
|
---|
1921 | v[1] = ROUNDF(ctx->EvalMap.Map2Index.u2);
|
---|
1922 | v[2] = ROUNDF(ctx->EvalMap.Map2Index.v1);
|
---|
1923 | v[3] = ROUNDF(ctx->EvalMap.Map2Index.v2);
|
---|
1924 | break;
|
---|
1925 | case GL_MAP2_NORMAL:
|
---|
1926 | v[0] = ROUNDF(ctx->EvalMap.Map2Normal.u1);
|
---|
1927 | v[1] = ROUNDF(ctx->EvalMap.Map2Normal.u2);
|
---|
1928 | v[2] = ROUNDF(ctx->EvalMap.Map2Normal.v1);
|
---|
1929 | v[3] = ROUNDF(ctx->EvalMap.Map2Normal.v2);
|
---|
1930 | break;
|
---|
1931 | case GL_MAP2_TEXTURE_COORD_1:
|
---|
1932 | v[0] = ROUNDF(ctx->EvalMap.Map2Texture1.u1);
|
---|
1933 | v[1] = ROUNDF(ctx->EvalMap.Map2Texture1.u2);
|
---|
1934 | v[2] = ROUNDF(ctx->EvalMap.Map2Texture1.v1);
|
---|
1935 | v[3] = ROUNDF(ctx->EvalMap.Map2Texture1.v2);
|
---|
1936 | break;
|
---|
1937 | case GL_MAP2_TEXTURE_COORD_2:
|
---|
1938 | v[0] = ROUNDF(ctx->EvalMap.Map2Texture2.u1);
|
---|
1939 | v[1] = ROUNDF(ctx->EvalMap.Map2Texture2.u2);
|
---|
1940 | v[2] = ROUNDF(ctx->EvalMap.Map2Texture2.v1);
|
---|
1941 | v[3] = ROUNDF(ctx->EvalMap.Map2Texture2.v2);
|
---|
1942 | break;
|
---|
1943 | case GL_MAP2_TEXTURE_COORD_3:
|
---|
1944 | v[0] = ROUNDF(ctx->EvalMap.Map2Texture3.u1);
|
---|
1945 | v[1] = ROUNDF(ctx->EvalMap.Map2Texture3.u2);
|
---|
1946 | v[2] = ROUNDF(ctx->EvalMap.Map2Texture3.v1);
|
---|
1947 | v[3] = ROUNDF(ctx->EvalMap.Map2Texture3.v2);
|
---|
1948 | break;
|
---|
1949 | case GL_MAP2_TEXTURE_COORD_4:
|
---|
1950 | v[0] = ROUNDF(ctx->EvalMap.Map2Texture4.u1);
|
---|
1951 | v[1] = ROUNDF(ctx->EvalMap.Map2Texture4.u2);
|
---|
1952 | v[2] = ROUNDF(ctx->EvalMap.Map2Texture4.v1);
|
---|
1953 | v[3] = ROUNDF(ctx->EvalMap.Map2Texture4.v2);
|
---|
1954 | break;
|
---|
1955 | case GL_MAP2_VERTEX_3:
|
---|
1956 | v[0] = ROUNDF(ctx->EvalMap.Map2Vertex3.u1);
|
---|
1957 | v[1] = ROUNDF(ctx->EvalMap.Map2Vertex3.u2);
|
---|
1958 | v[2] = ROUNDF(ctx->EvalMap.Map2Vertex3.v1);
|
---|
1959 | v[3] = ROUNDF(ctx->EvalMap.Map2Vertex3.v2);
|
---|
1960 | break;
|
---|
1961 | case GL_MAP2_VERTEX_4:
|
---|
1962 | v[0] = ROUNDF(ctx->EvalMap.Map2Vertex4.u1);
|
---|
1963 | v[1] = ROUNDF(ctx->EvalMap.Map2Vertex4.u2);
|
---|
1964 | v[2] = ROUNDF(ctx->EvalMap.Map2Vertex4.v1);
|
---|
1965 | v[3] = ROUNDF(ctx->EvalMap.Map2Vertex4.v2);
|
---|
1966 | break;
|
---|
1967 | default:
|
---|
1968 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
|
---|
1969 | }
|
---|
1970 | break;
|
---|
1971 | default:
|
---|
1972 | gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" );
|
---|
1973 | }
|
---|
1974 | }
|
---|
1975 |
|
---|
1976 |
|
---|
1977 |
|
---|
1978 | static void eval_points1( GLfloat outcoord[][4],
|
---|
1979 | GLfloat coord[][4],
|
---|
1980 | const GLuint *flags,
|
---|
1981 | GLuint start,
|
---|
1982 | GLfloat du, GLfloat u1 )
|
---|
1983 | {
|
---|
1984 | GLuint i;
|
---|
1985 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
1986 | if (flags[i] & VERT_EVAL_P1)
|
---|
1987 | outcoord[i][0] = coord[i][0] * du + u1;
|
---|
1988 | else if (flags[i] & VERT_EVAL_ANY) {
|
---|
1989 | outcoord[i][0] = coord[i][0];
|
---|
1990 | outcoord[i][1] = coord[i][1];
|
---|
1991 | }
|
---|
1992 | }
|
---|
1993 |
|
---|
1994 | static void eval_points2( GLfloat outcoord[][4],
|
---|
1995 | GLfloat coord[][4],
|
---|
1996 | const GLuint *flags,
|
---|
1997 | GLuint start,
|
---|
1998 | GLfloat du, GLfloat u1,
|
---|
1999 | GLfloat dv, GLfloat v1 )
|
---|
2000 | {
|
---|
2001 | GLuint i;
|
---|
2002 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2003 | if (flags[i] & VERT_EVAL_P2) {
|
---|
2004 | outcoord[i][0] = coord[i][0] * du + u1;
|
---|
2005 | outcoord[i][1] = coord[i][1] * dv + v1;
|
---|
2006 | } else if (flags[i] & VERT_EVAL_ANY) {
|
---|
2007 | outcoord[i][0] = coord[i][0];
|
---|
2008 | outcoord[i][1] = coord[i][1];
|
---|
2009 | }
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 |
|
---|
2013 | static const GLubyte dirty_flags[5] = {
|
---|
2014 | 0, /* not possible */
|
---|
2015 | VEC_DIRTY_0,
|
---|
2016 | VEC_DIRTY_1,
|
---|
2017 | VEC_DIRTY_2,
|
---|
2018 | VEC_DIRTY_3
|
---|
2019 | };
|
---|
2020 |
|
---|
2021 |
|
---|
2022 | static GLvector4f *eval1_4f( GLvector4f *dest,
|
---|
2023 | GLfloat coord[][4],
|
---|
2024 | const GLuint *flags,
|
---|
2025 | GLuint start,
|
---|
2026 | GLuint dimension,
|
---|
2027 | struct gl_1d_map *map )
|
---|
2028 | {
|
---|
2029 | const GLfloat u1 = map->u1;
|
---|
2030 | const GLfloat du = map->du;
|
---|
2031 | GLfloat (*to)[4] = dest->data;
|
---|
2032 | GLuint i;
|
---|
2033 |
|
---|
2034 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2035 | if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
|
---|
2036 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2037 | ASSIGN_4V(to[i], 0,0,0,1);
|
---|
2038 | horner_bezier_curve(map->Points, to[i], u, dimension, map->Order);
|
---|
2039 | }
|
---|
2040 |
|
---|
2041 | dest->count = i;
|
---|
2042 | dest->start = VEC_ELT(dest, GLfloat, start);
|
---|
2043 | dest->size = MAX2(dest->size, dimension);
|
---|
2044 | dest->flags |= dirty_flags[dimension];
|
---|
2045 | return dest;
|
---|
2046 | }
|
---|
2047 |
|
---|
2048 |
|
---|
2049 | static GLvector1ui *eval1_1ui( GLvector1ui *dest,
|
---|
2050 | GLfloat coord[][4],
|
---|
2051 | const GLuint *flags,
|
---|
2052 | GLuint start,
|
---|
2053 | struct gl_1d_map *map )
|
---|
2054 | {
|
---|
2055 | const GLfloat u1 = map->u1;
|
---|
2056 | const GLfloat du = map->du;
|
---|
2057 | GLuint *to = dest->data;
|
---|
2058 | GLuint i;
|
---|
2059 |
|
---|
2060 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2061 | if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
|
---|
2062 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2063 | GLfloat tmp;
|
---|
2064 | horner_bezier_curve(map->Points, &tmp, u, 1, map->Order);
|
---|
2065 | to[i] = (GLuint) (GLint) tmp;
|
---|
2066 | }
|
---|
2067 |
|
---|
2068 | dest->start = VEC_ELT(dest, GLuint, start);
|
---|
2069 | dest->count = i;
|
---|
2070 | return dest;
|
---|
2071 | }
|
---|
2072 |
|
---|
2073 | static GLvector3f *eval1_norm( GLvector3f *dest,
|
---|
2074 | GLfloat coord[][4],
|
---|
2075 | GLuint *flags, /* not const */
|
---|
2076 | GLuint start,
|
---|
2077 | struct gl_1d_map *map )
|
---|
2078 | {
|
---|
2079 | const GLfloat u1 = map->u1;
|
---|
2080 | const GLfloat du = map->du;
|
---|
2081 | GLfloat (*to)[3] = dest->data;
|
---|
2082 | GLuint i;
|
---|
2083 |
|
---|
2084 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2085 | if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
|
---|
2086 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2087 | horner_bezier_curve(map->Points, to[i], u, 3, map->Order);
|
---|
2088 | flags[i+1] |= VERT_NORM; /* reset */
|
---|
2089 | }
|
---|
2090 |
|
---|
2091 | dest->start = VEC_ELT(dest, GLfloat, start);
|
---|
2092 | dest->count = i;
|
---|
2093 | return dest;
|
---|
2094 | }
|
---|
2095 |
|
---|
2096 | static GLvector4ub *eval1_color( GLvector4ub *dest,
|
---|
2097 | GLfloat coord[][4],
|
---|
2098 | GLuint *flags, /* not const */
|
---|
2099 | GLuint start,
|
---|
2100 | struct gl_1d_map *map )
|
---|
2101 | {
|
---|
2102 | const GLfloat u1 = map->u1;
|
---|
2103 | const GLfloat du = map->du;
|
---|
2104 | GLubyte (*to)[4] = dest->data;
|
---|
2105 | GLuint i;
|
---|
2106 |
|
---|
2107 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2108 | if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
|
---|
2109 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2110 | GLfloat fcolor[4];
|
---|
2111 | horner_bezier_curve(map->Points, fcolor, u, 4, map->Order);
|
---|
2112 | FLOAT_RGBA_TO_UBYTE_RGBA(to[i], fcolor);
|
---|
2113 | flags[i+1] |= VERT_RGBA; /* reset */
|
---|
2114 | }
|
---|
2115 |
|
---|
2116 | dest->start = VEC_ELT(dest, GLubyte, start);
|
---|
2117 | dest->count = i;
|
---|
2118 | return dest;
|
---|
2119 | }
|
---|
2120 |
|
---|
2121 |
|
---|
2122 |
|
---|
2123 |
|
---|
2124 | static GLvector4f *eval2_obj_norm( GLvector4f *obj_ptr,
|
---|
2125 | GLvector3f *norm_ptr,
|
---|
2126 | GLfloat coord[][4],
|
---|
2127 | GLuint *flags,
|
---|
2128 | GLuint start,
|
---|
2129 | GLuint dimension,
|
---|
2130 | struct gl_2d_map *map )
|
---|
2131 | {
|
---|
2132 | const GLfloat u1 = map->u1;
|
---|
2133 | const GLfloat du = map->du;
|
---|
2134 | const GLfloat v1 = map->v1;
|
---|
2135 | const GLfloat dv = map->dv;
|
---|
2136 | GLfloat (*obj)[4] = obj_ptr->data;
|
---|
2137 | GLfloat (*normal)[3] = norm_ptr->data;
|
---|
2138 | GLuint i;
|
---|
2139 |
|
---|
2140 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2141 | if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
|
---|
2142 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2143 | GLfloat v = (coord[i][1] - v1) * dv;
|
---|
2144 | GLfloat du[4], dv[4];
|
---|
2145 |
|
---|
2146 | ASSIGN_4V(obj[i], 0,0,0,1);
|
---|
2147 | de_casteljau_surf(map->Points, obj[i], du, dv, u, v, dimension,
|
---|
2148 | map->Uorder, map->Vorder);
|
---|
2149 |
|
---|
2150 | CROSS3(normal[i], du, dv);
|
---|
2151 | NORMALIZE_3FV(normal[i]);
|
---|
2152 | flags[i+1] |= VERT_NORM;
|
---|
2153 | }
|
---|
2154 |
|
---|
2155 | obj_ptr->start = VEC_ELT(obj_ptr, GLfloat, start);
|
---|
2156 | obj_ptr->count = i;
|
---|
2157 | obj_ptr->size = MAX2(obj_ptr->size, dimension);
|
---|
2158 | obj_ptr->flags |= dirty_flags[dimension];
|
---|
2159 | return obj_ptr;
|
---|
2160 | }
|
---|
2161 |
|
---|
2162 |
|
---|
2163 | static GLvector4f *eval2_4f( GLvector4f *dest,
|
---|
2164 | GLfloat coord[][4],
|
---|
2165 | const GLuint *flags,
|
---|
2166 | GLuint start,
|
---|
2167 | GLuint dimension,
|
---|
2168 | struct gl_2d_map *map )
|
---|
2169 | {
|
---|
2170 | const GLfloat u1 = map->u1;
|
---|
2171 | const GLfloat du = map->du;
|
---|
2172 | const GLfloat v1 = map->v1;
|
---|
2173 | const GLfloat dv = map->dv;
|
---|
2174 | GLfloat (*to)[4] = dest->data;
|
---|
2175 | GLuint i;
|
---|
2176 |
|
---|
2177 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2178 | if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
|
---|
2179 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2180 | GLfloat v = (coord[i][1] - v1) * dv;
|
---|
2181 | horner_bezier_surf(map->Points, to[i], u, v, dimension,
|
---|
2182 | map->Uorder, map->Vorder);
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 | dest->start = VEC_ELT(dest, GLfloat, start);
|
---|
2186 | dest->count = i;
|
---|
2187 | dest->size = MAX2(dest->size, dimension);
|
---|
2188 | dest->flags |= dirty_flags[dimension];
|
---|
2189 | return dest;
|
---|
2190 | }
|
---|
2191 |
|
---|
2192 |
|
---|
2193 | static GLvector3f *eval2_norm( GLvector3f *dest,
|
---|
2194 | GLfloat coord[][4],
|
---|
2195 | GLuint *flags,
|
---|
2196 | GLuint start,
|
---|
2197 | struct gl_2d_map *map )
|
---|
2198 | {
|
---|
2199 | const GLfloat u1 = map->u1;
|
---|
2200 | const GLfloat du = map->du;
|
---|
2201 | const GLfloat v1 = map->v1;
|
---|
2202 | const GLfloat dv = map->dv;
|
---|
2203 | GLfloat (*to)[3] = dest->data;
|
---|
2204 | GLuint i;
|
---|
2205 |
|
---|
2206 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2207 | if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
|
---|
2208 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2209 | GLfloat v = (coord[i][1] - v1) * dv;
|
---|
2210 | horner_bezier_surf(map->Points, to[i], u, v, 3,
|
---|
2211 | map->Uorder, map->Vorder);
|
---|
2212 | flags[i+1] |= VERT_NORM; /* reset */
|
---|
2213 | }
|
---|
2214 |
|
---|
2215 | dest->start = VEC_ELT(dest, GLfloat, start);
|
---|
2216 | dest->count = i;
|
---|
2217 | return dest;
|
---|
2218 | }
|
---|
2219 |
|
---|
2220 |
|
---|
2221 | static GLvector1ui *eval2_1ui( GLvector1ui *dest,
|
---|
2222 | GLfloat coord[][4],
|
---|
2223 | const GLuint *flags,
|
---|
2224 | GLuint start,
|
---|
2225 | struct gl_2d_map *map )
|
---|
2226 | {
|
---|
2227 | const GLfloat u1 = map->u1;
|
---|
2228 | const GLfloat du = map->du;
|
---|
2229 | const GLfloat v1 = map->v1;
|
---|
2230 | const GLfloat dv = map->dv;
|
---|
2231 | GLuint *to = dest->data;
|
---|
2232 | GLuint i;
|
---|
2233 |
|
---|
2234 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2235 | if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
|
---|
2236 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2237 | GLfloat v = (coord[i][1] - v1) * dv;
|
---|
2238 | GLfloat tmp;
|
---|
2239 | horner_bezier_surf(map->Points, &tmp, u, v, 1,
|
---|
2240 | map->Uorder, map->Vorder);
|
---|
2241 |
|
---|
2242 | to[i] = (GLuint) (GLint) tmp;
|
---|
2243 | }
|
---|
2244 |
|
---|
2245 | dest->start = VEC_ELT(dest, GLuint, start);
|
---|
2246 | dest->count = i;
|
---|
2247 | return dest;
|
---|
2248 | }
|
---|
2249 |
|
---|
2250 |
|
---|
2251 |
|
---|
2252 | static GLvector4ub *eval2_color( GLvector4ub *dest,
|
---|
2253 | GLfloat coord[][4],
|
---|
2254 | GLuint *flags,
|
---|
2255 | GLuint start,
|
---|
2256 | struct gl_2d_map *map )
|
---|
2257 | {
|
---|
2258 | const GLfloat u1 = map->u1;
|
---|
2259 | const GLfloat du = map->du;
|
---|
2260 | const GLfloat v1 = map->v1;
|
---|
2261 | const GLfloat dv = map->dv;
|
---|
2262 | GLubyte (*to)[4] = dest->data;
|
---|
2263 | GLuint i;
|
---|
2264 |
|
---|
2265 | for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2266 | if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
|
---|
2267 | GLfloat u = (coord[i][0] - u1) * du;
|
---|
2268 | GLfloat v = (coord[i][1] - v1) * dv;
|
---|
2269 | GLfloat fcolor[4];
|
---|
2270 | horner_bezier_surf(map->Points, fcolor, u, v, 4,
|
---|
2271 | map->Uorder, map->Vorder);
|
---|
2272 | FLOAT_RGBA_TO_UBYTE_RGBA(to[i], fcolor);
|
---|
2273 | flags[i+1] |= VERT_RGBA; /* reset */
|
---|
2274 | }
|
---|
2275 |
|
---|
2276 | dest->start = VEC_ELT(dest, GLubyte, start);
|
---|
2277 | dest->count = i;
|
---|
2278 | return dest;
|
---|
2279 | }
|
---|
2280 |
|
---|
2281 |
|
---|
2282 | static GLvector4f *copy_4f( GLvector4f *out, CONST GLvector4f *in,
|
---|
2283 | const GLuint *flags,
|
---|
2284 | GLuint start )
|
---|
2285 | {
|
---|
2286 | GLfloat (*to)[4] = out->data;
|
---|
2287 | GLfloat (*from)[4] = in->data;
|
---|
2288 | GLuint i;
|
---|
2289 |
|
---|
2290 | for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2291 | if (!(flags[i] & VERT_EVAL_ANY))
|
---|
2292 | COPY_4FV( to[i], from[i] );
|
---|
2293 |
|
---|
2294 | out->start = VEC_ELT(out, GLfloat, start);
|
---|
2295 | return out;
|
---|
2296 | }
|
---|
2297 |
|
---|
2298 | static GLvector3f *copy_3f( GLvector3f *out, CONST GLvector3f *in,
|
---|
2299 | const GLuint *flags,
|
---|
2300 | GLuint start )
|
---|
2301 | {
|
---|
2302 | GLfloat (*to)[3] = out->data;
|
---|
2303 | GLfloat (*from)[3] = in->data;
|
---|
2304 | GLuint i;
|
---|
2305 |
|
---|
2306 | for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2307 | if (!(flags[i] & VERT_EVAL_ANY))
|
---|
2308 | COPY_3V( to[i], from[i] );
|
---|
2309 |
|
---|
2310 | out->start = VEC_ELT(out, GLfloat, start);
|
---|
2311 | return out;
|
---|
2312 | }
|
---|
2313 |
|
---|
2314 | static GLvector4ub *copy_4ub( GLvector4ub *out,
|
---|
2315 | CONST GLvector4ub *in,
|
---|
2316 | const GLuint *flags,
|
---|
2317 | GLuint start )
|
---|
2318 | {
|
---|
2319 | GLubyte (*to)[4] = out->data;
|
---|
2320 | GLubyte (*from)[4] = in->data;
|
---|
2321 | GLuint i;
|
---|
2322 |
|
---|
2323 | for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2324 | if (!(flags[i] & VERT_EVAL_ANY))
|
---|
2325 | COPY_4UBV( to[i], from[i] );
|
---|
2326 |
|
---|
2327 | out->start = VEC_ELT(out, GLubyte, start);
|
---|
2328 | return out;
|
---|
2329 | }
|
---|
2330 |
|
---|
2331 | static GLvector1ui *copy_1ui( GLvector1ui *out,
|
---|
2332 | CONST GLvector1ui *in,
|
---|
2333 | const GLuint *flags,
|
---|
2334 | GLuint start )
|
---|
2335 | {
|
---|
2336 | GLuint *to = out->data;
|
---|
2337 | CONST GLuint *from = in->data;
|
---|
2338 | GLuint i;
|
---|
2339 |
|
---|
2340 | for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
|
---|
2341 | if (!(flags[i] & VERT_EVAL_ANY))
|
---|
2342 | to[i] = from[i];
|
---|
2343 |
|
---|
2344 | out->start = VEC_ELT(out, GLuint, start);
|
---|
2345 | return out;
|
---|
2346 | }
|
---|
2347 |
|
---|
2348 |
|
---|
2349 | /* KW: Rewrote this to perform eval on a whole buffer at once.
|
---|
2350 | * Only evaluates active data items, and avoids scribbling
|
---|
2351 | * the source buffer if we are running from a display list.
|
---|
2352 | *
|
---|
2353 | * If the user (in this case looser) sends eval coordinates
|
---|
2354 | * or runs a display list containing eval coords with no
|
---|
2355 | * vertex maps enabled, we have to either copy all non-eval
|
---|
2356 | * data to a new buffer, or find a way of working around
|
---|
2357 | * the eval data. I choose the second option.
|
---|
2358 | *
|
---|
2359 | * KW: This code not reached by cva - use IM to access storage.
|
---|
2360 | */
|
---|
2361 | void gl_eval_vb( struct vertex_buffer *VB )
|
---|
2362 | {
|
---|
2363 | struct immediate *IM = VB->IM;
|
---|
2364 | GLcontext *ctx = VB->ctx;
|
---|
2365 | GLuint req = ctx->CVA.elt.inputs;
|
---|
2366 | GLfloat (*coord)[4] = VB->ObjPtr->data;
|
---|
2367 | GLuint *flags = VB->Flag;
|
---|
2368 | GLuint new_flags = 0;
|
---|
2369 |
|
---|
2370 |
|
---|
2371 | GLuint any_eval1 = VB->OrFlag & (VERT_EVAL_C1|VERT_EVAL_P1);
|
---|
2372 | GLuint any_eval2 = VB->OrFlag & (VERT_EVAL_C2|VERT_EVAL_P2);
|
---|
2373 | GLuint all_eval = IM->AndFlag & VERT_EVAL_ANY;
|
---|
2374 |
|
---|
2375 | /* Handle the degenerate cases.
|
---|
2376 | */
|
---|
2377 | if (any_eval1 && !ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3) {
|
---|
2378 | VB->PurgeFlags |= (VERT_EVAL_C1|VERT_EVAL_P1);
|
---|
2379 | VB->EarlyCull = 0;
|
---|
2380 | any_eval1 = GL_FALSE;
|
---|
2381 | }
|
---|
2382 |
|
---|
2383 | if (any_eval2 && !ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3) {
|
---|
2384 | VB->PurgeFlags |= (VERT_EVAL_C2|VERT_EVAL_P2);
|
---|
2385 | VB->EarlyCull = 0;
|
---|
2386 | any_eval2 = GL_FALSE;
|
---|
2387 | }
|
---|
2388 |
|
---|
2389 | /* KW: This really is a degenerate case - doing this disables
|
---|
2390 | * culling, and causes dummy values for the missing vertices to be
|
---|
2391 | * transformed and clip tested. It also forces the individual
|
---|
2392 | * cliptesting of each primitive in vb_render. I wish there was a
|
---|
2393 | * nice alternative, but I can't say I want to put effort into
|
---|
2394 | * optimizing such a bad usage of the library - I'd much rather
|
---|
2395 | * work on useful changes.
|
---|
2396 | */
|
---|
2397 | if (VB->PurgeFlags) {
|
---|
2398 | if (!any_eval1 && !any_eval2 && all_eval) VB->Count = VB->Start;
|
---|
2399 | gl_purge_vertices( VB );
|
---|
2400 | if (!any_eval1 && !any_eval2) return;
|
---|
2401 | } else
|
---|
2402 | VB->IndirectCount = VB->Count;
|
---|
2403 |
|
---|
2404 | /* Translate points into coords.
|
---|
2405 | */
|
---|
2406 | if (any_eval1 && (VB->OrFlag & VERT_EVAL_P1))
|
---|
2407 | {
|
---|
2408 | eval_points1( IM->Obj, coord, flags, IM->Start,
|
---|
2409 | ctx->Eval.MapGrid1du,
|
---|
2410 | ctx->Eval.MapGrid1u1);
|
---|
2411 |
|
---|
2412 | coord = IM->Obj;
|
---|
2413 | }
|
---|
2414 |
|
---|
2415 | if (any_eval2 && (VB->OrFlag & VERT_EVAL_P2))
|
---|
2416 | {
|
---|
2417 | eval_points2( IM->Obj, coord, flags, IM->Start,
|
---|
2418 | ctx->Eval.MapGrid2du,
|
---|
2419 | ctx->Eval.MapGrid2u1,
|
---|
2420 | ctx->Eval.MapGrid2dv,
|
---|
2421 | ctx->Eval.MapGrid2v1 );
|
---|
2422 |
|
---|
2423 | coord = IM->Obj;
|
---|
2424 | }
|
---|
2425 |
|
---|
2426 | /* Perform the evaluations on active data elements.
|
---|
2427 | */
|
---|
2428 | if (req & VERT_INDEX)
|
---|
2429 | {
|
---|
2430 | GLvector1ui *in_index = VB->IndexPtr;
|
---|
2431 | GLvector1ui *out_index = &IM->v.Index;
|
---|
2432 |
|
---|
2433 | if (ctx->Eval.Map1Index && any_eval1)
|
---|
2434 | VB->IndexPtr = eval1_1ui( out_index, coord, flags, IM->Start,
|
---|
2435 | &ctx->EvalMap.Map1Index );
|
---|
2436 |
|
---|
2437 | if (ctx->Eval.Map2Index && any_eval2)
|
---|
2438 | VB->IndexPtr = eval2_1ui( out_index, coord, flags, IM->Start,
|
---|
2439 | &ctx->EvalMap.Map2Index );
|
---|
2440 |
|
---|
2441 | if (VB->IndexPtr != in_index) {
|
---|
2442 | new_flags |= VERT_INDEX;
|
---|
2443 | if (!all_eval)
|
---|
2444 | VB->IndexPtr = copy_1ui( out_index, in_index, flags, IM->Start );
|
---|
2445 | }
|
---|
2446 | }
|
---|
2447 |
|
---|
2448 | if (req & VERT_RGBA)
|
---|
2449 | {
|
---|
2450 | GLvector4ub *in_color = VB->ColorPtr;
|
---|
2451 | GLvector4ub *out_color = &IM->v.Color;
|
---|
2452 |
|
---|
2453 | if (ctx->Eval.Map1Color4 && any_eval1)
|
---|
2454 | VB->ColorPtr = eval1_color( out_color, coord, flags, IM->Start,
|
---|
2455 | &ctx->EvalMap.Map1Color4 );
|
---|
2456 |
|
---|
2457 | if (ctx->Eval.Map2Color4 && any_eval2)
|
---|
2458 | VB->ColorPtr = eval2_color( out_color, coord, flags, IM->Start,
|
---|
2459 | &ctx->EvalMap.Map2Color4 );
|
---|
2460 |
|
---|
2461 | if (VB->ColorPtr != in_color) {
|
---|
2462 | new_flags |= VERT_RGBA;
|
---|
2463 | if (!all_eval)
|
---|
2464 | VB->ColorPtr = copy_4ub( out_color, in_color, flags, IM->Start );
|
---|
2465 | }
|
---|
2466 |
|
---|
2467 | VB->Color[0] = VB->Color[1] = VB->ColorPtr;
|
---|
2468 | }
|
---|
2469 |
|
---|
2470 |
|
---|
2471 | if (req & VERT_NORM)
|
---|
2472 | {
|
---|
2473 | GLvector3f *in_normal = VB->NormalPtr;
|
---|
2474 | GLvector3f *out_normal = &IM->v.Normal;
|
---|
2475 |
|
---|
2476 | if (ctx->Eval.Map1Normal && any_eval1)
|
---|
2477 | VB->NormalPtr = eval1_norm( out_normal, coord, flags, IM->Start,
|
---|
2478 | &ctx->EvalMap.Map1Normal );
|
---|
2479 |
|
---|
2480 | if (ctx->Eval.Map2Normal && any_eval2)
|
---|
2481 | VB->NormalPtr = eval2_norm( out_normal, coord, flags, IM->Start,
|
---|
2482 | &ctx->EvalMap.Map2Normal );
|
---|
2483 |
|
---|
2484 | if (VB->NormalPtr != in_normal) {
|
---|
2485 | new_flags |= VERT_NORM;
|
---|
2486 | if (!all_eval)
|
---|
2487 | VB->NormalPtr = copy_3f( out_normal, in_normal, flags, IM->Start );
|
---|
2488 | }
|
---|
2489 | }
|
---|
2490 |
|
---|
2491 |
|
---|
2492 | if (req & VERT_TEX_ANY(0))
|
---|
2493 | {
|
---|
2494 | GLvector4f *tc = VB->TexCoordPtr[0];
|
---|
2495 | GLvector4f *in = tc;
|
---|
2496 | GLvector4f *out = &IM->v.TexCoord[0];
|
---|
2497 |
|
---|
2498 | if (any_eval1) {
|
---|
2499 | if (ctx->Eval.Map1TextureCoord4)
|
---|
2500 | tc = eval1_4f( out, coord, flags, IM->Start,
|
---|
2501 | 4, &ctx->EvalMap.Map1Texture4);
|
---|
2502 | else if (ctx->Eval.Map1TextureCoord3)
|
---|
2503 | tc = eval1_4f( out, coord, flags, IM->Start, 3,
|
---|
2504 | &ctx->EvalMap.Map1Texture3);
|
---|
2505 | else if (ctx->Eval.Map1TextureCoord2)
|
---|
2506 | tc = eval1_4f( out, coord, flags, IM->Start, 2,
|
---|
2507 | &ctx->EvalMap.Map1Texture2);
|
---|
2508 | else if (ctx->Eval.Map1TextureCoord1)
|
---|
2509 | tc = eval1_4f( out, coord, flags, IM->Start, 1,
|
---|
2510 | &ctx->EvalMap.Map1Texture1);
|
---|
2511 | }
|
---|
2512 |
|
---|
2513 | if (any_eval2) {
|
---|
2514 | if (ctx->Eval.Map2TextureCoord4)
|
---|
2515 | tc = eval2_4f( out, coord, flags, IM->Start,
|
---|
2516 | 4, &ctx->EvalMap.Map2Texture4);
|
---|
2517 | else if (ctx->Eval.Map2TextureCoord3)
|
---|
2518 | tc = eval2_4f( out, coord, flags, IM->Start,
|
---|
2519 | 3, &ctx->EvalMap.Map2Texture3);
|
---|
2520 | else if (ctx->Eval.Map2TextureCoord2)
|
---|
2521 | tc = eval2_4f( out, coord, flags, IM->Start,
|
---|
2522 | 2, &ctx->EvalMap.Map2Texture2);
|
---|
2523 | else if (ctx->Eval.Map2TextureCoord1)
|
---|
2524 | tc = eval2_4f( out, coord, flags, IM->Start,
|
---|
2525 | 1, &ctx->EvalMap.Map2Texture1);
|
---|
2526 | }
|
---|
2527 |
|
---|
2528 | if (tc != in) {
|
---|
2529 | new_flags |= VERT_TEX_ANY(0); /* fix for sizes.. */
|
---|
2530 | if (!all_eval)
|
---|
2531 | tc = copy_4f( out, in, flags, IM->Start );
|
---|
2532 | }
|
---|
2533 |
|
---|
2534 | VB->TexCoordPtr[0] = tc;
|
---|
2535 | }
|
---|
2536 |
|
---|
2537 |
|
---|
2538 | {
|
---|
2539 | GLvector4f *in = VB->ObjPtr;
|
---|
2540 | GLvector4f *out = &IM->v.Obj;
|
---|
2541 | GLvector4f *obj = in;
|
---|
2542 |
|
---|
2543 | if (any_eval1) {
|
---|
2544 | if (ctx->Eval.Map1Vertex4)
|
---|
2545 | obj = eval1_4f( out, coord, flags, IM->Start,
|
---|
2546 | 4, &ctx->EvalMap.Map1Vertex4);
|
---|
2547 | else
|
---|
2548 | obj = eval1_4f( out, coord, flags, IM->Start,
|
---|
2549 | 3, &ctx->EvalMap.Map1Vertex3);
|
---|
2550 | }
|
---|
2551 |
|
---|
2552 | if (any_eval2) {
|
---|
2553 | if (ctx->Eval.Map2Vertex4)
|
---|
2554 | {
|
---|
2555 | if (ctx->Eval.AutoNormal && (req & VERT_NORM))
|
---|
2556 | obj = eval2_obj_norm( out, VB->NormalPtr, coord, flags, IM->Start,
|
---|
2557 | 4, &ctx->EvalMap.Map2Vertex4 );
|
---|
2558 | else
|
---|
2559 | obj = eval2_4f( out, coord, flags, IM->Start,
|
---|
2560 | 4, &ctx->EvalMap.Map2Vertex4);
|
---|
2561 | }
|
---|
2562 | else if (ctx->Eval.Map2Vertex3)
|
---|
2563 | {
|
---|
2564 | if (ctx->Eval.AutoNormal && (req & VERT_NORM))
|
---|
2565 | obj = eval2_obj_norm( out, VB->NormalPtr, coord, flags, IM->Start,
|
---|
2566 | 3, &ctx->EvalMap.Map2Vertex3 );
|
---|
2567 | else
|
---|
2568 | obj = eval2_4f( out, coord, flags, IM->Start,
|
---|
2569 | 3, &ctx->EvalMap.Map2Vertex3 );
|
---|
2570 | }
|
---|
2571 | }
|
---|
2572 |
|
---|
2573 | if (obj != in && !all_eval)
|
---|
2574 | obj = copy_4f( out, in, flags, IM->Start );
|
---|
2575 |
|
---|
2576 | VB->ObjPtr = obj;
|
---|
2577 | }
|
---|
2578 |
|
---|
2579 | if (new_flags) {
|
---|
2580 | GLuint *oldflags = VB->Flag;
|
---|
2581 | GLuint *flags = VB->Flag = VB->EvaluatedFlags;
|
---|
2582 | GLuint i;
|
---|
2583 | GLuint count = VB->Count;
|
---|
2584 |
|
---|
2585 | if (!flags) {
|
---|
2586 | VB->EvaluatedFlags = (GLuint *) MALLOC(VB->Size * sizeof(GLuint));
|
---|
2587 | flags = VB->Flag = VB->EvaluatedFlags;
|
---|
2588 | }
|
---|
2589 |
|
---|
2590 | if (all_eval) {
|
---|
2591 | for (i = 0 ; i < count ; i++)
|
---|
2592 | flags[i] = oldflags[i] | new_flags;
|
---|
2593 | } else {
|
---|
2594 | GLuint andflag = ~0;
|
---|
2595 | for (i = 0 ; i < count ; i++) {
|
---|
2596 | if (oldflags[i] & VERT_EVAL_ANY)
|
---|
2597 | flags[i] = oldflags[i] | new_flags;
|
---|
2598 | andflag &= flags[i];
|
---|
2599 | }
|
---|
2600 | }
|
---|
2601 | }
|
---|
2602 | }
|
---|
2603 |
|
---|
2604 |
|
---|
2605 | void
|
---|
2606 | _mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
|
---|
2607 | {
|
---|
2608 | GET_CURRENT_CONTEXT(ctx);
|
---|
2609 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid1f");
|
---|
2610 |
|
---|
2611 | if (un<1) {
|
---|
2612 | gl_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" );
|
---|
2613 | return;
|
---|
2614 | }
|
---|
2615 | ctx->Eval.MapGrid1un = un;
|
---|
2616 | ctx->Eval.MapGrid1u1 = u1;
|
---|
2617 | ctx->Eval.MapGrid1u2 = u2;
|
---|
2618 | ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un;
|
---|
2619 | }
|
---|
2620 |
|
---|
2621 |
|
---|
2622 | void
|
---|
2623 | _mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
|
---|
2624 | {
|
---|
2625 | _mesa_MapGrid1f( un, u1, u2 );
|
---|
2626 | }
|
---|
2627 |
|
---|
2628 |
|
---|
2629 | void
|
---|
2630 | _mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
|
---|
2631 | GLint vn, GLfloat v1, GLfloat v2 )
|
---|
2632 | {
|
---|
2633 | GET_CURRENT_CONTEXT(ctx);
|
---|
2634 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid2f");
|
---|
2635 | if (un<1) {
|
---|
2636 | gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" );
|
---|
2637 | return;
|
---|
2638 | }
|
---|
2639 | if (vn<1) {
|
---|
2640 | gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" );
|
---|
2641 | return;
|
---|
2642 | }
|
---|
2643 | ctx->Eval.MapGrid2un = un;
|
---|
2644 | ctx->Eval.MapGrid2u1 = u1;
|
---|
2645 | ctx->Eval.MapGrid2u2 = u2;
|
---|
2646 | ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un;
|
---|
2647 | ctx->Eval.MapGrid2vn = vn;
|
---|
2648 | ctx->Eval.MapGrid2v1 = v1;
|
---|
2649 | ctx->Eval.MapGrid2v2 = v2;
|
---|
2650 | ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn;
|
---|
2651 | }
|
---|
2652 |
|
---|
2653 |
|
---|
2654 | void
|
---|
2655 | _mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
|
---|
2656 | GLint vn, GLdouble v1, GLdouble v2 )
|
---|
2657 | {
|
---|
2658 | _mesa_MapGrid2f( un, u1, u2, vn, v1, v2 );
|
---|
2659 | }
|
---|
2660 |
|
---|
2661 |
|
---|
2662 |
|
---|
2663 |
|
---|
2664 | /* KW: If are compiling, we don't know whether eval will produce a
|
---|
2665 | * vertex when it is run in the future. If this is pure immediate
|
---|
2666 | * mode, eval is a noop if neither vertex map is enabled.
|
---|
2667 | *
|
---|
2668 | * Thus we need to have a check in the display list code or
|
---|
2669 | * elsewhere for eval(1,2) vertices in the case where
|
---|
2670 | * map(1,2)_vertex is disabled, and to purge those vertices from
|
---|
2671 | * the vb. This is currently done
|
---|
2672 | * via modifications to the cull_vb and render_vb operations, and
|
---|
2673 | * by using the existing cullmask mechanism for all other operations.
|
---|
2674 | */
|
---|
2675 |
|
---|
2676 |
|
---|
2677 | /* KW: Because the eval values don't become 'current', fixup will flow
|
---|
2678 | * through these vertices, and then evaluation will write on top
|
---|
2679 | * of the fixup results.
|
---|
2680 | *
|
---|
2681 | * This is a little inefficient, but at least it is correct. This
|
---|
2682 | * could be short-circuited in the case where all vertices are
|
---|
2683 | * eval-vertices, or more generally by a cullmask in fixup.
|
---|
2684 | *
|
---|
2685 | * Note: using Obj to hold eval coord data. This data is actually
|
---|
2686 | * transformed if eval is disabled. But disabling eval & sending
|
---|
2687 | * eval coords is stupid, right?
|
---|
2688 | */
|
---|
2689 |
|
---|
2690 |
|
---|
2691 | #define EVALCOORD1(IM, x) \
|
---|
2692 | { \
|
---|
2693 | GLuint count = IM->Count++; \
|
---|
2694 | IM->Flag[count] |= VERT_EVAL_C1; \
|
---|
2695 | ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
|
---|
2696 | if (count == VB_MAX-1) \
|
---|
2697 | IM->maybe_transform_vb( IM ); \
|
---|
2698 | }
|
---|
2699 |
|
---|
2700 | #define EVALCOORD2(IM, x, y) \
|
---|
2701 | { \
|
---|
2702 | GLuint count = IM->Count++; \
|
---|
2703 | IM->Flag[count] |= VERT_EVAL_C2; \
|
---|
2704 | ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
|
---|
2705 | if (count == VB_MAX-1) \
|
---|
2706 | IM->maybe_transform_vb( IM ); \
|
---|
2707 | }
|
---|
2708 |
|
---|
2709 | #define EVALPOINT1(IM, x) \
|
---|
2710 | { \
|
---|
2711 | GLuint count = IM->Count++; \
|
---|
2712 | IM->Flag[count] |= VERT_EVAL_P1; \
|
---|
2713 | ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
|
---|
2714 | if (count == VB_MAX-1) \
|
---|
2715 | IM->maybe_transform_vb( IM ); \
|
---|
2716 | }
|
---|
2717 |
|
---|
2718 | #define EVALPOINT2(IM, x, y) \
|
---|
2719 | { \
|
---|
2720 | GLuint count = IM->Count++; \
|
---|
2721 | IM->Flag[count] |= VERT_EVAL_P2; \
|
---|
2722 | ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
|
---|
2723 | if (count == VB_MAX-1) \
|
---|
2724 | IM->maybe_transform_vb( IM ); \
|
---|
2725 | }
|
---|
2726 |
|
---|
2727 |
|
---|
2728 | /* Lame internal function:
|
---|
2729 | */
|
---|
2730 | static void
|
---|
2731 | eval_coord1f( GLcontext *CC, GLfloat u )
|
---|
2732 | {
|
---|
2733 | struct immediate *i = CC->input;
|
---|
2734 | EVALCOORD1( i, u );
|
---|
2735 | }
|
---|
2736 |
|
---|
2737 |
|
---|
2738 | void
|
---|
2739 | _mesa_EvalCoord1d( GLdouble u )
|
---|
2740 | {
|
---|
2741 | GET_IMMEDIATE;
|
---|
2742 | EVALCOORD1( IM, (GLfloat) u );
|
---|
2743 | }
|
---|
2744 |
|
---|
2745 |
|
---|
2746 | void
|
---|
2747 | _mesa_EvalCoord1f( GLfloat u )
|
---|
2748 | {
|
---|
2749 | GET_IMMEDIATE;
|
---|
2750 | EVALCOORD1( IM, u );
|
---|
2751 | }
|
---|
2752 |
|
---|
2753 |
|
---|
2754 | void
|
---|
2755 | _mesa_EvalCoord1dv( const GLdouble *u )
|
---|
2756 | {
|
---|
2757 | GET_IMMEDIATE;
|
---|
2758 | EVALCOORD1( IM, (GLfloat) *u );
|
---|
2759 | }
|
---|
2760 |
|
---|
2761 |
|
---|
2762 | void
|
---|
2763 | _mesa_EvalCoord1fv( const GLfloat *u )
|
---|
2764 | {
|
---|
2765 | GET_IMMEDIATE;
|
---|
2766 | EVALCOORD1( IM, (GLfloat) *u );
|
---|
2767 | }
|
---|
2768 |
|
---|
2769 |
|
---|
2770 | void
|
---|
2771 | _mesa_EvalCoord2d( GLdouble u, GLdouble v )
|
---|
2772 | {
|
---|
2773 | GET_IMMEDIATE;
|
---|
2774 | EVALCOORD2( IM, (GLfloat) u, (GLfloat) v );
|
---|
2775 | }
|
---|
2776 |
|
---|
2777 |
|
---|
2778 | void
|
---|
2779 | _mesa_EvalCoord2f( GLfloat u, GLfloat v )
|
---|
2780 | {
|
---|
2781 | GET_IMMEDIATE;
|
---|
2782 | EVALCOORD2( IM, u, v );
|
---|
2783 | }
|
---|
2784 |
|
---|
2785 |
|
---|
2786 | /* Lame internal function:
|
---|
2787 | */
|
---|
2788 | static void
|
---|
2789 | eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v )
|
---|
2790 | {
|
---|
2791 | struct immediate *i = CC->input;
|
---|
2792 | EVALCOORD2( i, u, v );
|
---|
2793 | }
|
---|
2794 |
|
---|
2795 |
|
---|
2796 | void
|
---|
2797 | _mesa_EvalCoord2dv( const GLdouble *u )
|
---|
2798 | {
|
---|
2799 | GET_IMMEDIATE;
|
---|
2800 | EVALCOORD2( IM, (GLfloat) u[0], (GLfloat) u[1] );
|
---|
2801 | }
|
---|
2802 |
|
---|
2803 |
|
---|
2804 | void
|
---|
2805 | _mesa_EvalCoord2fv( const GLfloat *u )
|
---|
2806 | {
|
---|
2807 | GET_IMMEDIATE;
|
---|
2808 | EVALCOORD2( IM, u[0], u[1] );
|
---|
2809 | }
|
---|
2810 |
|
---|
2811 |
|
---|
2812 | void
|
---|
2813 | _mesa_EvalPoint1( GLint i )
|
---|
2814 | {
|
---|
2815 | GET_IMMEDIATE;
|
---|
2816 | EVALPOINT1( IM, i );
|
---|
2817 | }
|
---|
2818 |
|
---|
2819 |
|
---|
2820 | void
|
---|
2821 | _mesa_EvalPoint2( GLint i, GLint j )
|
---|
2822 | {
|
---|
2823 | GET_IMMEDIATE;
|
---|
2824 | EVALPOINT2( IM, i, j );
|
---|
2825 | }
|
---|
2826 |
|
---|
2827 |
|
---|
2828 |
|
---|
2829 |
|
---|
2830 |
|
---|
2831 | void
|
---|
2832 | _mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
|
---|
2833 | {
|
---|
2834 | GET_CURRENT_CONTEXT(ctx);
|
---|
2835 | GLint i;
|
---|
2836 | GLfloat u, du;
|
---|
2837 | GLenum prim;
|
---|
2838 |
|
---|
2839 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glEvalMesh1");
|
---|
2840 |
|
---|
2841 | switch (mode) {
|
---|
2842 | case GL_POINT:
|
---|
2843 | prim = GL_POINTS;
|
---|
2844 | break;
|
---|
2845 | case GL_LINE:
|
---|
2846 | prim = GL_LINE_STRIP;
|
---|
2847 | break;
|
---|
2848 | default:
|
---|
2849 | gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
|
---|
2850 | return;
|
---|
2851 | }
|
---|
2852 |
|
---|
2853 | /* No effect if vertex maps disabled.
|
---|
2854 | */
|
---|
2855 | if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3)
|
---|
2856 | return;
|
---|
2857 |
|
---|
2858 | du = ctx->Eval.MapGrid1du;
|
---|
2859 | u = ctx->Eval.MapGrid1u1 + i1 * du;
|
---|
2860 |
|
---|
2861 | /* KW: Could short-circuit this to avoid the immediate mechanism.
|
---|
2862 | */
|
---|
2863 | RESET_IMMEDIATE(ctx);
|
---|
2864 |
|
---|
2865 | gl_Begin( ctx, prim );
|
---|
2866 | for (i=i1;i<=i2;i++,u+=du) {
|
---|
2867 | eval_coord1f( ctx, u );
|
---|
2868 | }
|
---|
2869 | gl_End(ctx);
|
---|
2870 | }
|
---|
2871 |
|
---|
2872 |
|
---|
2873 |
|
---|
2874 | void
|
---|
2875 | _mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
|
---|
2876 | {
|
---|
2877 | GET_CURRENT_CONTEXT(ctx);
|
---|
2878 | GLint i, j;
|
---|
2879 | GLfloat u, du, v, dv, v1, u1;
|
---|
2880 |
|
---|
2881 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glEvalMesh2");
|
---|
2882 |
|
---|
2883 | /* No effect if vertex maps disabled.
|
---|
2884 | */
|
---|
2885 | if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3)
|
---|
2886 | return;
|
---|
2887 |
|
---|
2888 | du = ctx->Eval.MapGrid2du;
|
---|
2889 | dv = ctx->Eval.MapGrid2dv;
|
---|
2890 | v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
|
---|
2891 | u1 = ctx->Eval.MapGrid2u1 + i1 * du;
|
---|
2892 |
|
---|
2893 | RESET_IMMEDIATE(ctx);
|
---|
2894 |
|
---|
2895 | switch (mode) {
|
---|
2896 | case GL_POINT:
|
---|
2897 | gl_Begin( ctx, GL_POINTS );
|
---|
2898 | for (v=v1,j=j1;j<=j2;j++,v+=dv) {
|
---|
2899 | for (u=u1,i=i1;i<=i2;i++,u+=du) {
|
---|
2900 | eval_coord2f( ctx, u, v );
|
---|
2901 | }
|
---|
2902 | }
|
---|
2903 | gl_End(ctx);
|
---|
2904 | break;
|
---|
2905 | case GL_LINE:
|
---|
2906 | for (v=v1,j=j1;j<=j2;j++,v+=dv) {
|
---|
2907 | gl_Begin( ctx, GL_LINE_STRIP );
|
---|
2908 | for (u=u1,i=i1;i<=i2;i++,u+=du) {
|
---|
2909 | eval_coord2f( ctx, u, v );
|
---|
2910 | }
|
---|
2911 | gl_End(ctx);
|
---|
2912 | }
|
---|
2913 | for (u=u1,i=i1;i<=i2;i++,u+=du) {
|
---|
2914 | gl_Begin( ctx, GL_LINE_STRIP );
|
---|
2915 | for (v=v1,j=j1;j<=j2;j++,v+=dv) {
|
---|
2916 | eval_coord2f( ctx, u, v );
|
---|
2917 | }
|
---|
2918 | gl_End(ctx);
|
---|
2919 | }
|
---|
2920 | break;
|
---|
2921 | case GL_FILL:
|
---|
2922 | for (v=v1,j=j1;j<j2;j++,v+=dv) {
|
---|
2923 | /* NOTE: a quad strip can't be used because the four */
|
---|
2924 | /* can't be guaranteed to be coplanar! */
|
---|
2925 | gl_Begin( ctx, GL_TRIANGLE_STRIP );
|
---|
2926 | for (u=u1,i=i1;i<=i2;i++,u+=du) {
|
---|
2927 | eval_coord2f( ctx, u, v );
|
---|
2928 | eval_coord2f( ctx, u, v+dv );
|
---|
2929 | }
|
---|
2930 | gl_End(ctx);
|
---|
2931 | }
|
---|
2932 | break;
|
---|
2933 | default:
|
---|
2934 | gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
|
---|
2935 | return;
|
---|
2936 | }
|
---|
2937 | }
|
---|