blob: 9a5bbc7c64d9a0eefcd76beca6d751326cf9cbaf [file] [log] [blame]
Brian Paulc893a012000-10-28 20:41:13 +00001/* $Id: eval.c,v 1.12 2000/10/28 20:41:14 brianp Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paulc893a012000-10-28 20:41:13 +00005 * Version: 3.5
jtgafb833d1999-08-19 00:55:39 +00006 *
Brian Paulc7a5dbe2000-01-13 00:30:41 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
jtgafb833d1999-08-19 00:55:39 +00008 *
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
jtgafb833d1999-08-19 00:55:39 +000028/*
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
Brian Paulfbd8f211999-11-11 01:22:25 +000044#include "glheader.h"
Brian Paulc893a012000-10-28 20:41:13 +000045#include "colormac.h"
jtgafb833d1999-08-19 00:55:39 +000046#include "context.h"
47#include "eval.h"
48#include "macros.h"
Brian Paulfbd8f211999-11-11 01:22:25 +000049#include "mem.h"
jtgafb833d1999-08-19 00:55:39 +000050#include "mmath.h"
51#include "types.h"
52#include "vbcull.h"
53#include "vbfill.h"
54#include "vbxform.h"
jtgafb833d1999-08-19 00:55:39 +000055#endif
56
57
58static GLfloat inv_tab[MAX_EVAL_ORDER];
59
60/*
61 * Do one-time initialization for evaluators.
62 */
63void 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
110static void
111horner_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
155static void
156horner_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
237static void
238de_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.
Brian Paulfbd8f211999-11-11 01:22:25 +0000527 * See table 5.1 in the OpenGL 1.2 spec.
jtgafb833d1999-08-19 00:55:39 +0000528 */
Brian Paulfbd8f211999-11-11 01:22:25 +0000529GLuint _mesa_evaluator_components( GLenum target )
jtgafb833d1999-08-19 00:55:39 +0000530{
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 */
Brian Paulfbd8f211999-11-11 01:22:25 +0000567GLfloat *gl_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
jtgafb833d1999-08-19 00:55:39 +0000568 const GLfloat *points )
569{
570 GLfloat *buffer, *p;
Brian Paulfbd8f211999-11-11 01:22:25 +0000571 GLint i, k, size = _mesa_evaluator_components(target);
jtgafb833d1999-08-19 00:55:39 +0000572
573 if (!points || size==0) {
574 return NULL;
575 }
576
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000577 buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000578
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 */
Brian Paulfbd8f211999-11-11 01:22:25 +0000592GLfloat *gl_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
593 const GLdouble *points )
jtgafb833d1999-08-19 00:55:39 +0000594{
595 GLfloat *buffer, *p;
Brian Paulfbd8f211999-11-11 01:22:25 +0000596 GLint i, k, size = _mesa_evaluator_components(target);
jtgafb833d1999-08-19 00:55:39 +0000597
598 if (!points || size==0) {
599 return NULL;
600 }
601
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000602 buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000603
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 */
624GLfloat *gl_copy_map_points2f( GLenum target,
Brian Paulfbd8f211999-11-11 01:22:25 +0000625 GLint ustride, GLint uorder,
626 GLint vstride, GLint vorder,
627 const GLfloat *points )
jtgafb833d1999-08-19 00:55:39 +0000628{
629 GLfloat *buffer, *p;
630 GLint i, j, k, size, dsize, hsize;
631 GLint uinc;
632
Brian Paulfbd8f211999-11-11 01:22:25 +0000633 size = _mesa_evaluator_components(target);
jtgafb833d1999-08-19 00:55:39 +0000634
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)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000646 buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000647 else
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000648 buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000649
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 */
667GLfloat *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
Brian Paulfbd8f211999-11-11 01:22:25 +0000676 size = _mesa_evaluator_components(target);
jtgafb833d1999-08-19 00:55:39 +0000677
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)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000689 buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000690 else
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000691 buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
jtgafb833d1999-08-19 00:55:39 +0000692
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
Brian Paulfbd8f211999-11-11 01:22:25 +0000706#if 00
jtgafb833d1999-08-19 00:55:39 +0000707/*
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 */
711void 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. */
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000785 FREE( data );
jtgafb833d1999-08-19 00:55:39 +0000786 }
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. */
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000797 FREE( data );
jtgafb833d1999-08-19 00:55:39 +0000798 }
799 }
800
801}
Brian Paulfbd8f211999-11-11 01:22:25 +0000802#endif
jtgafb833d1999-08-19 00:55:39 +0000803
804
805
806/**********************************************************************/
807/*** API entry points ***/
808/**********************************************************************/
809
810
811/*
Brian Paulfbd8f211999-11-11 01:22:25 +0000812 * This does the work of glMap1[fd].
jtgafb833d1999-08-19 00:55:39 +0000813 */
Brian Paulfbd8f211999-11-11 01:22:25 +0000814static void
815map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
816 GLint uorder, const GLvoid *points, GLenum type )
jtgafb833d1999-08-19 00:55:39 +0000817{
Brian Paulfbd8f211999-11-11 01:22:25 +0000818 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000819 GLint k;
Brian Paulfbd8f211999-11-11 01:22:25 +0000820 GLfloat *pnts;
jtgafb833d1999-08-19 00:55:39 +0000821
822 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap1");
823
Brian Paulfbd8f211999-11-11 01:22:25 +0000824 assert(type == GL_FLOAT || type == GL_DOUBLE);
825
826 if (u1 == u2) {
jtgafb833d1999-08-19 00:55:39 +0000827 gl_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" );
828 return;
829 }
Brian Paulfbd8f211999-11-11 01:22:25 +0000830 if (uorder < 1 || uorder > MAX_EVAL_ORDER) {
jtgafb833d1999-08-19 00:55:39 +0000831 gl_error( ctx, GL_INVALID_VALUE, "glMap1(order)" );
832 return;
833 }
Brian Paulfbd8f211999-11-11 01:22:25 +0000834 if (!points) {
835 gl_error( ctx, GL_INVALID_VALUE, "glMap1(points)" );
836 return;
837 }
jtgafb833d1999-08-19 00:55:39 +0000838
Brian Paulfbd8f211999-11-11 01:22:25 +0000839 k = _mesa_evaluator_components( target );
840 if (k == 0) {
jtgafb833d1999-08-19 00:55:39 +0000841 gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
842 }
843
Brian Paulfbd8f211999-11-11 01:22:25 +0000844 if (ustride < k) {
jtgafb833d1999-08-19 00:55:39 +0000845 gl_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" );
846 return;
847 }
848
Brian Paulfbd8f211999-11-11 01:22:25 +0000849 /* 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
jtgafb833d1999-08-19 00:55:39 +0000855 switch (target) {
856 case GL_MAP1_VERTEX_3:
Brian Paulfbd8f211999-11-11 01:22:25 +0000857 ctx->EvalMap.Map1Vertex3.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000858 ctx->EvalMap.Map1Vertex3.u1 = u1;
859 ctx->EvalMap.Map1Vertex3.u2 = u2;
860 ctx->EvalMap.Map1Vertex3.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000861 if (ctx->EvalMap.Map1Vertex3.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000862 FREE( ctx->EvalMap.Map1Vertex3.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000863 ctx->EvalMap.Map1Vertex3.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000864 break;
865 case GL_MAP1_VERTEX_4:
Brian Paulfbd8f211999-11-11 01:22:25 +0000866 ctx->EvalMap.Map1Vertex4.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000867 ctx->EvalMap.Map1Vertex4.u1 = u1;
868 ctx->EvalMap.Map1Vertex4.u2 = u2;
869 ctx->EvalMap.Map1Vertex4.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000870 if (ctx->EvalMap.Map1Vertex4.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000871 FREE( ctx->EvalMap.Map1Vertex4.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000872 ctx->EvalMap.Map1Vertex4.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000873 break;
874 case GL_MAP1_INDEX:
Brian Paulfbd8f211999-11-11 01:22:25 +0000875 ctx->EvalMap.Map1Index.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000876 ctx->EvalMap.Map1Index.u1 = u1;
877 ctx->EvalMap.Map1Index.u2 = u2;
878 ctx->EvalMap.Map1Index.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000879 if (ctx->EvalMap.Map1Index.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000880 FREE( ctx->EvalMap.Map1Index.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000881 ctx->EvalMap.Map1Index.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000882 break;
883 case GL_MAP1_COLOR_4:
Brian Paulfbd8f211999-11-11 01:22:25 +0000884 ctx->EvalMap.Map1Color4.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000885 ctx->EvalMap.Map1Color4.u1 = u1;
886 ctx->EvalMap.Map1Color4.u2 = u2;
887 ctx->EvalMap.Map1Color4.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000888 if (ctx->EvalMap.Map1Color4.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000889 FREE( ctx->EvalMap.Map1Color4.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000890 ctx->EvalMap.Map1Color4.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000891 break;
892 case GL_MAP1_NORMAL:
Brian Paulfbd8f211999-11-11 01:22:25 +0000893 ctx->EvalMap.Map1Normal.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000894 ctx->EvalMap.Map1Normal.u1 = u1;
895 ctx->EvalMap.Map1Normal.u2 = u2;
896 ctx->EvalMap.Map1Normal.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000897 if (ctx->EvalMap.Map1Normal.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000898 FREE( ctx->EvalMap.Map1Normal.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000899 ctx->EvalMap.Map1Normal.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000900 break;
901 case GL_MAP1_TEXTURE_COORD_1:
Brian Paulfbd8f211999-11-11 01:22:25 +0000902 ctx->EvalMap.Map1Texture1.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000903 ctx->EvalMap.Map1Texture1.u1 = u1;
904 ctx->EvalMap.Map1Texture1.u2 = u2;
905 ctx->EvalMap.Map1Texture1.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000906 if (ctx->EvalMap.Map1Texture1.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000907 FREE( ctx->EvalMap.Map1Texture1.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000908 ctx->EvalMap.Map1Texture1.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000909 break;
910 case GL_MAP1_TEXTURE_COORD_2:
Brian Paulfbd8f211999-11-11 01:22:25 +0000911 ctx->EvalMap.Map1Texture2.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000912 ctx->EvalMap.Map1Texture2.u1 = u1;
913 ctx->EvalMap.Map1Texture2.u2 = u2;
914 ctx->EvalMap.Map1Texture2.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000915 if (ctx->EvalMap.Map1Texture2.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000916 FREE( ctx->EvalMap.Map1Texture2.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000917 ctx->EvalMap.Map1Texture2.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000918 break;
919 case GL_MAP1_TEXTURE_COORD_3:
Brian Paulfbd8f211999-11-11 01:22:25 +0000920 ctx->EvalMap.Map1Texture3.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000921 ctx->EvalMap.Map1Texture3.u1 = u1;
922 ctx->EvalMap.Map1Texture3.u2 = u2;
923 ctx->EvalMap.Map1Texture3.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000924 if (ctx->EvalMap.Map1Texture3.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000925 FREE( ctx->EvalMap.Map1Texture3.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000926 ctx->EvalMap.Map1Texture3.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000927 break;
928 case GL_MAP1_TEXTURE_COORD_4:
Brian Paulfbd8f211999-11-11 01:22:25 +0000929 ctx->EvalMap.Map1Texture4.Order = uorder;
jtgafb833d1999-08-19 00:55:39 +0000930 ctx->EvalMap.Map1Texture4.u1 = u1;
931 ctx->EvalMap.Map1Texture4.u2 = u2;
932 ctx->EvalMap.Map1Texture4.du = 1.0 / (u2 - u1);
Brian Paulfbd8f211999-11-11 01:22:25 +0000933 if (ctx->EvalMap.Map1Texture4.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +0000934 FREE( ctx->EvalMap.Map1Texture4.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +0000935 ctx->EvalMap.Map1Texture4.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +0000936 break;
937 default:
938 gl_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
939 }
940}
941
942
943
Brian Paulfbd8f211999-11-11 01:22:25 +0000944void
945_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
946 GLint order, const GLfloat *points )
jtgafb833d1999-08-19 00:55:39 +0000947{
Brian Paulfbd8f211999-11-11 01:22:25 +0000948 map1(target, u1, u2, stride, order, points, GL_FLOAT);
949}
950
951
952void
953_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
954 GLint order, const GLdouble *points )
955{
956 map1(target, u1, u2, stride, order, points, GL_DOUBLE);
957}
958
959
960static void
961map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
962 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
963 const GLvoid *points, GLenum type )
964{
965 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +0000966 GLint k;
Brian Paulfbd8f211999-11-11 01:22:25 +0000967 GLfloat *pnts;
jtgafb833d1999-08-19 00:55:39 +0000968
969 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMap2");
970
971 if (u1==u2) {
972 gl_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" );
973 return;
974 }
975
976 if (v1==v2) {
977 gl_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" );
978 return;
979 }
980
981 if (uorder<1 || uorder>MAX_EVAL_ORDER) {
982 gl_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" );
983 return;
984 }
985
986 if (vorder<1 || vorder>MAX_EVAL_ORDER) {
987 gl_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" );
988 return;
989 }
990
Brian Paulfbd8f211999-11-11 01:22:25 +0000991 k = _mesa_evaluator_components( target );
jtgafb833d1999-08-19 00:55:39 +0000992 if (k==0) {
993 gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
994 }
995
996 if (ustride < k) {
997 gl_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" );
998 return;
999 }
1000 if (vstride < k) {
1001 gl_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" );
1002 return;
1003 }
1004
Brian Paulfbd8f211999-11-11 01:22:25 +00001005 /* make copy of the control points */
1006 if (type == GL_FLOAT)
1007 pnts = gl_copy_map_points2f(target, ustride, uorder,
1008 vstride, vorder, (GLfloat*) points);
1009 else
1010 pnts = gl_copy_map_points2d(target, ustride, uorder,
1011 vstride, vorder, (GLdouble*) points);
1012
jtgafb833d1999-08-19 00:55:39 +00001013 switch (target) {
1014 case GL_MAP2_VERTEX_3:
1015 ctx->EvalMap.Map2Vertex3.Uorder = uorder;
1016 ctx->EvalMap.Map2Vertex3.u1 = u1;
1017 ctx->EvalMap.Map2Vertex3.u2 = u2;
1018 ctx->EvalMap.Map2Vertex3.du = 1.0 / (u2 - u1);
1019 ctx->EvalMap.Map2Vertex3.Vorder = vorder;
1020 ctx->EvalMap.Map2Vertex3.v1 = v1;
1021 ctx->EvalMap.Map2Vertex3.v2 = v2;
1022 ctx->EvalMap.Map2Vertex3.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001023 if (ctx->EvalMap.Map2Vertex3.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001024 FREE( ctx->EvalMap.Map2Vertex3.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001025 ctx->EvalMap.Map2Vertex3.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001026 break;
1027 case GL_MAP2_VERTEX_4:
1028 ctx->EvalMap.Map2Vertex4.Uorder = uorder;
1029 ctx->EvalMap.Map2Vertex4.u1 = u1;
1030 ctx->EvalMap.Map2Vertex4.u2 = u2;
1031 ctx->EvalMap.Map2Vertex4.du = 1.0 / (u2 - u1);
1032 ctx->EvalMap.Map2Vertex4.Vorder = vorder;
1033 ctx->EvalMap.Map2Vertex4.v1 = v1;
1034 ctx->EvalMap.Map2Vertex4.v2 = v2;
1035 ctx->EvalMap.Map2Vertex4.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001036 if (ctx->EvalMap.Map2Vertex4.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001037 FREE( ctx->EvalMap.Map2Vertex4.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001038 ctx->EvalMap.Map2Vertex4.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001039 break;
1040 case GL_MAP2_INDEX:
1041 ctx->EvalMap.Map2Index.Uorder = uorder;
1042 ctx->EvalMap.Map2Index.u1 = u1;
1043 ctx->EvalMap.Map2Index.u2 = u2;
1044 ctx->EvalMap.Map2Index.du = 1.0 / (u2 - u1);
1045 ctx->EvalMap.Map2Index.Vorder = vorder;
1046 ctx->EvalMap.Map2Index.v1 = v1;
1047 ctx->EvalMap.Map2Index.v2 = v2;
1048 ctx->EvalMap.Map2Index.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001049 if (ctx->EvalMap.Map2Index.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001050 FREE( ctx->EvalMap.Map2Index.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001051 ctx->EvalMap.Map2Index.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001052 break;
1053 case GL_MAP2_COLOR_4:
1054 ctx->EvalMap.Map2Color4.Uorder = uorder;
1055 ctx->EvalMap.Map2Color4.u1 = u1;
1056 ctx->EvalMap.Map2Color4.u2 = u2;
1057 ctx->EvalMap.Map2Color4.du = 1.0 / (u2 - u1);
1058 ctx->EvalMap.Map2Color4.Vorder = vorder;
1059 ctx->EvalMap.Map2Color4.v1 = v1;
1060 ctx->EvalMap.Map2Color4.v2 = v2;
1061 ctx->EvalMap.Map2Color4.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001062 if (ctx->EvalMap.Map2Color4.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001063 FREE( ctx->EvalMap.Map2Color4.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001064 ctx->EvalMap.Map2Color4.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001065 break;
1066 case GL_MAP2_NORMAL:
1067 ctx->EvalMap.Map2Normal.Uorder = uorder;
1068 ctx->EvalMap.Map2Normal.u1 = u1;
1069 ctx->EvalMap.Map2Normal.u2 = u2;
1070 ctx->EvalMap.Map2Normal.du = 1.0 / (u2 - u1);
1071 ctx->EvalMap.Map2Normal.Vorder = vorder;
1072 ctx->EvalMap.Map2Normal.v1 = v1;
1073 ctx->EvalMap.Map2Normal.v2 = v2;
1074 ctx->EvalMap.Map2Normal.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001075 if (ctx->EvalMap.Map2Normal.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001076 FREE( ctx->EvalMap.Map2Normal.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001077 ctx->EvalMap.Map2Normal.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001078 break;
1079 case GL_MAP2_TEXTURE_COORD_1:
1080 ctx->EvalMap.Map2Texture1.Uorder = uorder;
1081 ctx->EvalMap.Map2Texture1.u1 = u1;
1082 ctx->EvalMap.Map2Texture1.u2 = u2;
1083 ctx->EvalMap.Map2Texture1.du = 1.0 / (u2 - u1);
1084 ctx->EvalMap.Map2Texture1.Vorder = vorder;
1085 ctx->EvalMap.Map2Texture1.v1 = v1;
1086 ctx->EvalMap.Map2Texture1.v2 = v2;
1087 ctx->EvalMap.Map2Texture1.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001088 if (ctx->EvalMap.Map2Texture1.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001089 FREE( ctx->EvalMap.Map2Texture1.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001090 ctx->EvalMap.Map2Texture1.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001091 break;
1092 case GL_MAP2_TEXTURE_COORD_2:
1093 ctx->EvalMap.Map2Texture2.Uorder = uorder;
1094 ctx->EvalMap.Map2Texture2.u1 = u1;
1095 ctx->EvalMap.Map2Texture2.u2 = u2;
1096 ctx->EvalMap.Map2Texture2.du = 1.0 / (u2 - u1);
1097 ctx->EvalMap.Map2Texture2.Vorder = vorder;
1098 ctx->EvalMap.Map2Texture2.v1 = v1;
1099 ctx->EvalMap.Map2Texture2.v2 = v2;
1100 ctx->EvalMap.Map2Texture2.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001101 if (ctx->EvalMap.Map2Texture2.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001102 FREE( ctx->EvalMap.Map2Texture2.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001103 ctx->EvalMap.Map2Texture2.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001104 break;
1105 case GL_MAP2_TEXTURE_COORD_3:
1106 ctx->EvalMap.Map2Texture3.Uorder = uorder;
1107 ctx->EvalMap.Map2Texture3.u1 = u1;
1108 ctx->EvalMap.Map2Texture3.u2 = u2;
1109 ctx->EvalMap.Map2Texture3.du = 1.0 / (u2 - u1);
1110 ctx->EvalMap.Map2Texture3.Vorder = vorder;
1111 ctx->EvalMap.Map2Texture3.v1 = v1;
1112 ctx->EvalMap.Map2Texture3.v2 = v2;
1113 ctx->EvalMap.Map2Texture3.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001114 if (ctx->EvalMap.Map2Texture3.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001115 FREE( ctx->EvalMap.Map2Texture3.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001116 ctx->EvalMap.Map2Texture3.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001117 break;
1118 case GL_MAP2_TEXTURE_COORD_4:
1119 ctx->EvalMap.Map2Texture4.Uorder = uorder;
1120 ctx->EvalMap.Map2Texture4.u1 = u1;
1121 ctx->EvalMap.Map2Texture4.u2 = u2;
1122 ctx->EvalMap.Map2Texture4.du = 1.0 / (u2 - u1);
1123 ctx->EvalMap.Map2Texture4.Vorder = vorder;
1124 ctx->EvalMap.Map2Texture4.v1 = v1;
1125 ctx->EvalMap.Map2Texture4.v2 = v2;
1126 ctx->EvalMap.Map2Texture4.dv = 1.0 / (v2 - v1);
Brian Paulfbd8f211999-11-11 01:22:25 +00001127 if (ctx->EvalMap.Map2Texture4.Points)
Brian Paulbd5cdaf1999-10-13 18:42:49 +00001128 FREE( ctx->EvalMap.Map2Texture4.Points );
Brian Paulfbd8f211999-11-11 01:22:25 +00001129 ctx->EvalMap.Map2Texture4.Points = pnts;
jtgafb833d1999-08-19 00:55:39 +00001130 break;
1131 default:
1132 gl_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
1133 }
1134}
1135
1136
Brian Paulfbd8f211999-11-11 01:22:25 +00001137void
1138_mesa_Map2f( GLenum target,
1139 GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
1140 GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
1141 const GLfloat *points)
jtgafb833d1999-08-19 00:55:39 +00001142{
Brian Paulfbd8f211999-11-11 01:22:25 +00001143 map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
1144 points, GL_FLOAT);
1145}
1146
1147
1148void
1149_mesa_Map2d( GLenum target,
1150 GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
1151 GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
1152 const GLdouble *points )
1153{
1154 map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
1155 points, GL_DOUBLE);
1156}
1157
1158
1159
1160void
1161_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
1162{
1163 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00001164 GLint i, n;
1165 GLfloat *data;
1166
1167 switch (query) {
1168 case GL_COEFF:
1169 switch (target) {
1170 case GL_MAP1_COLOR_4:
1171 data = ctx->EvalMap.Map1Color4.Points;
1172 n = ctx->EvalMap.Map1Color4.Order * 4;
1173 break;
1174 case GL_MAP1_INDEX:
1175 data = ctx->EvalMap.Map1Index.Points;
1176 n = ctx->EvalMap.Map1Index.Order;
1177 break;
1178 case GL_MAP1_NORMAL:
1179 data = ctx->EvalMap.Map1Normal.Points;
1180 n = ctx->EvalMap.Map1Normal.Order * 3;
1181 break;
1182 case GL_MAP1_TEXTURE_COORD_1:
1183 data = ctx->EvalMap.Map1Texture1.Points;
1184 n = ctx->EvalMap.Map1Texture1.Order * 1;
1185 break;
1186 case GL_MAP1_TEXTURE_COORD_2:
1187 data = ctx->EvalMap.Map1Texture2.Points;
1188 n = ctx->EvalMap.Map1Texture2.Order * 2;
1189 break;
1190 case GL_MAP1_TEXTURE_COORD_3:
1191 data = ctx->EvalMap.Map1Texture3.Points;
1192 n = ctx->EvalMap.Map1Texture3.Order * 3;
1193 break;
1194 case GL_MAP1_TEXTURE_COORD_4:
1195 data = ctx->EvalMap.Map1Texture4.Points;
1196 n = ctx->EvalMap.Map1Texture4.Order * 4;
1197 break;
1198 case GL_MAP1_VERTEX_3:
1199 data = ctx->EvalMap.Map1Vertex3.Points;
1200 n = ctx->EvalMap.Map1Vertex3.Order * 3;
1201 break;
1202 case GL_MAP1_VERTEX_4:
1203 data = ctx->EvalMap.Map1Vertex4.Points;
1204 n = ctx->EvalMap.Map1Vertex4.Order * 4;
1205 break;
1206 case GL_MAP2_COLOR_4:
1207 data = ctx->EvalMap.Map2Color4.Points;
1208 n = ctx->EvalMap.Map2Color4.Uorder
1209 * ctx->EvalMap.Map2Color4.Vorder * 4;
1210 break;
1211 case GL_MAP2_INDEX:
1212 data = ctx->EvalMap.Map2Index.Points;
1213 n = ctx->EvalMap.Map2Index.Uorder
1214 * ctx->EvalMap.Map2Index.Vorder;
1215 break;
1216 case GL_MAP2_NORMAL:
1217 data = ctx->EvalMap.Map2Normal.Points;
1218 n = ctx->EvalMap.Map2Normal.Uorder
1219 * ctx->EvalMap.Map2Normal.Vorder * 3;
1220 break;
1221 case GL_MAP2_TEXTURE_COORD_1:
1222 data = ctx->EvalMap.Map2Texture1.Points;
1223 n = ctx->EvalMap.Map2Texture1.Uorder
1224 * ctx->EvalMap.Map2Texture1.Vorder * 1;
1225 break;
1226 case GL_MAP2_TEXTURE_COORD_2:
1227 data = ctx->EvalMap.Map2Texture2.Points;
1228 n = ctx->EvalMap.Map2Texture2.Uorder
1229 * ctx->EvalMap.Map2Texture2.Vorder * 2;
1230 break;
1231 case GL_MAP2_TEXTURE_COORD_3:
1232 data = ctx->EvalMap.Map2Texture3.Points;
1233 n = ctx->EvalMap.Map2Texture3.Uorder
1234 * ctx->EvalMap.Map2Texture3.Vorder * 3;
1235 break;
1236 case GL_MAP2_TEXTURE_COORD_4:
1237 data = ctx->EvalMap.Map2Texture4.Points;
1238 n = ctx->EvalMap.Map2Texture4.Uorder
1239 * ctx->EvalMap.Map2Texture4.Vorder * 4;
1240 break;
1241 case GL_MAP2_VERTEX_3:
1242 data = ctx->EvalMap.Map2Vertex3.Points;
1243 n = ctx->EvalMap.Map2Vertex3.Uorder
1244 * ctx->EvalMap.Map2Vertex3.Vorder * 3;
1245 break;
1246 case GL_MAP2_VERTEX_4:
1247 data = ctx->EvalMap.Map2Vertex4.Points;
1248 n = ctx->EvalMap.Map2Vertex4.Uorder
1249 * ctx->EvalMap.Map2Vertex4.Vorder * 4;
1250 break;
1251 default:
1252 gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
1253 return;
1254 }
1255 if (data) {
1256 for (i=0;i<n;i++) {
1257 v[i] = data[i];
1258 }
1259 }
1260 break;
1261 case GL_ORDER:
1262 switch (target) {
1263 case GL_MAP1_COLOR_4:
1264 *v = ctx->EvalMap.Map1Color4.Order;
1265 break;
1266 case GL_MAP1_INDEX:
1267 *v = ctx->EvalMap.Map1Index.Order;
1268 break;
1269 case GL_MAP1_NORMAL:
1270 *v = ctx->EvalMap.Map1Normal.Order;
1271 break;
1272 case GL_MAP1_TEXTURE_COORD_1:
1273 *v = ctx->EvalMap.Map1Texture1.Order;
1274 break;
1275 case GL_MAP1_TEXTURE_COORD_2:
1276 *v = ctx->EvalMap.Map1Texture2.Order;
1277 break;
1278 case GL_MAP1_TEXTURE_COORD_3:
1279 *v = ctx->EvalMap.Map1Texture3.Order;
1280 break;
1281 case GL_MAP1_TEXTURE_COORD_4:
1282 *v = ctx->EvalMap.Map1Texture4.Order;
1283 break;
1284 case GL_MAP1_VERTEX_3:
1285 *v = ctx->EvalMap.Map1Vertex3.Order;
1286 break;
1287 case GL_MAP1_VERTEX_4:
1288 *v = ctx->EvalMap.Map1Vertex4.Order;
1289 break;
1290 case GL_MAP2_COLOR_4:
1291 v[0] = ctx->EvalMap.Map2Color4.Uorder;
1292 v[1] = ctx->EvalMap.Map2Color4.Vorder;
1293 break;
1294 case GL_MAP2_INDEX:
1295 v[0] = ctx->EvalMap.Map2Index.Uorder;
1296 v[1] = ctx->EvalMap.Map2Index.Vorder;
1297 break;
1298 case GL_MAP2_NORMAL:
1299 v[0] = ctx->EvalMap.Map2Normal.Uorder;
1300 v[1] = ctx->EvalMap.Map2Normal.Vorder;
1301 break;
1302 case GL_MAP2_TEXTURE_COORD_1:
1303 v[0] = ctx->EvalMap.Map2Texture1.Uorder;
1304 v[1] = ctx->EvalMap.Map2Texture1.Vorder;
1305 break;
1306 case GL_MAP2_TEXTURE_COORD_2:
1307 v[0] = ctx->EvalMap.Map2Texture2.Uorder;
1308 v[1] = ctx->EvalMap.Map2Texture2.Vorder;
1309 break;
1310 case GL_MAP2_TEXTURE_COORD_3:
1311 v[0] = ctx->EvalMap.Map2Texture3.Uorder;
1312 v[1] = ctx->EvalMap.Map2Texture3.Vorder;
1313 break;
1314 case GL_MAP2_TEXTURE_COORD_4:
1315 v[0] = ctx->EvalMap.Map2Texture4.Uorder;
1316 v[1] = ctx->EvalMap.Map2Texture4.Vorder;
1317 break;
1318 case GL_MAP2_VERTEX_3:
1319 v[0] = ctx->EvalMap.Map2Vertex3.Uorder;
1320 v[1] = ctx->EvalMap.Map2Vertex3.Vorder;
1321 break;
1322 case GL_MAP2_VERTEX_4:
1323 v[0] = ctx->EvalMap.Map2Vertex4.Uorder;
1324 v[1] = ctx->EvalMap.Map2Vertex4.Vorder;
1325 break;
1326 default:
1327 gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
1328 return;
1329 }
1330 break;
1331 case GL_DOMAIN:
1332 switch (target) {
1333 case GL_MAP1_COLOR_4:
1334 v[0] = ctx->EvalMap.Map1Color4.u1;
1335 v[1] = ctx->EvalMap.Map1Color4.u2;
1336 break;
1337 case GL_MAP1_INDEX:
1338 v[0] = ctx->EvalMap.Map1Index.u1;
1339 v[1] = ctx->EvalMap.Map1Index.u2;
1340 break;
1341 case GL_MAP1_NORMAL:
1342 v[0] = ctx->EvalMap.Map1Normal.u1;
1343 v[1] = ctx->EvalMap.Map1Normal.u2;
1344 break;
1345 case GL_MAP1_TEXTURE_COORD_1:
1346 v[0] = ctx->EvalMap.Map1Texture1.u1;
1347 v[1] = ctx->EvalMap.Map1Texture1.u2;
1348 break;
1349 case GL_MAP1_TEXTURE_COORD_2:
1350 v[0] = ctx->EvalMap.Map1Texture2.u1;
1351 v[1] = ctx->EvalMap.Map1Texture2.u2;
1352 break;
1353 case GL_MAP1_TEXTURE_COORD_3:
1354 v[0] = ctx->EvalMap.Map1Texture3.u1;
1355 v[1] = ctx->EvalMap.Map1Texture3.u2;
1356 break;
1357 case GL_MAP1_TEXTURE_COORD_4:
1358 v[0] = ctx->EvalMap.Map1Texture4.u1;
1359 v[1] = ctx->EvalMap.Map1Texture4.u2;
1360 break;
1361 case GL_MAP1_VERTEX_3:
1362 v[0] = ctx->EvalMap.Map1Vertex3.u1;
1363 v[1] = ctx->EvalMap.Map1Vertex3.u2;
1364 break;
1365 case GL_MAP1_VERTEX_4:
1366 v[0] = ctx->EvalMap.Map1Vertex4.u1;
1367 v[1] = ctx->EvalMap.Map1Vertex4.u2;
1368 break;
1369 case GL_MAP2_COLOR_4:
1370 v[0] = ctx->EvalMap.Map2Color4.u1;
1371 v[1] = ctx->EvalMap.Map2Color4.u2;
1372 v[2] = ctx->EvalMap.Map2Color4.v1;
1373 v[3] = ctx->EvalMap.Map2Color4.v2;
1374 break;
1375 case GL_MAP2_INDEX:
1376 v[0] = ctx->EvalMap.Map2Index.u1;
1377 v[1] = ctx->EvalMap.Map2Index.u2;
1378 v[2] = ctx->EvalMap.Map2Index.v1;
1379 v[3] = ctx->EvalMap.Map2Index.v2;
1380 break;
1381 case GL_MAP2_NORMAL:
1382 v[0] = ctx->EvalMap.Map2Normal.u1;
1383 v[1] = ctx->EvalMap.Map2Normal.u2;
1384 v[2] = ctx->EvalMap.Map2Normal.v1;
1385 v[3] = ctx->EvalMap.Map2Normal.v2;
1386 break;
1387 case GL_MAP2_TEXTURE_COORD_1:
1388 v[0] = ctx->EvalMap.Map2Texture1.u1;
1389 v[1] = ctx->EvalMap.Map2Texture1.u2;
1390 v[2] = ctx->EvalMap.Map2Texture1.v1;
1391 v[3] = ctx->EvalMap.Map2Texture1.v2;
1392 break;
1393 case GL_MAP2_TEXTURE_COORD_2:
1394 v[0] = ctx->EvalMap.Map2Texture2.u1;
1395 v[1] = ctx->EvalMap.Map2Texture2.u2;
1396 v[2] = ctx->EvalMap.Map2Texture2.v1;
1397 v[3] = ctx->EvalMap.Map2Texture2.v2;
1398 break;
1399 case GL_MAP2_TEXTURE_COORD_3:
1400 v[0] = ctx->EvalMap.Map2Texture3.u1;
1401 v[1] = ctx->EvalMap.Map2Texture3.u2;
1402 v[2] = ctx->EvalMap.Map2Texture3.v1;
1403 v[3] = ctx->EvalMap.Map2Texture3.v2;
1404 break;
1405 case GL_MAP2_TEXTURE_COORD_4:
1406 v[0] = ctx->EvalMap.Map2Texture4.u1;
1407 v[1] = ctx->EvalMap.Map2Texture4.u2;
1408 v[2] = ctx->EvalMap.Map2Texture4.v1;
1409 v[3] = ctx->EvalMap.Map2Texture4.v2;
1410 break;
1411 case GL_MAP2_VERTEX_3:
1412 v[0] = ctx->EvalMap.Map2Vertex3.u1;
1413 v[1] = ctx->EvalMap.Map2Vertex3.u2;
1414 v[2] = ctx->EvalMap.Map2Vertex3.v1;
1415 v[3] = ctx->EvalMap.Map2Vertex3.v2;
1416 break;
1417 case GL_MAP2_VERTEX_4:
1418 v[0] = ctx->EvalMap.Map2Vertex4.u1;
1419 v[1] = ctx->EvalMap.Map2Vertex4.u2;
1420 v[2] = ctx->EvalMap.Map2Vertex4.v1;
1421 v[3] = ctx->EvalMap.Map2Vertex4.v2;
1422 break;
1423 default:
1424 gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
1425 }
1426 break;
1427 default:
1428 gl_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" );
1429 }
1430}
1431
1432
Brian Paulfbd8f211999-11-11 01:22:25 +00001433void
1434_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
jtgafb833d1999-08-19 00:55:39 +00001435{
Brian Paulfbd8f211999-11-11 01:22:25 +00001436 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00001437 GLint i, n;
1438 GLfloat *data;
1439
1440 switch (query) {
1441 case GL_COEFF:
1442 switch (target) {
1443 case GL_MAP1_COLOR_4:
1444 data = ctx->EvalMap.Map1Color4.Points;
1445 n = ctx->EvalMap.Map1Color4.Order * 4;
1446 break;
1447 case GL_MAP1_INDEX:
1448 data = ctx->EvalMap.Map1Index.Points;
1449 n = ctx->EvalMap.Map1Index.Order;
1450 break;
1451 case GL_MAP1_NORMAL:
1452 data = ctx->EvalMap.Map1Normal.Points;
1453 n = ctx->EvalMap.Map1Normal.Order * 3;
1454 break;
1455 case GL_MAP1_TEXTURE_COORD_1:
1456 data = ctx->EvalMap.Map1Texture1.Points;
1457 n = ctx->EvalMap.Map1Texture1.Order * 1;
1458 break;
1459 case GL_MAP1_TEXTURE_COORD_2:
1460 data = ctx->EvalMap.Map1Texture2.Points;
1461 n = ctx->EvalMap.Map1Texture2.Order * 2;
1462 break;
1463 case GL_MAP1_TEXTURE_COORD_3:
1464 data = ctx->EvalMap.Map1Texture3.Points;
1465 n = ctx->EvalMap.Map1Texture3.Order * 3;
1466 break;
1467 case GL_MAP1_TEXTURE_COORD_4:
1468 data = ctx->EvalMap.Map1Texture4.Points;
1469 n = ctx->EvalMap.Map1Texture4.Order * 4;
1470 break;
1471 case GL_MAP1_VERTEX_3:
1472 data = ctx->EvalMap.Map1Vertex3.Points;
1473 n = ctx->EvalMap.Map1Vertex3.Order * 3;
1474 break;
1475 case GL_MAP1_VERTEX_4:
1476 data = ctx->EvalMap.Map1Vertex4.Points;
1477 n = ctx->EvalMap.Map1Vertex4.Order * 4;
1478 break;
1479 case GL_MAP2_COLOR_4:
1480 data = ctx->EvalMap.Map2Color4.Points;
1481 n = ctx->EvalMap.Map2Color4.Uorder
1482 * ctx->EvalMap.Map2Color4.Vorder * 4;
1483 break;
1484 case GL_MAP2_INDEX:
1485 data = ctx->EvalMap.Map2Index.Points;
1486 n = ctx->EvalMap.Map2Index.Uorder
1487 * ctx->EvalMap.Map2Index.Vorder;
1488 break;
1489 case GL_MAP2_NORMAL:
1490 data = ctx->EvalMap.Map2Normal.Points;
1491 n = ctx->EvalMap.Map2Normal.Uorder
1492 * ctx->EvalMap.Map2Normal.Vorder * 3;
1493 break;
1494 case GL_MAP2_TEXTURE_COORD_1:
1495 data = ctx->EvalMap.Map2Texture1.Points;
1496 n = ctx->EvalMap.Map2Texture1.Uorder
1497 * ctx->EvalMap.Map2Texture1.Vorder * 1;
1498 break;
1499 case GL_MAP2_TEXTURE_COORD_2:
1500 data = ctx->EvalMap.Map2Texture2.Points;
1501 n = ctx->EvalMap.Map2Texture2.Uorder
1502 * ctx->EvalMap.Map2Texture2.Vorder * 2;
1503 break;
1504 case GL_MAP2_TEXTURE_COORD_3:
1505 data = ctx->EvalMap.Map2Texture3.Points;
1506 n = ctx->EvalMap.Map2Texture3.Uorder
1507 * ctx->EvalMap.Map2Texture3.Vorder * 3;
1508 break;
1509 case GL_MAP2_TEXTURE_COORD_4:
1510 data = ctx->EvalMap.Map2Texture4.Points;
1511 n = ctx->EvalMap.Map2Texture4.Uorder
1512 * ctx->EvalMap.Map2Texture4.Vorder * 4;
1513 break;
1514 case GL_MAP2_VERTEX_3:
1515 data = ctx->EvalMap.Map2Vertex3.Points;
1516 n = ctx->EvalMap.Map2Vertex3.Uorder
1517 * ctx->EvalMap.Map2Vertex3.Vorder * 3;
1518 break;
1519 case GL_MAP2_VERTEX_4:
1520 data = ctx->EvalMap.Map2Vertex4.Points;
1521 n = ctx->EvalMap.Map2Vertex4.Uorder
1522 * ctx->EvalMap.Map2Vertex4.Vorder * 4;
1523 break;
1524 default:
1525 gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
1526 return;
1527 }
1528 if (data) {
1529 for (i=0;i<n;i++) {
1530 v[i] = data[i];
1531 }
1532 }
1533 break;
1534 case GL_ORDER:
1535 switch (target) {
1536 case GL_MAP1_COLOR_4:
1537 *v = ctx->EvalMap.Map1Color4.Order;
1538 break;
1539 case GL_MAP1_INDEX:
1540 *v = ctx->EvalMap.Map1Index.Order;
1541 break;
1542 case GL_MAP1_NORMAL:
1543 *v = ctx->EvalMap.Map1Normal.Order;
1544 break;
1545 case GL_MAP1_TEXTURE_COORD_1:
1546 *v = ctx->EvalMap.Map1Texture1.Order;
1547 break;
1548 case GL_MAP1_TEXTURE_COORD_2:
1549 *v = ctx->EvalMap.Map1Texture2.Order;
1550 break;
1551 case GL_MAP1_TEXTURE_COORD_3:
1552 *v = ctx->EvalMap.Map1Texture3.Order;
1553 break;
1554 case GL_MAP1_TEXTURE_COORD_4:
1555 *v = ctx->EvalMap.Map1Texture4.Order;
1556 break;
1557 case GL_MAP1_VERTEX_3:
1558 *v = ctx->EvalMap.Map1Vertex3.Order;
1559 break;
1560 case GL_MAP1_VERTEX_4:
1561 *v = ctx->EvalMap.Map1Vertex4.Order;
1562 break;
1563 case GL_MAP2_COLOR_4:
1564 v[0] = ctx->EvalMap.Map2Color4.Uorder;
1565 v[1] = ctx->EvalMap.Map2Color4.Vorder;
1566 break;
1567 case GL_MAP2_INDEX:
1568 v[0] = ctx->EvalMap.Map2Index.Uorder;
1569 v[1] = ctx->EvalMap.Map2Index.Vorder;
1570 break;
1571 case GL_MAP2_NORMAL:
1572 v[0] = ctx->EvalMap.Map2Normal.Uorder;
1573 v[1] = ctx->EvalMap.Map2Normal.Vorder;
1574 break;
1575 case GL_MAP2_TEXTURE_COORD_1:
1576 v[0] = ctx->EvalMap.Map2Texture1.Uorder;
1577 v[1] = ctx->EvalMap.Map2Texture1.Vorder;
1578 break;
1579 case GL_MAP2_TEXTURE_COORD_2:
1580 v[0] = ctx->EvalMap.Map2Texture2.Uorder;
1581 v[1] = ctx->EvalMap.Map2Texture2.Vorder;
1582 break;
1583 case GL_MAP2_TEXTURE_COORD_3:
1584 v[0] = ctx->EvalMap.Map2Texture3.Uorder;
1585 v[1] = ctx->EvalMap.Map2Texture3.Vorder;
1586 break;
1587 case GL_MAP2_TEXTURE_COORD_4:
1588 v[0] = ctx->EvalMap.Map2Texture4.Uorder;
1589 v[1] = ctx->EvalMap.Map2Texture4.Vorder;
1590 break;
1591 case GL_MAP2_VERTEX_3:
1592 v[0] = ctx->EvalMap.Map2Vertex3.Uorder;
1593 v[1] = ctx->EvalMap.Map2Vertex3.Vorder;
1594 break;
1595 case GL_MAP2_VERTEX_4:
1596 v[0] = ctx->EvalMap.Map2Vertex4.Uorder;
1597 v[1] = ctx->EvalMap.Map2Vertex4.Vorder;
1598 break;
1599 default:
1600 gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
1601 return;
1602 }
1603 break;
1604 case GL_DOMAIN:
1605 switch (target) {
1606 case GL_MAP1_COLOR_4:
1607 v[0] = ctx->EvalMap.Map1Color4.u1;
1608 v[1] = ctx->EvalMap.Map1Color4.u2;
1609 break;
1610 case GL_MAP1_INDEX:
1611 v[0] = ctx->EvalMap.Map1Index.u1;
1612 v[1] = ctx->EvalMap.Map1Index.u2;
1613 break;
1614 case GL_MAP1_NORMAL:
1615 v[0] = ctx->EvalMap.Map1Normal.u1;
1616 v[1] = ctx->EvalMap.Map1Normal.u2;
1617 break;
1618 case GL_MAP1_TEXTURE_COORD_1:
1619 v[0] = ctx->EvalMap.Map1Texture1.u1;
1620 v[1] = ctx->EvalMap.Map1Texture1.u2;
1621 break;
1622 case GL_MAP1_TEXTURE_COORD_2:
1623 v[0] = ctx->EvalMap.Map1Texture2.u1;
1624 v[1] = ctx->EvalMap.Map1Texture2.u2;
1625 break;
1626 case GL_MAP1_TEXTURE_COORD_3:
1627 v[0] = ctx->EvalMap.Map1Texture3.u1;
1628 v[1] = ctx->EvalMap.Map1Texture3.u2;
1629 break;
1630 case GL_MAP1_TEXTURE_COORD_4:
1631 v[0] = ctx->EvalMap.Map1Texture4.u1;
1632 v[1] = ctx->EvalMap.Map1Texture4.u2;
1633 break;
1634 case GL_MAP1_VERTEX_3:
1635 v[0] = ctx->EvalMap.Map1Vertex3.u1;
1636 v[1] = ctx->EvalMap.Map1Vertex3.u2;
1637 break;
1638 case GL_MAP1_VERTEX_4:
1639 v[0] = ctx->EvalMap.Map1Vertex4.u1;
1640 v[1] = ctx->EvalMap.Map1Vertex4.u2;
1641 break;
1642 case GL_MAP2_COLOR_4:
1643 v[0] = ctx->EvalMap.Map2Color4.u1;
1644 v[1] = ctx->EvalMap.Map2Color4.u2;
1645 v[2] = ctx->EvalMap.Map2Color4.v1;
1646 v[3] = ctx->EvalMap.Map2Color4.v2;
1647 break;
1648 case GL_MAP2_INDEX:
1649 v[0] = ctx->EvalMap.Map2Index.u1;
1650 v[1] = ctx->EvalMap.Map2Index.u2;
1651 v[2] = ctx->EvalMap.Map2Index.v1;
1652 v[3] = ctx->EvalMap.Map2Index.v2;
1653 break;
1654 case GL_MAP2_NORMAL:
1655 v[0] = ctx->EvalMap.Map2Normal.u1;
1656 v[1] = ctx->EvalMap.Map2Normal.u2;
1657 v[2] = ctx->EvalMap.Map2Normal.v1;
1658 v[3] = ctx->EvalMap.Map2Normal.v2;
1659 break;
1660 case GL_MAP2_TEXTURE_COORD_1:
1661 v[0] = ctx->EvalMap.Map2Texture1.u1;
1662 v[1] = ctx->EvalMap.Map2Texture1.u2;
1663 v[2] = ctx->EvalMap.Map2Texture1.v1;
1664 v[3] = ctx->EvalMap.Map2Texture1.v2;
1665 break;
1666 case GL_MAP2_TEXTURE_COORD_2:
1667 v[0] = ctx->EvalMap.Map2Texture2.u1;
1668 v[1] = ctx->EvalMap.Map2Texture2.u2;
1669 v[2] = ctx->EvalMap.Map2Texture2.v1;
1670 v[3] = ctx->EvalMap.Map2Texture2.v2;
1671 break;
1672 case GL_MAP2_TEXTURE_COORD_3:
1673 v[0] = ctx->EvalMap.Map2Texture3.u1;
1674 v[1] = ctx->EvalMap.Map2Texture3.u2;
1675 v[2] = ctx->EvalMap.Map2Texture3.v1;
1676 v[3] = ctx->EvalMap.Map2Texture3.v2;
1677 break;
1678 case GL_MAP2_TEXTURE_COORD_4:
1679 v[0] = ctx->EvalMap.Map2Texture4.u1;
1680 v[1] = ctx->EvalMap.Map2Texture4.u2;
1681 v[2] = ctx->EvalMap.Map2Texture4.v1;
1682 v[3] = ctx->EvalMap.Map2Texture4.v2;
1683 break;
1684 case GL_MAP2_VERTEX_3:
1685 v[0] = ctx->EvalMap.Map2Vertex3.u1;
1686 v[1] = ctx->EvalMap.Map2Vertex3.u2;
1687 v[2] = ctx->EvalMap.Map2Vertex3.v1;
1688 v[3] = ctx->EvalMap.Map2Vertex3.v2;
1689 break;
1690 case GL_MAP2_VERTEX_4:
1691 v[0] = ctx->EvalMap.Map2Vertex4.u1;
1692 v[1] = ctx->EvalMap.Map2Vertex4.u2;
1693 v[2] = ctx->EvalMap.Map2Vertex4.v1;
1694 v[3] = ctx->EvalMap.Map2Vertex4.v2;
1695 break;
1696 default:
1697 gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
1698 }
1699 break;
1700 default:
1701 gl_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" );
1702 }
1703}
1704
1705
Brian Paulfbd8f211999-11-11 01:22:25 +00001706void
1707_mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
jtgafb833d1999-08-19 00:55:39 +00001708{
Brian Paulfbd8f211999-11-11 01:22:25 +00001709 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00001710 GLuint i, n;
1711 GLfloat *data;
1712
1713 switch (query) {
1714 case GL_COEFF:
1715 switch (target) {
1716 case GL_MAP1_COLOR_4:
1717 data = ctx->EvalMap.Map1Color4.Points;
1718 n = ctx->EvalMap.Map1Color4.Order * 4;
1719 break;
1720 case GL_MAP1_INDEX:
1721 data = ctx->EvalMap.Map1Index.Points;
1722 n = ctx->EvalMap.Map1Index.Order;
1723 break;
1724 case GL_MAP1_NORMAL:
1725 data = ctx->EvalMap.Map1Normal.Points;
1726 n = ctx->EvalMap.Map1Normal.Order * 3;
1727 break;
1728 case GL_MAP1_TEXTURE_COORD_1:
1729 data = ctx->EvalMap.Map1Texture1.Points;
1730 n = ctx->EvalMap.Map1Texture1.Order * 1;
1731 break;
1732 case GL_MAP1_TEXTURE_COORD_2:
1733 data = ctx->EvalMap.Map1Texture2.Points;
1734 n = ctx->EvalMap.Map1Texture2.Order * 2;
1735 break;
1736 case GL_MAP1_TEXTURE_COORD_3:
1737 data = ctx->EvalMap.Map1Texture3.Points;
1738 n = ctx->EvalMap.Map1Texture3.Order * 3;
1739 break;
1740 case GL_MAP1_TEXTURE_COORD_4:
1741 data = ctx->EvalMap.Map1Texture4.Points;
1742 n = ctx->EvalMap.Map1Texture4.Order * 4;
1743 break;
1744 case GL_MAP1_VERTEX_3:
1745 data = ctx->EvalMap.Map1Vertex3.Points;
1746 n = ctx->EvalMap.Map1Vertex3.Order * 3;
1747 break;
1748 case GL_MAP1_VERTEX_4:
1749 data = ctx->EvalMap.Map1Vertex4.Points;
1750 n = ctx->EvalMap.Map1Vertex4.Order * 4;
1751 break;
1752 case GL_MAP2_COLOR_4:
1753 data = ctx->EvalMap.Map2Color4.Points;
1754 n = ctx->EvalMap.Map2Color4.Uorder
1755 * ctx->EvalMap.Map2Color4.Vorder * 4;
1756 break;
1757 case GL_MAP2_INDEX:
1758 data = ctx->EvalMap.Map2Index.Points;
1759 n = ctx->EvalMap.Map2Index.Uorder
1760 * ctx->EvalMap.Map2Index.Vorder;
1761 break;
1762 case GL_MAP2_NORMAL:
1763 data = ctx->EvalMap.Map2Normal.Points;
1764 n = ctx->EvalMap.Map2Normal.Uorder
1765 * ctx->EvalMap.Map2Normal.Vorder * 3;
1766 break;
1767 case GL_MAP2_TEXTURE_COORD_1:
1768 data = ctx->EvalMap.Map2Texture1.Points;
1769 n = ctx->EvalMap.Map2Texture1.Uorder
1770 * ctx->EvalMap.Map2Texture1.Vorder * 1;
1771 break;
1772 case GL_MAP2_TEXTURE_COORD_2:
1773 data = ctx->EvalMap.Map2Texture2.Points;
1774 n = ctx->EvalMap.Map2Texture2.Uorder
1775 * ctx->EvalMap.Map2Texture2.Vorder * 2;
1776 break;
1777 case GL_MAP2_TEXTURE_COORD_3:
1778 data = ctx->EvalMap.Map2Texture3.Points;
1779 n = ctx->EvalMap.Map2Texture3.Uorder
1780 * ctx->EvalMap.Map2Texture3.Vorder * 3;
1781 break;
1782 case GL_MAP2_TEXTURE_COORD_4:
1783 data = ctx->EvalMap.Map2Texture4.Points;
1784 n = ctx->EvalMap.Map2Texture4.Uorder
1785 * ctx->EvalMap.Map2Texture4.Vorder * 4;
1786 break;
1787 case GL_MAP2_VERTEX_3:
1788 data = ctx->EvalMap.Map2Vertex3.Points;
1789 n = ctx->EvalMap.Map2Vertex3.Uorder
1790 * ctx->EvalMap.Map2Vertex3.Vorder * 3;
1791 break;
1792 case GL_MAP2_VERTEX_4:
1793 data = ctx->EvalMap.Map2Vertex4.Points;
1794 n = ctx->EvalMap.Map2Vertex4.Uorder
1795 * ctx->EvalMap.Map2Vertex4.Vorder * 4;
1796 break;
1797 default:
1798 gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
1799 return;
1800 }
1801 if (data) {
1802 for (i=0;i<n;i++) {
1803 v[i] = ROUNDF(data[i]);
1804 }
1805 }
1806 break;
1807 case GL_ORDER:
1808 switch (target) {
1809 case GL_MAP1_COLOR_4:
1810 *v = ctx->EvalMap.Map1Color4.Order;
1811 break;
1812 case GL_MAP1_INDEX:
1813 *v = ctx->EvalMap.Map1Index.Order;
1814 break;
1815 case GL_MAP1_NORMAL:
1816 *v = ctx->EvalMap.Map1Normal.Order;
1817 break;
1818 case GL_MAP1_TEXTURE_COORD_1:
1819 *v = ctx->EvalMap.Map1Texture1.Order;
1820 break;
1821 case GL_MAP1_TEXTURE_COORD_2:
1822 *v = ctx->EvalMap.Map1Texture2.Order;
1823 break;
1824 case GL_MAP1_TEXTURE_COORD_3:
1825 *v = ctx->EvalMap.Map1Texture3.Order;
1826 break;
1827 case GL_MAP1_TEXTURE_COORD_4:
1828 *v = ctx->EvalMap.Map1Texture4.Order;
1829 break;
1830 case GL_MAP1_VERTEX_3:
1831 *v = ctx->EvalMap.Map1Vertex3.Order;
1832 break;
1833 case GL_MAP1_VERTEX_4:
1834 *v = ctx->EvalMap.Map1Vertex4.Order;
1835 break;
1836 case GL_MAP2_COLOR_4:
1837 v[0] = ctx->EvalMap.Map2Color4.Uorder;
1838 v[1] = ctx->EvalMap.Map2Color4.Vorder;
1839 break;
1840 case GL_MAP2_INDEX:
1841 v[0] = ctx->EvalMap.Map2Index.Uorder;
1842 v[1] = ctx->EvalMap.Map2Index.Vorder;
1843 break;
1844 case GL_MAP2_NORMAL:
1845 v[0] = ctx->EvalMap.Map2Normal.Uorder;
1846 v[1] = ctx->EvalMap.Map2Normal.Vorder;
1847 break;
1848 case GL_MAP2_TEXTURE_COORD_1:
1849 v[0] = ctx->EvalMap.Map2Texture1.Uorder;
1850 v[1] = ctx->EvalMap.Map2Texture1.Vorder;
1851 break;
1852 case GL_MAP2_TEXTURE_COORD_2:
1853 v[0] = ctx->EvalMap.Map2Texture2.Uorder;
1854 v[1] = ctx->EvalMap.Map2Texture2.Vorder;
1855 break;
1856 case GL_MAP2_TEXTURE_COORD_3:
1857 v[0] = ctx->EvalMap.Map2Texture3.Uorder;
1858 v[1] = ctx->EvalMap.Map2Texture3.Vorder;
1859 break;
1860 case GL_MAP2_TEXTURE_COORD_4:
1861 v[0] = ctx->EvalMap.Map2Texture4.Uorder;
1862 v[1] = ctx->EvalMap.Map2Texture4.Vorder;
1863 break;
1864 case GL_MAP2_VERTEX_3:
1865 v[0] = ctx->EvalMap.Map2Vertex3.Uorder;
1866 v[1] = ctx->EvalMap.Map2Vertex3.Vorder;
1867 break;
1868 case GL_MAP2_VERTEX_4:
1869 v[0] = ctx->EvalMap.Map2Vertex4.Uorder;
1870 v[1] = ctx->EvalMap.Map2Vertex4.Vorder;
1871 break;
1872 default:
1873 gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
1874 return;
1875 }
1876 break;
1877 case GL_DOMAIN:
1878 switch (target) {
1879 case GL_MAP1_COLOR_4:
1880 v[0] = ROUNDF(ctx->EvalMap.Map1Color4.u1);
1881 v[1] = ROUNDF(ctx->EvalMap.Map1Color4.u2);
1882 break;
1883 case GL_MAP1_INDEX:
1884 v[0] = ROUNDF(ctx->EvalMap.Map1Index.u1);
1885 v[1] = ROUNDF(ctx->EvalMap.Map1Index.u2);
1886 break;
1887 case GL_MAP1_NORMAL:
1888 v[0] = ROUNDF(ctx->EvalMap.Map1Normal.u1);
1889 v[1] = ROUNDF(ctx->EvalMap.Map1Normal.u2);
1890 break;
1891 case GL_MAP1_TEXTURE_COORD_1:
1892 v[0] = ROUNDF(ctx->EvalMap.Map1Texture1.u1);
1893 v[1] = ROUNDF(ctx->EvalMap.Map1Texture1.u2);
1894 break;
1895 case GL_MAP1_TEXTURE_COORD_2:
1896 v[0] = ROUNDF(ctx->EvalMap.Map1Texture2.u1);
1897 v[1] = ROUNDF(ctx->EvalMap.Map1Texture2.u2);
1898 break;
1899 case GL_MAP1_TEXTURE_COORD_3:
1900 v[0] = ROUNDF(ctx->EvalMap.Map1Texture3.u1);
1901 v[1] = ROUNDF(ctx->EvalMap.Map1Texture3.u2);
1902 break;
1903 case GL_MAP1_TEXTURE_COORD_4:
1904 v[0] = ROUNDF(ctx->EvalMap.Map1Texture4.u1);
1905 v[1] = ROUNDF(ctx->EvalMap.Map1Texture4.u2);
1906 break;
1907 case GL_MAP1_VERTEX_3:
1908 v[0] = ROUNDF(ctx->EvalMap.Map1Vertex3.u1);
1909 v[1] = ROUNDF(ctx->EvalMap.Map1Vertex3.u2);
1910 break;
1911 case GL_MAP1_VERTEX_4:
1912 v[0] = ROUNDF(ctx->EvalMap.Map1Vertex4.u1);
1913 v[1] = ROUNDF(ctx->EvalMap.Map1Vertex4.u2);
1914 break;
1915 case GL_MAP2_COLOR_4:
1916 v[0] = ROUNDF(ctx->EvalMap.Map2Color4.u1);
1917 v[1] = ROUNDF(ctx->EvalMap.Map2Color4.u2);
1918 v[2] = ROUNDF(ctx->EvalMap.Map2Color4.v1);
1919 v[3] = ROUNDF(ctx->EvalMap.Map2Color4.v2);
1920 break;
1921 case GL_MAP2_INDEX:
1922 v[0] = ROUNDF(ctx->EvalMap.Map2Index.u1);
1923 v[1] = ROUNDF(ctx->EvalMap.Map2Index.u2);
1924 v[2] = ROUNDF(ctx->EvalMap.Map2Index.v1);
1925 v[3] = ROUNDF(ctx->EvalMap.Map2Index.v2);
1926 break;
1927 case GL_MAP2_NORMAL:
1928 v[0] = ROUNDF(ctx->EvalMap.Map2Normal.u1);
1929 v[1] = ROUNDF(ctx->EvalMap.Map2Normal.u2);
1930 v[2] = ROUNDF(ctx->EvalMap.Map2Normal.v1);
1931 v[3] = ROUNDF(ctx->EvalMap.Map2Normal.v2);
1932 break;
1933 case GL_MAP2_TEXTURE_COORD_1:
1934 v[0] = ROUNDF(ctx->EvalMap.Map2Texture1.u1);
1935 v[1] = ROUNDF(ctx->EvalMap.Map2Texture1.u2);
1936 v[2] = ROUNDF(ctx->EvalMap.Map2Texture1.v1);
1937 v[3] = ROUNDF(ctx->EvalMap.Map2Texture1.v2);
1938 break;
1939 case GL_MAP2_TEXTURE_COORD_2:
1940 v[0] = ROUNDF(ctx->EvalMap.Map2Texture2.u1);
1941 v[1] = ROUNDF(ctx->EvalMap.Map2Texture2.u2);
1942 v[2] = ROUNDF(ctx->EvalMap.Map2Texture2.v1);
1943 v[3] = ROUNDF(ctx->EvalMap.Map2Texture2.v2);
1944 break;
1945 case GL_MAP2_TEXTURE_COORD_3:
1946 v[0] = ROUNDF(ctx->EvalMap.Map2Texture3.u1);
1947 v[1] = ROUNDF(ctx->EvalMap.Map2Texture3.u2);
1948 v[2] = ROUNDF(ctx->EvalMap.Map2Texture3.v1);
1949 v[3] = ROUNDF(ctx->EvalMap.Map2Texture3.v2);
1950 break;
1951 case GL_MAP2_TEXTURE_COORD_4:
1952 v[0] = ROUNDF(ctx->EvalMap.Map2Texture4.u1);
1953 v[1] = ROUNDF(ctx->EvalMap.Map2Texture4.u2);
1954 v[2] = ROUNDF(ctx->EvalMap.Map2Texture4.v1);
1955 v[3] = ROUNDF(ctx->EvalMap.Map2Texture4.v2);
1956 break;
1957 case GL_MAP2_VERTEX_3:
1958 v[0] = ROUNDF(ctx->EvalMap.Map2Vertex3.u1);
1959 v[1] = ROUNDF(ctx->EvalMap.Map2Vertex3.u2);
1960 v[2] = ROUNDF(ctx->EvalMap.Map2Vertex3.v1);
1961 v[3] = ROUNDF(ctx->EvalMap.Map2Vertex3.v2);
1962 break;
1963 case GL_MAP2_VERTEX_4:
1964 v[0] = ROUNDF(ctx->EvalMap.Map2Vertex4.u1);
1965 v[1] = ROUNDF(ctx->EvalMap.Map2Vertex4.u2);
1966 v[2] = ROUNDF(ctx->EvalMap.Map2Vertex4.v1);
1967 v[3] = ROUNDF(ctx->EvalMap.Map2Vertex4.v2);
1968 break;
1969 default:
1970 gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
1971 }
1972 break;
1973 default:
1974 gl_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" );
1975 }
1976}
1977
1978
1979
Keith Whitwell485f0401999-10-08 09:27:09 +00001980static void eval_points1( GLfloat outcoord[][4],
Keith Whitwelld4714731999-10-19 18:37:02 +00001981 GLfloat coord[][4],
1982 const GLuint *flags,
1983 GLuint start,
1984 GLfloat du, GLfloat u1 )
jtgafb833d1999-08-19 00:55:39 +00001985{
1986 GLuint i;
Keith Whitwelld4714731999-10-19 18:37:02 +00001987 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00001988 if (flags[i] & VERT_EVAL_P1)
1989 outcoord[i][0] = coord[i][0] * du + u1;
1990 else if (flags[i] & VERT_EVAL_ANY) {
1991 outcoord[i][0] = coord[i][0];
1992 outcoord[i][1] = coord[i][1];
1993 }
1994}
1995
Keith Whitwell485f0401999-10-08 09:27:09 +00001996static void eval_points2( GLfloat outcoord[][4],
Keith Whitwelld4714731999-10-19 18:37:02 +00001997 GLfloat coord[][4],
1998 const GLuint *flags,
1999 GLuint start,
2000 GLfloat du, GLfloat u1,
2001 GLfloat dv, GLfloat v1 )
jtgafb833d1999-08-19 00:55:39 +00002002{
2003 GLuint i;
Keith Whitwelld4714731999-10-19 18:37:02 +00002004 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002005 if (flags[i] & VERT_EVAL_P2) {
2006 outcoord[i][0] = coord[i][0] * du + u1;
2007 outcoord[i][1] = coord[i][1] * dv + v1;
2008 } else if (flags[i] & VERT_EVAL_ANY) {
2009 outcoord[i][0] = coord[i][0];
2010 outcoord[i][1] = coord[i][1];
2011 }
2012}
2013
2014
2015static const GLubyte dirty_flags[5] = {
2016 0, /* not possible */
2017 VEC_DIRTY_0,
2018 VEC_DIRTY_1,
2019 VEC_DIRTY_2,
2020 VEC_DIRTY_3
2021};
2022
2023
Keith Whitwell485f0401999-10-08 09:27:09 +00002024static GLvector4f *eval1_4f( GLvector4f *dest,
2025 GLfloat coord[][4],
Keith Whitwelld4714731999-10-19 18:37:02 +00002026 const GLuint *flags,
2027 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002028 GLuint dimension,
2029 struct gl_1d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002030{
2031 const GLfloat u1 = map->u1;
2032 const GLfloat du = map->du;
2033 GLfloat (*to)[4] = dest->data;
2034 GLuint i;
2035
Keith Whitwelld4714731999-10-19 18:37:02 +00002036 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002037 if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
2038 GLfloat u = (coord[i][0] - u1) * du;
2039 ASSIGN_4V(to[i], 0,0,0,1);
2040 horner_bezier_curve(map->Points, to[i], u, dimension, map->Order);
2041 }
2042
2043 dest->count = i;
Keith Whitwelld4714731999-10-19 18:37:02 +00002044 dest->start = VEC_ELT(dest, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002045 dest->size = MAX2(dest->size, dimension);
2046 dest->flags |= dirty_flags[dimension];
2047 return dest;
2048}
2049
2050
Keith Whitwell485f0401999-10-08 09:27:09 +00002051static GLvector1ui *eval1_1ui( GLvector1ui *dest,
2052 GLfloat coord[][4],
Keith Whitwelld4714731999-10-19 18:37:02 +00002053 const GLuint *flags,
2054 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002055 struct gl_1d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002056{
2057 const GLfloat u1 = map->u1;
2058 const GLfloat du = map->du;
2059 GLuint *to = dest->data;
2060 GLuint i;
2061
Keith Whitwelld4714731999-10-19 18:37:02 +00002062 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002063 if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
2064 GLfloat u = (coord[i][0] - u1) * du;
2065 GLfloat tmp;
2066 horner_bezier_curve(map->Points, &tmp, u, 1, map->Order);
2067 to[i] = (GLuint) (GLint) tmp;
2068 }
2069
Keith Whitwelld4714731999-10-19 18:37:02 +00002070 dest->start = VEC_ELT(dest, GLuint, start);
jtgafb833d1999-08-19 00:55:39 +00002071 dest->count = i;
2072 return dest;
2073}
2074
Keith Whitwell485f0401999-10-08 09:27:09 +00002075static GLvector3f *eval1_norm( GLvector3f *dest,
Keith Whitwelld4714731999-10-19 18:37:02 +00002076 GLfloat coord[][4],
2077 GLuint *flags, /* not const */
2078 GLuint start,
2079 struct gl_1d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002080{
2081 const GLfloat u1 = map->u1;
2082 const GLfloat du = map->du;
2083 GLfloat (*to)[3] = dest->data;
2084 GLuint i;
2085
Keith Whitwelld4714731999-10-19 18:37:02 +00002086 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002087 if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
2088 GLfloat u = (coord[i][0] - u1) * du;
2089 horner_bezier_curve(map->Points, to[i], u, 3, map->Order);
2090 flags[i+1] |= VERT_NORM; /* reset */
2091 }
2092
Keith Whitwelld4714731999-10-19 18:37:02 +00002093 dest->start = VEC_ELT(dest, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002094 dest->count = i;
2095 return dest;
2096}
2097
Keith Whitwell485f0401999-10-08 09:27:09 +00002098static GLvector4ub *eval1_color( GLvector4ub *dest,
Keith Whitwelld4714731999-10-19 18:37:02 +00002099 GLfloat coord[][4],
2100 GLuint *flags, /* not const */
2101 GLuint start,
2102 struct gl_1d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002103{
2104 const GLfloat u1 = map->u1;
2105 const GLfloat du = map->du;
2106 GLubyte (*to)[4] = dest->data;
2107 GLuint i;
2108
Keith Whitwelld4714731999-10-19 18:37:02 +00002109 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002110 if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
2111 GLfloat u = (coord[i][0] - u1) * du;
2112 GLfloat fcolor[4];
2113 horner_bezier_curve(map->Points, fcolor, u, 4, map->Order);
Brian Paulc893a012000-10-28 20:41:13 +00002114 FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
jtgafb833d1999-08-19 00:55:39 +00002115 flags[i+1] |= VERT_RGBA; /* reset */
2116 }
2117
Keith Whitwelld4714731999-10-19 18:37:02 +00002118 dest->start = VEC_ELT(dest, GLubyte, start);
jtgafb833d1999-08-19 00:55:39 +00002119 dest->count = i;
2120 return dest;
2121}
2122
2123
2124
2125
Keith Whitwell485f0401999-10-08 09:27:09 +00002126static GLvector4f *eval2_obj_norm( GLvector4f *obj_ptr,
2127 GLvector3f *norm_ptr,
2128 GLfloat coord[][4],
2129 GLuint *flags,
Keith Whitwelld4714731999-10-19 18:37:02 +00002130 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002131 GLuint dimension,
2132 struct gl_2d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002133{
2134 const GLfloat u1 = map->u1;
2135 const GLfloat du = map->du;
2136 const GLfloat v1 = map->v1;
2137 const GLfloat dv = map->dv;
2138 GLfloat (*obj)[4] = obj_ptr->data;
2139 GLfloat (*normal)[3] = norm_ptr->data;
2140 GLuint i;
2141
Keith Whitwelld4714731999-10-19 18:37:02 +00002142 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002143 if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
2144 GLfloat u = (coord[i][0] - u1) * du;
2145 GLfloat v = (coord[i][1] - v1) * dv;
2146 GLfloat du[4], dv[4];
2147
2148 ASSIGN_4V(obj[i], 0,0,0,1);
2149 de_casteljau_surf(map->Points, obj[i], du, dv, u, v, dimension,
2150 map->Uorder, map->Vorder);
2151
2152 CROSS3(normal[i], du, dv);
2153 NORMALIZE_3FV(normal[i]);
2154 flags[i+1] |= VERT_NORM;
2155 }
2156
Keith Whitwelld4714731999-10-19 18:37:02 +00002157 obj_ptr->start = VEC_ELT(obj_ptr, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002158 obj_ptr->count = i;
2159 obj_ptr->size = MAX2(obj_ptr->size, dimension);
2160 obj_ptr->flags |= dirty_flags[dimension];
2161 return obj_ptr;
2162}
2163
2164
Keith Whitwell485f0401999-10-08 09:27:09 +00002165static GLvector4f *eval2_4f( GLvector4f *dest,
2166 GLfloat coord[][4],
Keith Whitwelld4714731999-10-19 18:37:02 +00002167 const GLuint *flags,
2168 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002169 GLuint dimension,
2170 struct gl_2d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002171{
2172 const GLfloat u1 = map->u1;
2173 const GLfloat du = map->du;
2174 const GLfloat v1 = map->v1;
2175 const GLfloat dv = map->dv;
2176 GLfloat (*to)[4] = dest->data;
2177 GLuint i;
2178
Keith Whitwelld4714731999-10-19 18:37:02 +00002179 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002180 if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
2181 GLfloat u = (coord[i][0] - u1) * du;
2182 GLfloat v = (coord[i][1] - v1) * dv;
2183 horner_bezier_surf(map->Points, to[i], u, v, dimension,
2184 map->Uorder, map->Vorder);
2185 }
2186
Keith Whitwelld4714731999-10-19 18:37:02 +00002187 dest->start = VEC_ELT(dest, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002188 dest->count = i;
2189 dest->size = MAX2(dest->size, dimension);
2190 dest->flags |= dirty_flags[dimension];
2191 return dest;
2192}
2193
2194
Keith Whitwell485f0401999-10-08 09:27:09 +00002195static GLvector3f *eval2_norm( GLvector3f *dest,
2196 GLfloat coord[][4],
2197 GLuint *flags,
Keith Whitwelld4714731999-10-19 18:37:02 +00002198 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002199 struct gl_2d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002200{
2201 const GLfloat u1 = map->u1;
2202 const GLfloat du = map->du;
2203 const GLfloat v1 = map->v1;
2204 const GLfloat dv = map->dv;
2205 GLfloat (*to)[3] = dest->data;
2206 GLuint i;
2207
Keith Whitwelld4714731999-10-19 18:37:02 +00002208 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002209 if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
2210 GLfloat u = (coord[i][0] - u1) * du;
2211 GLfloat v = (coord[i][1] - v1) * dv;
2212 horner_bezier_surf(map->Points, to[i], u, v, 3,
2213 map->Uorder, map->Vorder);
2214 flags[i+1] |= VERT_NORM; /* reset */
2215 }
2216
Keith Whitwelld4714731999-10-19 18:37:02 +00002217 dest->start = VEC_ELT(dest, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002218 dest->count = i;
2219 return dest;
2220}
2221
2222
Keith Whitwell485f0401999-10-08 09:27:09 +00002223static GLvector1ui *eval2_1ui( GLvector1ui *dest,
2224 GLfloat coord[][4],
Keith Whitwelld4714731999-10-19 18:37:02 +00002225 const GLuint *flags,
2226 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002227 struct gl_2d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002228{
2229 const GLfloat u1 = map->u1;
2230 const GLfloat du = map->du;
2231 const GLfloat v1 = map->v1;
2232 const GLfloat dv = map->dv;
2233 GLuint *to = dest->data;
2234 GLuint i;
2235
Keith Whitwelld4714731999-10-19 18:37:02 +00002236 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002237 if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
2238 GLfloat u = (coord[i][0] - u1) * du;
2239 GLfloat v = (coord[i][1] - v1) * dv;
2240 GLfloat tmp;
2241 horner_bezier_surf(map->Points, &tmp, u, v, 1,
2242 map->Uorder, map->Vorder);
2243
2244 to[i] = (GLuint) (GLint) tmp;
2245 }
2246
Keith Whitwelld4714731999-10-19 18:37:02 +00002247 dest->start = VEC_ELT(dest, GLuint, start);
jtgafb833d1999-08-19 00:55:39 +00002248 dest->count = i;
2249 return dest;
2250}
2251
2252
2253
Keith Whitwell485f0401999-10-08 09:27:09 +00002254static GLvector4ub *eval2_color( GLvector4ub *dest,
2255 GLfloat coord[][4],
2256 GLuint *flags,
Keith Whitwelld4714731999-10-19 18:37:02 +00002257 GLuint start,
Keith Whitwell485f0401999-10-08 09:27:09 +00002258 struct gl_2d_map *map )
jtgafb833d1999-08-19 00:55:39 +00002259{
2260 const GLfloat u1 = map->u1;
2261 const GLfloat du = map->du;
2262 const GLfloat v1 = map->v1;
2263 const GLfloat dv = map->dv;
2264 GLubyte (*to)[4] = dest->data;
2265 GLuint i;
2266
Keith Whitwelld4714731999-10-19 18:37:02 +00002267 for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002268 if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
2269 GLfloat u = (coord[i][0] - u1) * du;
2270 GLfloat v = (coord[i][1] - v1) * dv;
2271 GLfloat fcolor[4];
2272 horner_bezier_surf(map->Points, fcolor, u, v, 4,
2273 map->Uorder, map->Vorder);
Brian Paulc893a012000-10-28 20:41:13 +00002274 FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
jtgafb833d1999-08-19 00:55:39 +00002275 flags[i+1] |= VERT_RGBA; /* reset */
2276 }
2277
Keith Whitwelld4714731999-10-19 18:37:02 +00002278 dest->start = VEC_ELT(dest, GLubyte, start);
jtgafb833d1999-08-19 00:55:39 +00002279 dest->count = i;
2280 return dest;
2281}
2282
2283
Keith Whitwell485f0401999-10-08 09:27:09 +00002284static GLvector4f *copy_4f( GLvector4f *out, CONST GLvector4f *in,
Keith Whitwelld4714731999-10-19 18:37:02 +00002285 const GLuint *flags,
2286 GLuint start )
jtgafb833d1999-08-19 00:55:39 +00002287{
2288 GLfloat (*to)[4] = out->data;
2289 GLfloat (*from)[4] = in->data;
2290 GLuint i;
2291
Keith Whitwelld4714731999-10-19 18:37:02 +00002292 for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002293 if (!(flags[i] & VERT_EVAL_ANY))
2294 COPY_4FV( to[i], from[i] );
2295
Keith Whitwelld4714731999-10-19 18:37:02 +00002296 out->start = VEC_ELT(out, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002297 return out;
2298}
2299
Keith Whitwell485f0401999-10-08 09:27:09 +00002300static GLvector3f *copy_3f( GLvector3f *out, CONST GLvector3f *in,
Keith Whitwelld4714731999-10-19 18:37:02 +00002301 const GLuint *flags,
2302 GLuint start )
jtgafb833d1999-08-19 00:55:39 +00002303{
2304 GLfloat (*to)[3] = out->data;
2305 GLfloat (*from)[3] = in->data;
2306 GLuint i;
2307
Keith Whitwelld4714731999-10-19 18:37:02 +00002308 for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002309 if (!(flags[i] & VERT_EVAL_ANY))
2310 COPY_3V( to[i], from[i] );
2311
Keith Whitwelld4714731999-10-19 18:37:02 +00002312 out->start = VEC_ELT(out, GLfloat, start);
jtgafb833d1999-08-19 00:55:39 +00002313 return out;
2314}
2315
Keith Whitwelld4714731999-10-19 18:37:02 +00002316static GLvector4ub *copy_4ub( GLvector4ub *out,
2317 CONST GLvector4ub *in,
2318 const GLuint *flags,
2319 GLuint start )
jtgafb833d1999-08-19 00:55:39 +00002320{
2321 GLubyte (*to)[4] = out->data;
2322 GLubyte (*from)[4] = in->data;
2323 GLuint i;
2324
Keith Whitwelld4714731999-10-19 18:37:02 +00002325 for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002326 if (!(flags[i] & VERT_EVAL_ANY))
2327 COPY_4UBV( to[i], from[i] );
2328
Keith Whitwelld4714731999-10-19 18:37:02 +00002329 out->start = VEC_ELT(out, GLubyte, start);
jtgafb833d1999-08-19 00:55:39 +00002330 return out;
2331}
2332
Keith Whitwelld4714731999-10-19 18:37:02 +00002333static GLvector1ui *copy_1ui( GLvector1ui *out,
2334 CONST GLvector1ui *in,
2335 const GLuint *flags,
2336 GLuint start )
jtgafb833d1999-08-19 00:55:39 +00002337{
2338 GLuint *to = out->data;
2339 CONST GLuint *from = in->data;
2340 GLuint i;
2341
Keith Whitwelld4714731999-10-19 18:37:02 +00002342 for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
jtgafb833d1999-08-19 00:55:39 +00002343 if (!(flags[i] & VERT_EVAL_ANY))
2344 to[i] = from[i];
2345
Keith Whitwelld4714731999-10-19 18:37:02 +00002346 out->start = VEC_ELT(out, GLuint, start);
jtgafb833d1999-08-19 00:55:39 +00002347 return out;
2348}
2349
2350
2351/* KW: Rewrote this to perform eval on a whole buffer at once.
2352 * Only evaluates active data items, and avoids scribbling
2353 * the source buffer if we are running from a display list.
2354 *
2355 * If the user (in this case looser) sends eval coordinates
2356 * or runs a display list containing eval coords with no
2357 * vertex maps enabled, we have to either copy all non-eval
2358 * data to a new buffer, or find a way of working around
2359 * the eval data. I choose the second option.
2360 *
2361 * KW: This code not reached by cva - use IM to access storage.
2362 */
2363void gl_eval_vb( struct vertex_buffer *VB )
2364{
2365 struct immediate *IM = VB->IM;
2366 GLcontext *ctx = VB->ctx;
2367 GLuint req = ctx->CVA.elt.inputs;
2368 GLfloat (*coord)[4] = VB->ObjPtr->data;
2369 GLuint *flags = VB->Flag;
2370 GLuint new_flags = 0;
2371
2372
2373 GLuint any_eval1 = VB->OrFlag & (VERT_EVAL_C1|VERT_EVAL_P1);
2374 GLuint any_eval2 = VB->OrFlag & (VERT_EVAL_C2|VERT_EVAL_P2);
Keith Whitwelld4714731999-10-19 18:37:02 +00002375 GLuint all_eval = IM->AndFlag & VERT_EVAL_ANY;
jtgafb833d1999-08-19 00:55:39 +00002376
2377 /* Handle the degenerate cases.
2378 */
2379 if (any_eval1 && !ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3) {
2380 VB->PurgeFlags |= (VERT_EVAL_C1|VERT_EVAL_P1);
2381 VB->EarlyCull = 0;
2382 any_eval1 = GL_FALSE;
2383 }
2384
2385 if (any_eval2 && !ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3) {
2386 VB->PurgeFlags |= (VERT_EVAL_C2|VERT_EVAL_P2);
2387 VB->EarlyCull = 0;
2388 any_eval2 = GL_FALSE;
2389 }
2390
2391 /* KW: This really is a degenerate case - doing this disables
2392 * culling, and causes dummy values for the missing vertices to be
2393 * transformed and clip tested. It also forces the individual
2394 * cliptesting of each primitive in vb_render. I wish there was a
2395 * nice alternative, but I can't say I want to put effort into
2396 * optimizing such a bad usage of the library - I'd much rather
2397 * work on useful changes.
2398 */
2399 if (VB->PurgeFlags) {
Keith Whitwelld4714731999-10-19 18:37:02 +00002400 if (!any_eval1 && !any_eval2 && all_eval) VB->Count = VB->Start;
jtgafb833d1999-08-19 00:55:39 +00002401 gl_purge_vertices( VB );
2402 if (!any_eval1 && !any_eval2) return;
2403 } else
2404 VB->IndirectCount = VB->Count;
2405
2406 /* Translate points into coords.
2407 */
2408 if (any_eval1 && (VB->OrFlag & VERT_EVAL_P1))
2409 {
Keith Whitwelld4714731999-10-19 18:37:02 +00002410 eval_points1( IM->Obj, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002411 ctx->Eval.MapGrid1du,
2412 ctx->Eval.MapGrid1u1);
2413
2414 coord = IM->Obj;
2415 }
2416
2417 if (any_eval2 && (VB->OrFlag & VERT_EVAL_P2))
2418 {
Keith Whitwelld4714731999-10-19 18:37:02 +00002419 eval_points2( IM->Obj, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002420 ctx->Eval.MapGrid2du,
2421 ctx->Eval.MapGrid2u1,
2422 ctx->Eval.MapGrid2dv,
2423 ctx->Eval.MapGrid2v1 );
2424
2425 coord = IM->Obj;
2426 }
2427
2428 /* Perform the evaluations on active data elements.
2429 */
2430 if (req & VERT_INDEX)
2431 {
2432 GLvector1ui *in_index = VB->IndexPtr;
2433 GLvector1ui *out_index = &IM->v.Index;
2434
2435 if (ctx->Eval.Map1Index && any_eval1)
Keith Whitwelld4714731999-10-19 18:37:02 +00002436 VB->IndexPtr = eval1_1ui( out_index, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002437 &ctx->EvalMap.Map1Index );
2438
2439 if (ctx->Eval.Map2Index && any_eval2)
Keith Whitwelld4714731999-10-19 18:37:02 +00002440 VB->IndexPtr = eval2_1ui( out_index, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002441 &ctx->EvalMap.Map2Index );
2442
2443 if (VB->IndexPtr != in_index) {
2444 new_flags |= VERT_INDEX;
2445 if (!all_eval)
Keith Whitwelld4714731999-10-19 18:37:02 +00002446 VB->IndexPtr = copy_1ui( out_index, in_index, flags, IM->Start );
jtgafb833d1999-08-19 00:55:39 +00002447 }
2448 }
2449
2450 if (req & VERT_RGBA)
2451 {
2452 GLvector4ub *in_color = VB->ColorPtr;
2453 GLvector4ub *out_color = &IM->v.Color;
2454
2455 if (ctx->Eval.Map1Color4 && any_eval1)
Keith Whitwelld4714731999-10-19 18:37:02 +00002456 VB->ColorPtr = eval1_color( out_color, coord, flags, IM->Start,
Keith Whitwella62875d2000-07-17 12:53:33 +00002457 &ctx->EvalMap.Map1Color4 );
jtgafb833d1999-08-19 00:55:39 +00002458
2459 if (ctx->Eval.Map2Color4 && any_eval2)
Keith Whitwelld4714731999-10-19 18:37:02 +00002460 VB->ColorPtr = eval2_color( out_color, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002461 &ctx->EvalMap.Map2Color4 );
2462
2463 if (VB->ColorPtr != in_color) {
2464 new_flags |= VERT_RGBA;
2465 if (!all_eval)
Keith Whitwelld4714731999-10-19 18:37:02 +00002466 VB->ColorPtr = copy_4ub( out_color, in_color, flags, IM->Start );
jtgafb833d1999-08-19 00:55:39 +00002467 }
2468
2469 VB->Color[0] = VB->Color[1] = VB->ColorPtr;
2470 }
2471
2472
2473 if (req & VERT_NORM)
2474 {
2475 GLvector3f *in_normal = VB->NormalPtr;
2476 GLvector3f *out_normal = &IM->v.Normal;
2477
2478 if (ctx->Eval.Map1Normal && any_eval1)
Keith Whitwelld4714731999-10-19 18:37:02 +00002479 VB->NormalPtr = eval1_norm( out_normal, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002480 &ctx->EvalMap.Map1Normal );
2481
2482 if (ctx->Eval.Map2Normal && any_eval2)
Keith Whitwelld4714731999-10-19 18:37:02 +00002483 VB->NormalPtr = eval2_norm( out_normal, coord, flags, IM->Start,
jtgafb833d1999-08-19 00:55:39 +00002484 &ctx->EvalMap.Map2Normal );
2485
Keith Whitwella62875d2000-07-17 12:53:33 +00002486 new_flags |= VERT_NORM;
2487
jtgafb833d1999-08-19 00:55:39 +00002488 if (VB->NormalPtr != in_normal) {
jtgafb833d1999-08-19 00:55:39 +00002489 if (!all_eval)
Keith Whitwelld4714731999-10-19 18:37:02 +00002490 VB->NormalPtr = copy_3f( out_normal, in_normal, flags, IM->Start );
jtgafb833d1999-08-19 00:55:39 +00002491 }
2492 }
2493
2494
2495 if (req & VERT_TEX_ANY(0))
2496 {
2497 GLvector4f *tc = VB->TexCoordPtr[0];
2498 GLvector4f *in = tc;
2499 GLvector4f *out = &IM->v.TexCoord[0];
2500
2501 if (any_eval1) {
2502 if (ctx->Eval.Map1TextureCoord4)
Keith Whitwelld4714731999-10-19 18:37:02 +00002503 tc = eval1_4f( out, coord, flags, IM->Start,
2504 4, &ctx->EvalMap.Map1Texture4);
jtgafb833d1999-08-19 00:55:39 +00002505 else if (ctx->Eval.Map1TextureCoord3)
Keith Whitwelld4714731999-10-19 18:37:02 +00002506 tc = eval1_4f( out, coord, flags, IM->Start, 3,
2507 &ctx->EvalMap.Map1Texture3);
jtgafb833d1999-08-19 00:55:39 +00002508 else if (ctx->Eval.Map1TextureCoord2)
Keith Whitwelld4714731999-10-19 18:37:02 +00002509 tc = eval1_4f( out, coord, flags, IM->Start, 2,
2510 &ctx->EvalMap.Map1Texture2);
jtgafb833d1999-08-19 00:55:39 +00002511 else if (ctx->Eval.Map1TextureCoord1)
Keith Whitwelld4714731999-10-19 18:37:02 +00002512 tc = eval1_4f( out, coord, flags, IM->Start, 1,
2513 &ctx->EvalMap.Map1Texture1);
jtgafb833d1999-08-19 00:55:39 +00002514 }
2515
2516 if (any_eval2) {
2517 if (ctx->Eval.Map2TextureCoord4)
Keith Whitwelld4714731999-10-19 18:37:02 +00002518 tc = eval2_4f( out, coord, flags, IM->Start,
2519 4, &ctx->EvalMap.Map2Texture4);
jtgafb833d1999-08-19 00:55:39 +00002520 else if (ctx->Eval.Map2TextureCoord3)
Keith Whitwelld4714731999-10-19 18:37:02 +00002521 tc = eval2_4f( out, coord, flags, IM->Start,
2522 3, &ctx->EvalMap.Map2Texture3);
jtgafb833d1999-08-19 00:55:39 +00002523 else if (ctx->Eval.Map2TextureCoord2)
Keith Whitwelld4714731999-10-19 18:37:02 +00002524 tc = eval2_4f( out, coord, flags, IM->Start,
2525 2, &ctx->EvalMap.Map2Texture2);
jtgafb833d1999-08-19 00:55:39 +00002526 else if (ctx->Eval.Map2TextureCoord1)
Keith Whitwelld4714731999-10-19 18:37:02 +00002527 tc = eval2_4f( out, coord, flags, IM->Start,
2528 1, &ctx->EvalMap.Map2Texture1);
jtgafb833d1999-08-19 00:55:39 +00002529 }
2530
2531 if (tc != in) {
2532 new_flags |= VERT_TEX_ANY(0); /* fix for sizes.. */
2533 if (!all_eval)
Keith Whitwelld4714731999-10-19 18:37:02 +00002534 tc = copy_4f( out, in, flags, IM->Start );
jtgafb833d1999-08-19 00:55:39 +00002535 }
2536
2537 VB->TexCoordPtr[0] = tc;
2538 }
2539
2540
2541 {
2542 GLvector4f *in = VB->ObjPtr;
2543 GLvector4f *out = &IM->v.Obj;
2544 GLvector4f *obj = in;
2545
2546 if (any_eval1) {
2547 if (ctx->Eval.Map1Vertex4)
Keith Whitwelld4714731999-10-19 18:37:02 +00002548 obj = eval1_4f( out, coord, flags, IM->Start,
2549 4, &ctx->EvalMap.Map1Vertex4);
jtgafb833d1999-08-19 00:55:39 +00002550 else
Keith Whitwelld4714731999-10-19 18:37:02 +00002551 obj = eval1_4f( out, coord, flags, IM->Start,
2552 3, &ctx->EvalMap.Map1Vertex3);
jtgafb833d1999-08-19 00:55:39 +00002553 }
2554
2555 if (any_eval2) {
Keith Whitwella62875d2000-07-17 12:53:33 +00002556 GLvector3f *in_normal = VB->NormalPtr;
2557 GLvector3f *out_normal = &IM->v.Normal;
2558
jtgafb833d1999-08-19 00:55:39 +00002559 if (ctx->Eval.Map2Vertex4)
2560 {
Keith Whitwella62875d2000-07-17 12:53:33 +00002561 if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
2562 obj = eval2_obj_norm( out, out_normal, coord, flags,
2563 IM->Start, 4, &ctx->EvalMap.Map2Vertex4 );
2564 VB->NormalPtr = out_normal;
2565 new_flags |= VERT_NORM;
2566 }
jtgafb833d1999-08-19 00:55:39 +00002567 else
Keith Whitwelld4714731999-10-19 18:37:02 +00002568 obj = eval2_4f( out, coord, flags, IM->Start,
Keith Whitwella62875d2000-07-17 12:53:33 +00002569 4, &ctx->EvalMap.Map2Vertex4 );
jtgafb833d1999-08-19 00:55:39 +00002570 }
2571 else if (ctx->Eval.Map2Vertex3)
2572 {
Keith Whitwella62875d2000-07-17 12:53:33 +00002573 if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
2574 obj = eval2_obj_norm( out, out_normal, coord, flags,
2575 IM->Start, 3, &ctx->EvalMap.Map2Vertex3 );
2576 VB->NormalPtr = out_normal;
2577 new_flags |= VERT_NORM;
2578 }
jtgafb833d1999-08-19 00:55:39 +00002579 else
Keith Whitwelld4714731999-10-19 18:37:02 +00002580 obj = eval2_4f( out, coord, flags, IM->Start,
2581 3, &ctx->EvalMap.Map2Vertex3 );
jtgafb833d1999-08-19 00:55:39 +00002582 }
jtgafb833d1999-08-19 00:55:39 +00002583
Keith Whitwella62875d2000-07-17 12:53:33 +00002584
2585 if (VB->NormalPtr != in_normal) {
2586 if (!all_eval)
2587 VB->NormalPtr = copy_3f( out_normal, in_normal, flags,
2588 IM->Start );
2589 }
2590 }
2591
jtgafb833d1999-08-19 00:55:39 +00002592 if (obj != in && !all_eval)
Keith Whitwelld4714731999-10-19 18:37:02 +00002593 obj = copy_4f( out, in, flags, IM->Start );
jtgafb833d1999-08-19 00:55:39 +00002594
2595 VB->ObjPtr = obj;
2596 }
2597
2598 if (new_flags) {
2599 GLuint *oldflags = VB->Flag;
2600 GLuint *flags = VB->Flag = VB->EvaluatedFlags;
2601 GLuint i;
2602 GLuint count = VB->Count;
Keith Whitwella62875d2000-07-17 12:53:33 +00002603 GLuint andflag = VB->IM->AndFlag;
jtgafb833d1999-08-19 00:55:39 +00002604
2605 if (!flags) {
Brian Paulbd5cdaf1999-10-13 18:42:49 +00002606 VB->EvaluatedFlags = (GLuint *) MALLOC(VB->Size * sizeof(GLuint));
jtgafb833d1999-08-19 00:55:39 +00002607 flags = VB->Flag = VB->EvaluatedFlags;
2608 }
2609
2610 if (all_eval) {
Keith Whitwellcc70e782000-07-20 15:53:17 +00002611 for (i = 0 ; i <= count ; i++)
jtgafb833d1999-08-19 00:55:39 +00002612 flags[i] = oldflags[i] | new_flags;
Keith Whitwella62875d2000-07-17 12:53:33 +00002613 andflag |= new_flags;
jtgafb833d1999-08-19 00:55:39 +00002614 } else {
Keith Whitwella62875d2000-07-17 12:53:33 +00002615 andflag = ~0;
Keith Whitwellcc70e782000-07-20 15:53:17 +00002616 for (i = 0 ; i <= count ; i++) {
2617 flags[i] = oldflags[i];
2618 if (flags[i] & VERT_EVAL_ANY)
2619 flags[i] |= new_flags;
jtgafb833d1999-08-19 00:55:39 +00002620 andflag &= flags[i];
2621 }
jtgafb833d1999-08-19 00:55:39 +00002622 }
Keith Whitwella62875d2000-07-17 12:53:33 +00002623
2624 VB->OrFlag |= new_flags;
2625 VB->CullMode = (GLubyte) ((andflag & VERT_NORM) ? 0 : COMPACTED_NORMALS);
jtgafb833d1999-08-19 00:55:39 +00002626 }
2627}
2628
2629
Brian Paulfbd8f211999-11-11 01:22:25 +00002630void
2631_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
jtgafb833d1999-08-19 00:55:39 +00002632{
Brian Paulfbd8f211999-11-11 01:22:25 +00002633 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00002634 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid1f");
2635
2636 if (un<1) {
2637 gl_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" );
2638 return;
2639 }
2640 ctx->Eval.MapGrid1un = un;
2641 ctx->Eval.MapGrid1u1 = u1;
2642 ctx->Eval.MapGrid1u2 = u2;
2643 ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un;
2644}
2645
2646
Brian Paulfbd8f211999-11-11 01:22:25 +00002647void
2648_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
jtgafb833d1999-08-19 00:55:39 +00002649{
Brian Paulfbd8f211999-11-11 01:22:25 +00002650 _mesa_MapGrid1f( un, u1, u2 );
2651}
2652
2653
2654void
2655_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
2656 GLint vn, GLfloat v1, GLfloat v2 )
2657{
2658 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00002659 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMapGrid2f");
2660 if (un<1) {
2661 gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" );
2662 return;
2663 }
2664 if (vn<1) {
2665 gl_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" );
2666 return;
2667 }
2668 ctx->Eval.MapGrid2un = un;
2669 ctx->Eval.MapGrid2u1 = u1;
2670 ctx->Eval.MapGrid2u2 = u2;
2671 ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un;
2672 ctx->Eval.MapGrid2vn = vn;
2673 ctx->Eval.MapGrid2v1 = v1;
2674 ctx->Eval.MapGrid2v2 = v2;
2675 ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn;
2676}
2677
2678
Brian Paulfbd8f211999-11-11 01:22:25 +00002679void
2680_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
2681 GLint vn, GLdouble v1, GLdouble v2 )
jtgafb833d1999-08-19 00:55:39 +00002682{
Brian Paulfbd8f211999-11-11 01:22:25 +00002683 _mesa_MapGrid2f( un, u1, u2, vn, v1, v2 );
2684}
2685
2686
2687
2688
2689/* KW: If are compiling, we don't know whether eval will produce a
2690 * vertex when it is run in the future. If this is pure immediate
2691 * mode, eval is a noop if neither vertex map is enabled.
2692 *
2693 * Thus we need to have a check in the display list code or
2694 * elsewhere for eval(1,2) vertices in the case where
2695 * map(1,2)_vertex is disabled, and to purge those vertices from
2696 * the vb. This is currently done
2697 * via modifications to the cull_vb and render_vb operations, and
2698 * by using the existing cullmask mechanism for all other operations.
2699 */
2700
2701
2702/* KW: Because the eval values don't become 'current', fixup will flow
2703 * through these vertices, and then evaluation will write on top
2704 * of the fixup results.
2705 *
2706 * This is a little inefficient, but at least it is correct. This
2707 * could be short-circuited in the case where all vertices are
2708 * eval-vertices, or more generally by a cullmask in fixup.
2709 *
2710 * Note: using Obj to hold eval coord data. This data is actually
2711 * transformed if eval is disabled. But disabling eval & sending
2712 * eval coords is stupid, right?
2713 */
2714
2715
2716#define EVALCOORD1(IM, x) \
2717{ \
2718 GLuint count = IM->Count++; \
2719 IM->Flag[count] |= VERT_EVAL_C1; \
2720 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
2721 if (count == VB_MAX-1) \
Brian Paul038573a2000-09-11 18:49:06 +00002722 _mesa_maybe_transform_vb( IM ); \
Brian Paulfbd8f211999-11-11 01:22:25 +00002723}
2724
2725#define EVALCOORD2(IM, x, y) \
2726{ \
2727 GLuint count = IM->Count++; \
2728 IM->Flag[count] |= VERT_EVAL_C2; \
2729 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
2730 if (count == VB_MAX-1) \
Brian Paul038573a2000-09-11 18:49:06 +00002731 _mesa_maybe_transform_vb( IM ); \
Brian Paulfbd8f211999-11-11 01:22:25 +00002732}
2733
2734#define EVALPOINT1(IM, x) \
2735{ \
2736 GLuint count = IM->Count++; \
2737 IM->Flag[count] |= VERT_EVAL_P1; \
2738 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
2739 if (count == VB_MAX-1) \
Brian Paul038573a2000-09-11 18:49:06 +00002740 _mesa_maybe_transform_vb( IM ); \
Brian Paulfbd8f211999-11-11 01:22:25 +00002741}
2742
2743#define EVALPOINT2(IM, x, y) \
2744{ \
2745 GLuint count = IM->Count++; \
2746 IM->Flag[count] |= VERT_EVAL_P2; \
2747 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
2748 if (count == VB_MAX-1) \
Brian Paul038573a2000-09-11 18:49:06 +00002749 _mesa_maybe_transform_vb( IM ); \
Brian Paulfbd8f211999-11-11 01:22:25 +00002750}
2751
2752
2753/* Lame internal function:
2754 */
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002755static void
2756eval_coord1f( GLcontext *CC, GLfloat u )
Brian Paulfbd8f211999-11-11 01:22:25 +00002757{
2758 struct immediate *i = CC->input;
2759 EVALCOORD1( i, u );
2760}
2761
2762
2763void
2764_mesa_EvalCoord1d( GLdouble u )
2765{
2766 GET_IMMEDIATE;
2767 EVALCOORD1( IM, (GLfloat) u );
2768}
2769
2770
2771void
2772_mesa_EvalCoord1f( GLfloat u )
2773{
2774 GET_IMMEDIATE;
2775 EVALCOORD1( IM, u );
2776}
2777
2778
2779void
2780_mesa_EvalCoord1dv( const GLdouble *u )
2781{
2782 GET_IMMEDIATE;
2783 EVALCOORD1( IM, (GLfloat) *u );
2784}
2785
2786
2787void
2788_mesa_EvalCoord1fv( const GLfloat *u )
2789{
2790 GET_IMMEDIATE;
2791 EVALCOORD1( IM, (GLfloat) *u );
2792}
2793
2794
2795void
2796_mesa_EvalCoord2d( GLdouble u, GLdouble v )
2797{
2798 GET_IMMEDIATE;
2799 EVALCOORD2( IM, (GLfloat) u, (GLfloat) v );
2800}
2801
2802
2803void
2804_mesa_EvalCoord2f( GLfloat u, GLfloat v )
2805{
2806 GET_IMMEDIATE;
2807 EVALCOORD2( IM, u, v );
2808}
2809
2810
2811/* Lame internal function:
2812 */
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002813static void
2814eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v )
Brian Paulfbd8f211999-11-11 01:22:25 +00002815{
2816 struct immediate *i = CC->input;
2817 EVALCOORD2( i, u, v );
2818}
2819
2820
2821void
2822_mesa_EvalCoord2dv( const GLdouble *u )
2823{
2824 GET_IMMEDIATE;
2825 EVALCOORD2( IM, (GLfloat) u[0], (GLfloat) u[1] );
2826}
2827
2828
2829void
2830_mesa_EvalCoord2fv( const GLfloat *u )
2831{
2832 GET_IMMEDIATE;
2833 EVALCOORD2( IM, u[0], u[1] );
2834}
2835
2836
2837void
2838_mesa_EvalPoint1( GLint i )
2839{
2840 GET_IMMEDIATE;
2841 EVALPOINT1( IM, i );
2842}
2843
2844
2845void
2846_mesa_EvalPoint2( GLint i, GLint j )
2847{
2848 GET_IMMEDIATE;
2849 EVALPOINT2( IM, i, j );
2850}
2851
2852
2853
2854
2855
2856void
2857_mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
2858{
2859 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00002860 GLint i;
2861 GLfloat u, du;
2862 GLenum prim;
2863
2864 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glEvalMesh1");
2865
2866 switch (mode) {
2867 case GL_POINT:
2868 prim = GL_POINTS;
2869 break;
2870 case GL_LINE:
2871 prim = GL_LINE_STRIP;
2872 break;
2873 default:
2874 gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
2875 return;
2876 }
2877
2878 /* No effect if vertex maps disabled.
2879 */
2880 if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3)
2881 return;
2882
2883 du = ctx->Eval.MapGrid1du;
2884 u = ctx->Eval.MapGrid1u1 + i1 * du;
2885
2886 /* KW: Could short-circuit this to avoid the immediate mechanism.
2887 */
2888 RESET_IMMEDIATE(ctx);
2889
2890 gl_Begin( ctx, prim );
2891 for (i=i1;i<=i2;i++,u+=du) {
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002892 eval_coord1f( ctx, u );
jtgafb833d1999-08-19 00:55:39 +00002893 }
2894 gl_End(ctx);
2895}
2896
2897
2898
Brian Paulfbd8f211999-11-11 01:22:25 +00002899void
2900_mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
jtgafb833d1999-08-19 00:55:39 +00002901{
Brian Paulfbd8f211999-11-11 01:22:25 +00002902 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00002903 GLint i, j;
2904 GLfloat u, du, v, dv, v1, u1;
2905
2906 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glEvalMesh2");
2907
2908 /* No effect if vertex maps disabled.
2909 */
2910 if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3)
2911 return;
2912
2913 du = ctx->Eval.MapGrid2du;
2914 dv = ctx->Eval.MapGrid2dv;
2915 v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
2916 u1 = ctx->Eval.MapGrid2u1 + i1 * du;
2917
2918 RESET_IMMEDIATE(ctx);
2919
2920 switch (mode) {
2921 case GL_POINT:
2922 gl_Begin( ctx, GL_POINTS );
2923 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
2924 for (u=u1,i=i1;i<=i2;i++,u+=du) {
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002925 eval_coord2f( ctx, u, v );
jtgafb833d1999-08-19 00:55:39 +00002926 }
2927 }
2928 gl_End(ctx);
2929 break;
2930 case GL_LINE:
2931 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
2932 gl_Begin( ctx, GL_LINE_STRIP );
2933 for (u=u1,i=i1;i<=i2;i++,u+=du) {
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002934 eval_coord2f( ctx, u, v );
jtgafb833d1999-08-19 00:55:39 +00002935 }
2936 gl_End(ctx);
2937 }
2938 for (u=u1,i=i1;i<=i2;i++,u+=du) {
2939 gl_Begin( ctx, GL_LINE_STRIP );
2940 for (v=v1,j=j1;j<=j2;j++,v+=dv) {
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002941 eval_coord2f( ctx, u, v );
jtgafb833d1999-08-19 00:55:39 +00002942 }
2943 gl_End(ctx);
2944 }
2945 break;
2946 case GL_FILL:
2947 for (v=v1,j=j1;j<j2;j++,v+=dv) {
2948 /* NOTE: a quad strip can't be used because the four */
2949 /* can't be guaranteed to be coplanar! */
2950 gl_Begin( ctx, GL_TRIANGLE_STRIP );
2951 for (u=u1,i=i1;i<=i2;i++,u+=du) {
Brian Paulc7a5dbe2000-01-13 00:30:41 +00002952 eval_coord2f( ctx, u, v );
2953 eval_coord2f( ctx, u, v+dv );
jtgafb833d1999-08-19 00:55:39 +00002954 }
2955 gl_End(ctx);
2956 }
2957 break;
2958 default:
2959 gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
2960 return;
2961 }
2962}
Brian Paulfbd8f211999-11-11 01:22:25 +00002963
2964
2965