1 /* $Id: eval.c,v 1.8 2000/01/13 00:30:41 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
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).
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.
57 static GLfloat inv_tab
[MAX_EVAL_ORDER
];
60 * Do one-time initialization for evaluators.
62 void gl_init_eval( void )
64 static int init_flag
= 0;
67 /* Compute a table of nCr (combination) values used by the
68 * Bernstein polynomial generator.
71 /* KW: precompute 1/x for useful x.
75 for (i
= 1 ; i
< MAX_EVAL_ORDER
; i
++)
85 * Horner scheme for Bezier curves
87 * Bezier curves can be computed via a Horner scheme.
88 * Horner is numerically less stable than the de Casteljau
89 * algorithm, but it is faster. For curves of degree n
90 * the complexity of Horner is O(n) and de Casteljau is O(n^2).
91 * Since stability is not important for displaying curve
92 * points I decided to use the Horner scheme.
94 * A cubic Bezier curve with control points b0, b1, b2, b3 can be
97 * (([3] [3] ) [3] ) [3]
98 * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
101 * where s=1-t and the binomial coefficients [i]. These can
102 * be computed iteratively using the identity:
105 * [i] = (n-i+1)/i * [i-1] and [0] = 1
110 horner_bezier_curve(const GLfloat
*cp
, GLfloat
*out
, GLfloat t
,
111 GLuint dim
, GLuint order
)
114 GLuint i
, k
, bincoeff
;
122 out
[k
] = s
*cp
[k
] + bincoeff
*t
*cp
[dim
+k
];
124 for(i
=2, cp
+=2*dim
, powert
=t
*t
; i
<order
; i
++, powert
*=t
, cp
+=dim
)
127 bincoeff
*= inv_tab
[i
];
130 out
[k
] = s
*out
[k
] + bincoeff
*powert
*cp
[k
];
133 else /* order=1 -> constant curve */
141 * Tensor product Bezier surfaces
143 * Again the Horner scheme is used to compute a point on a
144 * TP Bezier surface. First a control polygon for a curve
145 * on the surface in one parameter direction is computed,
146 * then the point on the curve for the other parameter
147 * direction is evaluated.
149 * To store the curve control polygon additional storage
150 * for max(uorder,vorder) points is needed in the
155 horner_bezier_surf(GLfloat
*cn
, GLfloat
*out
, GLfloat u
, GLfloat v
,
156 GLuint dim
, GLuint uorder
, GLuint vorder
)
158 GLfloat
*cp
= cn
+ uorder
*vorder
*dim
;
159 GLuint i
, uinc
= vorder
*dim
;
166 GLuint j
, k
, bincoeff
;
168 /* Compute the control polygon for the surface-curve in u-direction */
169 for(j
=0; j
<vorder
; j
++)
171 GLfloat
*ucp
= &cn
[j
*dim
];
173 /* Each control point is the point for parameter u on a */
174 /* curve defined by the control polygons in u-direction */
179 cp
[j
*dim
+k
] = s
*ucp
[k
] + bincoeff
*u
*ucp
[uinc
+k
];
181 for(i
=2, ucp
+=2*uinc
, poweru
=u
*u
; i
<uorder
;
182 i
++, poweru
*=u
, ucp
+=uinc
)
184 bincoeff
*= uorder
-i
;
185 bincoeff
*= inv_tab
[i
];
188 cp
[j
*dim
+k
] = s
*cp
[j
*dim
+k
] + bincoeff
*poweru
*ucp
[k
];
192 /* Evaluate curve point in v */
193 horner_bezier_curve(cp
, out
, v
, dim
, vorder
);
195 else /* uorder=1 -> cn defines a curve in v */
196 horner_bezier_curve(cn
, out
, v
, dim
, vorder
);
198 else /* vorder <= uorder */
204 /* Compute the control polygon for the surface-curve in u-direction */
205 for(i
=0; i
<uorder
; i
++, cn
+= uinc
)
207 /* For constant i all cn[i][j] (j=0..vorder) are located */
208 /* on consecutive memory locations, so we can use */
209 /* horner_bezier_curve to compute the control points */
211 horner_bezier_curve(cn
, &cp
[i
*dim
], v
, dim
, vorder
);
214 /* Evaluate curve point in u */
215 horner_bezier_curve(cp
, out
, u
, dim
, uorder
);
217 else /* vorder=1 -> cn defines a curve in u */
218 horner_bezier_curve(cn
, out
, u
, dim
, uorder
);
223 * The direct de Casteljau algorithm is used when a point on the
224 * surface and the tangent directions spanning the tangent plane
225 * should be computed (this is needed to compute normals to the
226 * surface). In this case the de Casteljau algorithm approach is
227 * nicer because a point and the partial derivatives can be computed
228 * at the same time. To get the correct tangent length du and dv
229 * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
230 * Since only the directions are needed, this scaling step is omitted.
232 * De Casteljau needs additional storage for uorder*vorder
233 * values in the control net cn.
237 de_casteljau_surf(GLfloat
*cn
, GLfloat
*out
, GLfloat
*du
, GLfloat
*dv
,
238 GLfloat u
, GLfloat v
, GLuint dim
,
239 GLuint uorder
, GLuint vorder
)
241 GLfloat
*dcn
= cn
+ uorder
*vorder
*dim
;
242 GLfloat us
= 1.0-u
, vs
= 1.0-v
;
244 GLuint minorder
= uorder
< vorder
? uorder
: vorder
;
245 GLuint uinc
= vorder
*dim
;
246 GLuint dcuinc
= vorder
;
248 /* Each component is evaluated separately to save buffer space */
249 /* This does not drasticaly decrease the performance of the */
250 /* algorithm. If additional storage for (uorder-1)*(vorder-1) */
251 /* points would be available, the components could be accessed */
252 /* in the innermost loop which could lead to less cache misses. */
254 #define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)]
255 #define DCN(I, J) dcn[(I)*dcuinc+(J)]
262 /* Derivative direction in u */
263 du
[k
] = vs
*(CN(1,0,k
) - CN(0,0,k
)) +
264 v
*(CN(1,1,k
) - CN(0,1,k
));
266 /* Derivative direction in v */
267 dv
[k
] = us
*(CN(0,1,k
) - CN(0,0,k
)) +
268 u
*(CN(1,1,k
) - CN(1,0,k
));
270 /* bilinear de Casteljau step */
271 out
[k
] = us
*(vs
*CN(0,0,k
) + v
*CN(0,1,k
)) +
272 u
*(vs
*CN(1,0,k
) + v
*CN(1,1,k
));
275 else if(minorder
== uorder
)
279 /* bilinear de Casteljau step */
280 DCN(1,0) = CN(1,0,k
) - CN(0,0,k
);
281 DCN(0,0) = us
*CN(0,0,k
) + u
*CN(1,0,k
);
283 for(j
=0; j
<vorder
-1; j
++)
285 /* for the derivative in u */
286 DCN(1,j
+1) = CN(1,j
+1,k
) - CN(0,j
+1,k
);
287 DCN(1,j
) = vs
*DCN(1,j
) + v
*DCN(1,j
+1);
289 /* for the `point' */
290 DCN(0,j
+1) = us
*CN(0,j
+1,k
) + u
*CN(1,j
+1,k
);
291 DCN(0,j
) = vs
*DCN(0,j
) + v
*DCN(0,j
+1);
294 /* remaining linear de Casteljau steps until the second last step */
295 for(h
=minorder
; h
<vorder
-1; h
++)
296 for(j
=0; j
<vorder
-h
; j
++)
298 /* for the derivative in u */
299 DCN(1,j
) = vs
*DCN(1,j
) + v
*DCN(1,j
+1);
301 /* for the `point' */
302 DCN(0,j
) = vs
*DCN(0,j
) + v
*DCN(0,j
+1);
305 /* derivative direction in v */
306 dv
[k
] = DCN(0,1) - DCN(0,0);
308 /* derivative direction in u */
309 du
[k
] = vs
*DCN(1,0) + v
*DCN(1,1);
311 /* last linear de Casteljau step */
312 out
[k
] = vs
*DCN(0,0) + v
*DCN(0,1);
315 else /* minorder == vorder */
319 /* bilinear de Casteljau step */
320 DCN(0,1) = CN(0,1,k
) - CN(0,0,k
);
321 DCN(0,0) = vs
*CN(0,0,k
) + v
*CN(0,1,k
);
322 for(i
=0; i
<uorder
-1; i
++)
324 /* for the derivative in v */
325 DCN(i
+1,1) = CN(i
+1,1,k
) - CN(i
+1,0,k
);
326 DCN(i
,1) = us
*DCN(i
,1) + u
*DCN(i
+1,1);
328 /* for the `point' */
329 DCN(i
+1,0) = vs
*CN(i
+1,0,k
) + v
*CN(i
+1,1,k
);
330 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
333 /* remaining linear de Casteljau steps until the second last step */
334 for(h
=minorder
; h
<uorder
-1; h
++)
335 for(i
=0; i
<uorder
-h
; i
++)
337 /* for the derivative in v */
338 DCN(i
,1) = us
*DCN(i
,1) + u
*DCN(i
+1,1);
340 /* for the `point' */
341 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
344 /* derivative direction in u */
345 du
[k
] = DCN(1,0) - DCN(0,0);
347 /* derivative direction in v */
348 dv
[k
] = us
*DCN(0,1) + u
*DCN(1,1);
350 /* last linear de Casteljau step */
351 out
[k
] = us
*DCN(0,0) + u
*DCN(1,0);
355 else if(uorder
== vorder
)
359 /* first bilinear de Casteljau step */
360 for(i
=0; i
<uorder
-1; i
++)
362 DCN(i
,0) = us
*CN(i
,0,k
) + u
*CN(i
+1,0,k
);
363 for(j
=0; j
<vorder
-1; j
++)
365 DCN(i
,j
+1) = us
*CN(i
,j
+1,k
) + u
*CN(i
+1,j
+1,k
);
366 DCN(i
,j
) = vs
*DCN(i
,j
) + v
*DCN(i
,j
+1);
370 /* remaining bilinear de Casteljau steps until the second last step */
371 for(h
=2; h
<minorder
-1; h
++)
372 for(i
=0; i
<uorder
-h
; i
++)
374 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
375 for(j
=0; j
<vorder
-h
; j
++)
377 DCN(i
,j
+1) = us
*DCN(i
,j
+1) + u
*DCN(i
+1,j
+1);
378 DCN(i
,j
) = vs
*DCN(i
,j
) + v
*DCN(i
,j
+1);
382 /* derivative direction in u */
383 du
[k
] = vs
*(DCN(1,0) - DCN(0,0)) +
384 v
*(DCN(1,1) - DCN(0,1));
386 /* derivative direction in v */
387 dv
[k
] = us
*(DCN(0,1) - DCN(0,0)) +
388 u
*(DCN(1,1) - DCN(1,0));
390 /* last bilinear de Casteljau step */
391 out
[k
] = us
*(vs
*DCN(0,0) + v
*DCN(0,1)) +
392 u
*(vs
*DCN(1,0) + v
*DCN(1,1));
395 else if(minorder
== uorder
)
399 /* first bilinear de Casteljau step */
400 for(i
=0; i
<uorder
-1; i
++)
402 DCN(i
,0) = us
*CN(i
,0,k
) + u
*CN(i
+1,0,k
);
403 for(j
=0; j
<vorder
-1; j
++)
405 DCN(i
,j
+1) = us
*CN(i
,j
+1,k
) + u
*CN(i
+1,j
+1,k
);
406 DCN(i
,j
) = vs
*DCN(i
,j
) + v
*DCN(i
,j
+1);
410 /* remaining bilinear de Casteljau steps until the second last step */
411 for(h
=2; h
<minorder
-1; h
++)
412 for(i
=0; i
<uorder
-h
; i
++)
414 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
415 for(j
=0; j
<vorder
-h
; j
++)
417 DCN(i
,j
+1) = us
*DCN(i
,j
+1) + u
*DCN(i
+1,j
+1);
418 DCN(i
,j
) = vs
*DCN(i
,j
) + v
*DCN(i
,j
+1);
422 /* last bilinear de Casteljau step */
423 DCN(2,0) = DCN(1,0) - DCN(0,0);
424 DCN(0,0) = us
*DCN(0,0) + u
*DCN(1,0);
425 for(j
=0; j
<vorder
-1; j
++)
427 /* for the derivative in u */
428 DCN(2,j
+1) = DCN(1,j
+1) - DCN(0,j
+1);
429 DCN(2,j
) = vs
*DCN(2,j
) + v
*DCN(2,j
+1);
431 /* for the `point' */
432 DCN(0,j
+1) = us
*DCN(0,j
+1 ) + u
*DCN(1,j
+1);
433 DCN(0,j
) = vs
*DCN(0,j
) + v
*DCN(0,j
+1);
436 /* remaining linear de Casteljau steps until the second last step */
437 for(h
=minorder
; h
<vorder
-1; h
++)
438 for(j
=0; j
<vorder
-h
; j
++)
440 /* for the derivative in u */
441 DCN(2,j
) = vs
*DCN(2,j
) + v
*DCN(2,j
+1);
443 /* for the `point' */
444 DCN(0,j
) = vs
*DCN(0,j
) + v
*DCN(0,j
+1);
447 /* derivative direction in v */
448 dv
[k
] = DCN(0,1) - DCN(0,0);
450 /* derivative direction in u */
451 du
[k
] = vs
*DCN(2,0) + v
*DCN(2,1);
453 /* last linear de Casteljau step */
454 out
[k
] = vs
*DCN(0,0) + v
*DCN(0,1);
457 else /* minorder == vorder */
461 /* first bilinear de Casteljau step */
462 for(i
=0; i
<uorder
-1; i
++)
464 DCN(i
,0) = us
*CN(i
,0,k
) + u
*CN(i
+1,0,k
);
465 for(j
=0; j
<vorder
-1; j
++)
467 DCN(i
,j
+1) = us
*CN(i
,j
+1,k
) + u
*CN(i
+1,j
+1,k
);
468 DCN(i
,j
) = vs
*DCN(i
,j
) + v
*DCN(i
,j
+1);
472 /* remaining bilinear de Casteljau steps until the second last step */
473 for(h
=2; h
<minorder
-1; h
++)
474 for(i
=0; i
<uorder
-h
; i
++)
476 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
477 for(j
=0; j
<vorder
-h
; j
++)
479 DCN(i
,j
+1) = us
*DCN(i
,j
+1) + u
*DCN(i
+1,j
+1);
480 DCN(i
,j
) = vs
*DCN(i
,j
) + v
*DCN(i
,j
+1);
484 /* last bilinear de Casteljau step */
485 DCN(0,2) = DCN(0,1) - DCN(0,0);
486 DCN(0,0) = vs
*DCN(0,0) + v
*DCN(0,1);
487 for(i
=0; i
<uorder
-1; i
++)
489 /* for the derivative in v */
490 DCN(i
+1,2) = DCN(i
+1,1) - DCN(i
+1,0);
491 DCN(i
,2) = us
*DCN(i
,2) + u
*DCN(i
+1,2);
493 /* for the `point' */
494 DCN(i
+1,0) = vs
*DCN(i
+1,0) + v
*DCN(i
+1,1);
495 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
498 /* remaining linear de Casteljau steps until the second last step */
499 for(h
=minorder
; h
<uorder
-1; h
++)
500 for(i
=0; i
<uorder
-h
; i
++)
502 /* for the derivative in v */
503 DCN(i
,2) = us
*DCN(i
,2) + u
*DCN(i
+1,2);
505 /* for the `point' */
506 DCN(i
,0) = us
*DCN(i
,0) + u
*DCN(i
+1,0);
509 /* derivative direction in u */
510 du
[k
] = DCN(1,0) - DCN(0,0);
512 /* derivative direction in v */
513 dv
[k
] = us
*DCN(0,2) + u
*DCN(1,2);
515 /* last linear de Casteljau step */
516 out
[k
] = us
*DCN(0,0) + u
*DCN(1,0);
524 * Return the number of components per control point for any type of
525 * evaluator. Return 0 if bad target.
526 * See table 5.1 in the OpenGL 1.2 spec.
528 GLuint
_mesa_evaluator_components( GLenum target
)
531 case GL_MAP1_VERTEX_3
: return 3;
532 case GL_MAP1_VERTEX_4
: return 4;
533 case GL_MAP1_INDEX
: return 1;
534 case GL_MAP1_COLOR_4
: return 4;
535 case GL_MAP1_NORMAL
: return 3;
536 case GL_MAP1_TEXTURE_COORD_1
: return 1;
537 case GL_MAP1_TEXTURE_COORD_2
: return 2;
538 case GL_MAP1_TEXTURE_COORD_3
: return 3;
539 case GL_MAP1_TEXTURE_COORD_4
: return 4;
540 case GL_MAP2_VERTEX_3
: return 3;
541 case GL_MAP2_VERTEX_4
: return 4;
542 case GL_MAP2_INDEX
: return 1;
543 case GL_MAP2_COLOR_4
: return 4;
544 case GL_MAP2_NORMAL
: return 3;
545 case GL_MAP2_TEXTURE_COORD_1
: return 1;
546 case GL_MAP2_TEXTURE_COORD_2
: return 2;
547 case GL_MAP2_TEXTURE_COORD_3
: return 3;
548 case GL_MAP2_TEXTURE_COORD_4
: return 4;
554 /**********************************************************************/
555 /*** Copy and deallocate control points ***/
556 /**********************************************************************/
560 * Copy 1-parametric evaluator control points from user-specified
561 * memory space to a buffer of contiguous control points.
562 * Input: see glMap1f for details
563 * Return: pointer to buffer of contiguous control points or NULL if out
566 GLfloat
*gl_copy_map_points1f( GLenum target
, GLint ustride
, GLint uorder
,
567 const GLfloat
*points
)
570 GLint i
, k
, size
= _mesa_evaluator_components(target
);
572 if (!points
|| size
==0) {
576 buffer
= (GLfloat
*) MALLOC(uorder
* size
* sizeof(GLfloat
));
579 for(i
=0, p
=buffer
; i
<uorder
; i
++, points
+=ustride
)
580 for(k
=0; k
<size
; k
++)
589 * Same as above but convert doubles to floats.
591 GLfloat
*gl_copy_map_points1d( GLenum target
, GLint ustride
, GLint uorder
,
592 const GLdouble
*points
)
595 GLint i
, k
, size
= _mesa_evaluator_components(target
);
597 if (!points
|| size
==0) {
601 buffer
= (GLfloat
*) MALLOC(uorder
* size
* sizeof(GLfloat
));
604 for(i
=0, p
=buffer
; i
<uorder
; i
++, points
+=ustride
)
605 for(k
=0; k
<size
; k
++)
606 *p
++ = (GLfloat
) points
[k
];
614 * Copy 2-parametric evaluator control points from user-specified
615 * memory space to a buffer of contiguous control points.
616 * Additional memory is allocated to be used by the horner and
617 * de Casteljau evaluation schemes.
619 * Input: see glMap2f for details
620 * Return: pointer to buffer of contiguous control points or NULL if out
623 GLfloat
*gl_copy_map_points2f( GLenum target
,
624 GLint ustride
, GLint uorder
,
625 GLint vstride
, GLint vorder
,
626 const GLfloat
*points
)
629 GLint i
, j
, k
, size
, dsize
, hsize
;
632 size
= _mesa_evaluator_components(target
);
634 if (!points
|| size
==0) {
638 /* max(uorder, vorder) additional points are used in */
639 /* horner evaluation and uorder*vorder additional */
640 /* values are needed for de Casteljau */
641 dsize
= (uorder
== 2 && vorder
== 2)? 0 : uorder
*vorder
;
642 hsize
= (uorder
> vorder
? uorder
: vorder
)*size
;
645 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+hsize
)*sizeof(GLfloat
));
647 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+dsize
)*sizeof(GLfloat
));
649 /* compute the increment value for the u-loop */
650 uinc
= ustride
- vorder
*vstride
;
653 for (i
=0, p
=buffer
; i
<uorder
; i
++, points
+= uinc
)
654 for (j
=0; j
<vorder
; j
++, points
+= vstride
)
655 for (k
=0; k
<size
; k
++)
664 * Same as above but convert doubles to floats.
666 GLfloat
*gl_copy_map_points2d(GLenum target
,
667 GLint ustride
, GLint uorder
,
668 GLint vstride
, GLint vorder
,
669 const GLdouble
*points
)
672 GLint i
, j
, k
, size
, hsize
, dsize
;
675 size
= _mesa_evaluator_components(target
);
677 if (!points
|| size
==0) {
681 /* max(uorder, vorder) additional points are used in */
682 /* horner evaluation and uorder*vorder additional */
683 /* values are needed for de Casteljau */
684 dsize
= (uorder
== 2 && vorder
== 2)? 0 : uorder
*vorder
;
685 hsize
= (uorder
> vorder
? uorder
: vorder
)*size
;
688 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+hsize
)*sizeof(GLfloat
));
690 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+dsize
)*sizeof(GLfloat
));
692 /* compute the increment value for the u-loop */
693 uinc
= ustride
- vorder
*vstride
;
696 for (i
=0, p
=buffer
; i
<uorder
; i
++, points
+= uinc
)
697 for (j
=0; j
<vorder
; j
++, points
+= vstride
)
698 for (k
=0; k
<size
; k
++)
699 *p
++ = (GLfloat
) points
[k
];
707 * This function is called by the display list deallocator function to
708 * specify that a given set of control points are no longer needed.
710 void gl_free_control_points( GLcontext
* ctx
, GLenum target
, GLfloat
*data
)
712 struct gl_1d_map
*map1
= NULL
;
713 struct gl_2d_map
*map2
= NULL
;
716 case GL_MAP1_VERTEX_3
:
717 map1
= &ctx
->EvalMap
.Map1Vertex3
;
719 case GL_MAP1_VERTEX_4
:
720 map1
= &ctx
->EvalMap
.Map1Vertex4
;
723 map1
= &ctx
->EvalMap
.Map1Index
;
725 case GL_MAP1_COLOR_4
:
726 map1
= &ctx
->EvalMap
.Map1Color4
;
729 map1
= &ctx
->EvalMap
.Map1Normal
;
731 case GL_MAP1_TEXTURE_COORD_1
:
732 map1
= &ctx
->EvalMap
.Map1Texture1
;
734 case GL_MAP1_TEXTURE_COORD_2
:
735 map1
= &ctx
->EvalMap
.Map1Texture2
;
737 case GL_MAP1_TEXTURE_COORD_3
:
738 map1
= &ctx
->EvalMap
.Map1Texture3
;
740 case GL_MAP1_TEXTURE_COORD_4
:
741 map1
= &ctx
->EvalMap
.Map1Texture4
;
743 case GL_MAP2_VERTEX_3
:
744 map2
= &ctx
->EvalMap
.Map2Vertex3
;
746 case GL_MAP2_VERTEX_4
:
747 map2
= &ctx
->EvalMap
.Map2Vertex4
;
750 map2
= &ctx
->EvalMap
.Map2Index
;
752 case GL_MAP2_COLOR_4
:
753 map2
= &ctx
->EvalMap
.Map2Color4
;
756 map2
= &ctx
->EvalMap
.Map2Normal
;
758 case GL_MAP2_TEXTURE_COORD_1
:
759 map2
= &ctx
->EvalMap
.Map2Texture1
;
761 case GL_MAP2_TEXTURE_COORD_2
:
762 map2
= &ctx
->EvalMap
.Map2Texture2
;
764 case GL_MAP2_TEXTURE_COORD_3
:
765 map2
= &ctx
->EvalMap
.Map2Texture3
;
767 case GL_MAP2_TEXTURE_COORD_4
:
768 map2
= &ctx
->EvalMap
.Map2Texture4
;
771 gl_error( ctx
, GL_INVALID_ENUM
, "gl_free_control_points" );
776 if (data
==map1
->Points
) {
777 /* The control points in the display list are currently */
778 /* being used so we can mark them as discard-able. */
779 map1
->Retain
= GL_FALSE
;
782 /* The control points in the display list are not currently */
788 if (data
==map2
->Points
) {
789 /* The control points in the display list are currently */
790 /* being used so we can mark them as discard-able. */
791 map2
->Retain
= GL_FALSE
;
794 /* The control points in the display list are not currently */
805 /**********************************************************************/
806 /*** API entry points ***/
807 /**********************************************************************/
811 * This does the work of glMap1[fd].
814 map1(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustride
,
815 GLint uorder
, const GLvoid
*points
, GLenum type
)
817 GET_CURRENT_CONTEXT(ctx
);
821 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glMap1");
823 assert(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
826 gl_error( ctx
, GL_INVALID_VALUE
, "glMap1(u1,u2)" );
829 if (uorder
< 1 || uorder
> MAX_EVAL_ORDER
) {
830 gl_error( ctx
, GL_INVALID_VALUE
, "glMap1(order)" );
834 gl_error( ctx
, GL_INVALID_VALUE
, "glMap1(points)" );
838 k
= _mesa_evaluator_components( target
);
840 gl_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
844 gl_error( ctx
, GL_INVALID_VALUE
, "glMap1(stride)" );
848 /* make copy of the control points */
849 if (type
== GL_FLOAT
)
850 pnts
= gl_copy_map_points1f(target
, ustride
, uorder
, (GLfloat
*) points
);
852 pnts
= gl_copy_map_points1d(target
, ustride
, uorder
, (GLdouble
*) points
);
855 case GL_MAP1_VERTEX_3
:
856 ctx
->EvalMap
.Map1Vertex3
.Order
= uorder
;
857 ctx
->EvalMap
.Map1Vertex3
.u1
= u1
;
858 ctx
->EvalMap
.Map1Vertex3
.u2
= u2
;
859 ctx
->EvalMap
.Map1Vertex3
.du
= 1.0 / (u2
- u1
);
860 if (ctx
->EvalMap
.Map1Vertex3
.Points
)
861 FREE( ctx
->EvalMap
.Map1Vertex3
.Points
);
862 ctx
->EvalMap
.Map1Vertex3
.Points
= pnts
;
864 case GL_MAP1_VERTEX_4
:
865 ctx
->EvalMap
.Map1Vertex4
.Order
= uorder
;
866 ctx
->EvalMap
.Map1Vertex4
.u1
= u1
;
867 ctx
->EvalMap
.Map1Vertex4
.u2
= u2
;
868 ctx
->EvalMap
.Map1Vertex4
.du
= 1.0 / (u2
- u1
);
869 if (ctx
->EvalMap
.Map1Vertex4
.Points
)
870 FREE( ctx
->EvalMap
.Map1Vertex4
.Points
);
871 ctx
->EvalMap
.Map1Vertex4
.Points
= pnts
;
874 ctx
->EvalMap
.Map1Index
.Order
= uorder
;
875 ctx
->EvalMap
.Map1Index
.u1
= u1
;
876 ctx
->EvalMap
.Map1Index
.u2
= u2
;
877 ctx
->EvalMap
.Map1Index
.du
= 1.0 / (u2
- u1
);
878 if (ctx
->EvalMap
.Map1Index
.Points
)
879 FREE( ctx
->EvalMap
.Map1Index
.Points
);
880 ctx
->EvalMap
.Map1Index
.Points
= pnts
;
882 case GL_MAP1_COLOR_4
:
883 ctx
->EvalMap
.Map1Color4
.Order
= uorder
;
884 ctx
->EvalMap
.Map1Color4
.u1
= u1
;
885 ctx
->EvalMap
.Map1Color4
.u2
= u2
;
886 ctx
->EvalMap
.Map1Color4
.du
= 1.0 / (u2
- u1
);
887 if (ctx
->EvalMap
.Map1Color4
.Points
)
888 FREE( ctx
->EvalMap
.Map1Color4
.Points
);
889 ctx
->EvalMap
.Map1Color4
.Points
= pnts
;
892 ctx
->EvalMap
.Map1Normal
.Order
= uorder
;
893 ctx
->EvalMap
.Map1Normal
.u1
= u1
;
894 ctx
->EvalMap
.Map1Normal
.u2
= u2
;
895 ctx
->EvalMap
.Map1Normal
.du
= 1.0 / (u2
- u1
);
896 if (ctx
->EvalMap
.Map1Normal
.Points
)
897 FREE( ctx
->EvalMap
.Map1Normal
.Points
);
898 ctx
->EvalMap
.Map1Normal
.Points
= pnts
;
900 case GL_MAP1_TEXTURE_COORD_1
:
901 ctx
->EvalMap
.Map1Texture1
.Order
= uorder
;
902 ctx
->EvalMap
.Map1Texture1
.u1
= u1
;
903 ctx
->EvalMap
.Map1Texture1
.u2
= u2
;
904 ctx
->EvalMap
.Map1Texture1
.du
= 1.0 / (u2
- u1
);
905 if (ctx
->EvalMap
.Map1Texture1
.Points
)
906 FREE( ctx
->EvalMap
.Map1Texture1
.Points
);
907 ctx
->EvalMap
.Map1Texture1
.Points
= pnts
;
909 case GL_MAP1_TEXTURE_COORD_2
:
910 ctx
->EvalMap
.Map1Texture2
.Order
= uorder
;
911 ctx
->EvalMap
.Map1Texture2
.u1
= u1
;
912 ctx
->EvalMap
.Map1Texture2
.u2
= u2
;
913 ctx
->EvalMap
.Map1Texture2
.du
= 1.0 / (u2
- u1
);
914 if (ctx
->EvalMap
.Map1Texture2
.Points
)
915 FREE( ctx
->EvalMap
.Map1Texture2
.Points
);
916 ctx
->EvalMap
.Map1Texture2
.Points
= pnts
;
918 case GL_MAP1_TEXTURE_COORD_3
:
919 ctx
->EvalMap
.Map1Texture3
.Order
= uorder
;
920 ctx
->EvalMap
.Map1Texture3
.u1
= u1
;
921 ctx
->EvalMap
.Map1Texture3
.u2
= u2
;
922 ctx
->EvalMap
.Map1Texture3
.du
= 1.0 / (u2
- u1
);
923 if (ctx
->EvalMap
.Map1Texture3
.Points
)
924 FREE( ctx
->EvalMap
.Map1Texture3
.Points
);
925 ctx
->EvalMap
.Map1Texture3
.Points
= pnts
;
927 case GL_MAP1_TEXTURE_COORD_4
:
928 ctx
->EvalMap
.Map1Texture4
.Order
= uorder
;
929 ctx
->EvalMap
.Map1Texture4
.u1
= u1
;
930 ctx
->EvalMap
.Map1Texture4
.u2
= u2
;
931 ctx
->EvalMap
.Map1Texture4
.du
= 1.0 / (u2
- u1
);
932 if (ctx
->EvalMap
.Map1Texture4
.Points
)
933 FREE( ctx
->EvalMap
.Map1Texture4
.Points
);
934 ctx
->EvalMap
.Map1Texture4
.Points
= pnts
;
937 gl_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
944 _mesa_Map1f( GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
945 GLint order
, const GLfloat
*points
)
947 map1(target
, u1
, u2
, stride
, order
, points
, GL_FLOAT
);
952 _mesa_Map1d( GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
953 GLint order
, const GLdouble
*points
)
955 map1(target
, u1
, u2
, stride
, order
, points
, GL_DOUBLE
);
960 map2( GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
961 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
962 const GLvoid
*points
, GLenum type
)
964 GET_CURRENT_CONTEXT(ctx
);
968 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glMap2");
971 gl_error( ctx
, GL_INVALID_VALUE
, "glMap2(u1,u2)" );
976 gl_error( ctx
, GL_INVALID_VALUE
, "glMap2(v1,v2)" );
980 if (uorder
<1 || uorder
>MAX_EVAL_ORDER
) {
981 gl_error( ctx
, GL_INVALID_VALUE
, "glMap2(uorder)" );
985 if (vorder
<1 || vorder
>MAX_EVAL_ORDER
) {
986 gl_error( ctx
, GL_INVALID_VALUE
, "glMap2(vorder)" );
990 k
= _mesa_evaluator_components( target
);
992 gl_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
996 gl_error( ctx
, GL_INVALID_VALUE
, "glMap2(ustride)" );
1000 gl_error( ctx
, GL_INVALID_VALUE
, "glMap2(vstride)" );
1004 /* make copy of the control points */
1005 if (type
== GL_FLOAT
)
1006 pnts
= gl_copy_map_points2f(target
, ustride
, uorder
,
1007 vstride
, vorder
, (GLfloat
*) points
);
1009 pnts
= gl_copy_map_points2d(target
, ustride
, uorder
,
1010 vstride
, vorder
, (GLdouble
*) points
);
1013 case GL_MAP2_VERTEX_3
:
1014 ctx
->EvalMap
.Map2Vertex3
.Uorder
= uorder
;
1015 ctx
->EvalMap
.Map2Vertex3
.u1
= u1
;
1016 ctx
->EvalMap
.Map2Vertex3
.u2
= u2
;
1017 ctx
->EvalMap
.Map2Vertex3
.du
= 1.0 / (u2
- u1
);
1018 ctx
->EvalMap
.Map2Vertex3
.Vorder
= vorder
;
1019 ctx
->EvalMap
.Map2Vertex3
.v1
= v1
;
1020 ctx
->EvalMap
.Map2Vertex3
.v2
= v2
;
1021 ctx
->EvalMap
.Map2Vertex3
.dv
= 1.0 / (v2
- v1
);
1022 if (ctx
->EvalMap
.Map2Vertex3
.Points
)
1023 FREE( ctx
->EvalMap
.Map2Vertex3
.Points
);
1024 ctx
->EvalMap
.Map2Vertex3
.Points
= pnts
;
1026 case GL_MAP2_VERTEX_4
:
1027 ctx
->EvalMap
.Map2Vertex4
.Uorder
= uorder
;
1028 ctx
->EvalMap
.Map2Vertex4
.u1
= u1
;
1029 ctx
->EvalMap
.Map2Vertex4
.u2
= u2
;
1030 ctx
->EvalMap
.Map2Vertex4
.du
= 1.0 / (u2
- u1
);
1031 ctx
->EvalMap
.Map2Vertex4
.Vorder
= vorder
;
1032 ctx
->EvalMap
.Map2Vertex4
.v1
= v1
;
1033 ctx
->EvalMap
.Map2Vertex4
.v2
= v2
;
1034 ctx
->EvalMap
.Map2Vertex4
.dv
= 1.0 / (v2
- v1
);
1035 if (ctx
->EvalMap
.Map2Vertex4
.Points
)
1036 FREE( ctx
->EvalMap
.Map2Vertex4
.Points
);
1037 ctx
->EvalMap
.Map2Vertex4
.Points
= pnts
;
1040 ctx
->EvalMap
.Map2Index
.Uorder
= uorder
;
1041 ctx
->EvalMap
.Map2Index
.u1
= u1
;
1042 ctx
->EvalMap
.Map2Index
.u2
= u2
;
1043 ctx
->EvalMap
.Map2Index
.du
= 1.0 / (u2
- u1
);
1044 ctx
->EvalMap
.Map2Index
.Vorder
= vorder
;
1045 ctx
->EvalMap
.Map2Index
.v1
= v1
;
1046 ctx
->EvalMap
.Map2Index
.v2
= v2
;
1047 ctx
->EvalMap
.Map2Index
.dv
= 1.0 / (v2
- v1
);
1048 if (ctx
->EvalMap
.Map2Index
.Points
)
1049 FREE( ctx
->EvalMap
.Map2Index
.Points
);
1050 ctx
->EvalMap
.Map2Index
.Points
= pnts
;
1052 case GL_MAP2_COLOR_4
:
1053 ctx
->EvalMap
.Map2Color4
.Uorder
= uorder
;
1054 ctx
->EvalMap
.Map2Color4
.u1
= u1
;
1055 ctx
->EvalMap
.Map2Color4
.u2
= u2
;
1056 ctx
->EvalMap
.Map2Color4
.du
= 1.0 / (u2
- u1
);
1057 ctx
->EvalMap
.Map2Color4
.Vorder
= vorder
;
1058 ctx
->EvalMap
.Map2Color4
.v1
= v1
;
1059 ctx
->EvalMap
.Map2Color4
.v2
= v2
;
1060 ctx
->EvalMap
.Map2Color4
.dv
= 1.0 / (v2
- v1
);
1061 if (ctx
->EvalMap
.Map2Color4
.Points
)
1062 FREE( ctx
->EvalMap
.Map2Color4
.Points
);
1063 ctx
->EvalMap
.Map2Color4
.Points
= pnts
;
1065 case GL_MAP2_NORMAL
:
1066 ctx
->EvalMap
.Map2Normal
.Uorder
= uorder
;
1067 ctx
->EvalMap
.Map2Normal
.u1
= u1
;
1068 ctx
->EvalMap
.Map2Normal
.u2
= u2
;
1069 ctx
->EvalMap
.Map2Normal
.du
= 1.0 / (u2
- u1
);
1070 ctx
->EvalMap
.Map2Normal
.Vorder
= vorder
;
1071 ctx
->EvalMap
.Map2Normal
.v1
= v1
;
1072 ctx
->EvalMap
.Map2Normal
.v2
= v2
;
1073 ctx
->EvalMap
.Map2Normal
.dv
= 1.0 / (v2
- v1
);
1074 if (ctx
->EvalMap
.Map2Normal
.Points
)
1075 FREE( ctx
->EvalMap
.Map2Normal
.Points
);
1076 ctx
->EvalMap
.Map2Normal
.Points
= pnts
;
1078 case GL_MAP2_TEXTURE_COORD_1
:
1079 ctx
->EvalMap
.Map2Texture1
.Uorder
= uorder
;
1080 ctx
->EvalMap
.Map2Texture1
.u1
= u1
;
1081 ctx
->EvalMap
.Map2Texture1
.u2
= u2
;
1082 ctx
->EvalMap
.Map2Texture1
.du
= 1.0 / (u2
- u1
);
1083 ctx
->EvalMap
.Map2Texture1
.Vorder
= vorder
;
1084 ctx
->EvalMap
.Map2Texture1
.v1
= v1
;
1085 ctx
->EvalMap
.Map2Texture1
.v2
= v2
;
1086 ctx
->EvalMap
.Map2Texture1
.dv
= 1.0 / (v2
- v1
);
1087 if (ctx
->EvalMap
.Map2Texture1
.Points
)
1088 FREE( ctx
->EvalMap
.Map2Texture1
.Points
);
1089 ctx
->EvalMap
.Map2Texture1
.Points
= pnts
;
1091 case GL_MAP2_TEXTURE_COORD_2
:
1092 ctx
->EvalMap
.Map2Texture2
.Uorder
= uorder
;
1093 ctx
->EvalMap
.Map2Texture2
.u1
= u1
;
1094 ctx
->EvalMap
.Map2Texture2
.u2
= u2
;
1095 ctx
->EvalMap
.Map2Texture2
.du
= 1.0 / (u2
- u1
);
1096 ctx
->EvalMap
.Map2Texture2
.Vorder
= vorder
;
1097 ctx
->EvalMap
.Map2Texture2
.v1
= v1
;
1098 ctx
->EvalMap
.Map2Texture2
.v2
= v2
;
1099 ctx
->EvalMap
.Map2Texture2
.dv
= 1.0 / (v2
- v1
);
1100 if (ctx
->EvalMap
.Map2Texture2
.Points
)
1101 FREE( ctx
->EvalMap
.Map2Texture2
.Points
);
1102 ctx
->EvalMap
.Map2Texture2
.Points
= pnts
;
1104 case GL_MAP2_TEXTURE_COORD_3
:
1105 ctx
->EvalMap
.Map2Texture3
.Uorder
= uorder
;
1106 ctx
->EvalMap
.Map2Texture3
.u1
= u1
;
1107 ctx
->EvalMap
.Map2Texture3
.u2
= u2
;
1108 ctx
->EvalMap
.Map2Texture3
.du
= 1.0 / (u2
- u1
);
1109 ctx
->EvalMap
.Map2Texture3
.Vorder
= vorder
;
1110 ctx
->EvalMap
.Map2Texture3
.v1
= v1
;
1111 ctx
->EvalMap
.Map2Texture3
.v2
= v2
;
1112 ctx
->EvalMap
.Map2Texture3
.dv
= 1.0 / (v2
- v1
);
1113 if (ctx
->EvalMap
.Map2Texture3
.Points
)
1114 FREE( ctx
->EvalMap
.Map2Texture3
.Points
);
1115 ctx
->EvalMap
.Map2Texture3
.Points
= pnts
;
1117 case GL_MAP2_TEXTURE_COORD_4
:
1118 ctx
->EvalMap
.Map2Texture4
.Uorder
= uorder
;
1119 ctx
->EvalMap
.Map2Texture4
.u1
= u1
;
1120 ctx
->EvalMap
.Map2Texture4
.u2
= u2
;
1121 ctx
->EvalMap
.Map2Texture4
.du
= 1.0 / (u2
- u1
);
1122 ctx
->EvalMap
.Map2Texture4
.Vorder
= vorder
;
1123 ctx
->EvalMap
.Map2Texture4
.v1
= v1
;
1124 ctx
->EvalMap
.Map2Texture4
.v2
= v2
;
1125 ctx
->EvalMap
.Map2Texture4
.dv
= 1.0 / (v2
- v1
);
1126 if (ctx
->EvalMap
.Map2Texture4
.Points
)
1127 FREE( ctx
->EvalMap
.Map2Texture4
.Points
);
1128 ctx
->EvalMap
.Map2Texture4
.Points
= pnts
;
1131 gl_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
1137 _mesa_Map2f( GLenum target
,
1138 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
1139 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
1140 const GLfloat
*points
)
1142 map2(target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
,
1148 _mesa_Map2d( GLenum target
,
1149 GLdouble u1
, GLdouble u2
, GLint ustride
, GLint uorder
,
1150 GLdouble v1
, GLdouble v2
, GLint vstride
, GLint vorder
,
1151 const GLdouble
*points
)
1153 map2(target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
,
1160 _mesa_GetMapdv( GLenum target
, GLenum query
, GLdouble
*v
)
1162 GET_CURRENT_CONTEXT(ctx
);
1169 case GL_MAP1_COLOR_4
:
1170 data
= ctx
->EvalMap
.Map1Color4
.Points
;
1171 n
= ctx
->EvalMap
.Map1Color4
.Order
* 4;
1174 data
= ctx
->EvalMap
.Map1Index
.Points
;
1175 n
= ctx
->EvalMap
.Map1Index
.Order
;
1177 case GL_MAP1_NORMAL
:
1178 data
= ctx
->EvalMap
.Map1Normal
.Points
;
1179 n
= ctx
->EvalMap
.Map1Normal
.Order
* 3;
1181 case GL_MAP1_TEXTURE_COORD_1
:
1182 data
= ctx
->EvalMap
.Map1Texture1
.Points
;
1183 n
= ctx
->EvalMap
.Map1Texture1
.Order
* 1;
1185 case GL_MAP1_TEXTURE_COORD_2
:
1186 data
= ctx
->EvalMap
.Map1Texture2
.Points
;
1187 n
= ctx
->EvalMap
.Map1Texture2
.Order
* 2;
1189 case GL_MAP1_TEXTURE_COORD_3
:
1190 data
= ctx
->EvalMap
.Map1Texture3
.Points
;
1191 n
= ctx
->EvalMap
.Map1Texture3
.Order
* 3;
1193 case GL_MAP1_TEXTURE_COORD_4
:
1194 data
= ctx
->EvalMap
.Map1Texture4
.Points
;
1195 n
= ctx
->EvalMap
.Map1Texture4
.Order
* 4;
1197 case GL_MAP1_VERTEX_3
:
1198 data
= ctx
->EvalMap
.Map1Vertex3
.Points
;
1199 n
= ctx
->EvalMap
.Map1Vertex3
.Order
* 3;
1201 case GL_MAP1_VERTEX_4
:
1202 data
= ctx
->EvalMap
.Map1Vertex4
.Points
;
1203 n
= ctx
->EvalMap
.Map1Vertex4
.Order
* 4;
1205 case GL_MAP2_COLOR_4
:
1206 data
= ctx
->EvalMap
.Map2Color4
.Points
;
1207 n
= ctx
->EvalMap
.Map2Color4
.Uorder
1208 * ctx
->EvalMap
.Map2Color4
.Vorder
* 4;
1211 data
= ctx
->EvalMap
.Map2Index
.Points
;
1212 n
= ctx
->EvalMap
.Map2Index
.Uorder
1213 * ctx
->EvalMap
.Map2Index
.Vorder
;
1215 case GL_MAP2_NORMAL
:
1216 data
= ctx
->EvalMap
.Map2Normal
.Points
;
1217 n
= ctx
->EvalMap
.Map2Normal
.Uorder
1218 * ctx
->EvalMap
.Map2Normal
.Vorder
* 3;
1220 case GL_MAP2_TEXTURE_COORD_1
:
1221 data
= ctx
->EvalMap
.Map2Texture1
.Points
;
1222 n
= ctx
->EvalMap
.Map2Texture1
.Uorder
1223 * ctx
->EvalMap
.Map2Texture1
.Vorder
* 1;
1225 case GL_MAP2_TEXTURE_COORD_2
:
1226 data
= ctx
->EvalMap
.Map2Texture2
.Points
;
1227 n
= ctx
->EvalMap
.Map2Texture2
.Uorder
1228 * ctx
->EvalMap
.Map2Texture2
.Vorder
* 2;
1230 case GL_MAP2_TEXTURE_COORD_3
:
1231 data
= ctx
->EvalMap
.Map2Texture3
.Points
;
1232 n
= ctx
->EvalMap
.Map2Texture3
.Uorder
1233 * ctx
->EvalMap
.Map2Texture3
.Vorder
* 3;
1235 case GL_MAP2_TEXTURE_COORD_4
:
1236 data
= ctx
->EvalMap
.Map2Texture4
.Points
;
1237 n
= ctx
->EvalMap
.Map2Texture4
.Uorder
1238 * ctx
->EvalMap
.Map2Texture4
.Vorder
* 4;
1240 case GL_MAP2_VERTEX_3
:
1241 data
= ctx
->EvalMap
.Map2Vertex3
.Points
;
1242 n
= ctx
->EvalMap
.Map2Vertex3
.Uorder
1243 * ctx
->EvalMap
.Map2Vertex3
.Vorder
* 3;
1245 case GL_MAP2_VERTEX_4
:
1246 data
= ctx
->EvalMap
.Map2Vertex4
.Points
;
1247 n
= ctx
->EvalMap
.Map2Vertex4
.Uorder
1248 * ctx
->EvalMap
.Map2Vertex4
.Vorder
* 4;
1251 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(target)" );
1262 case GL_MAP1_COLOR_4
:
1263 *v
= ctx
->EvalMap
.Map1Color4
.Order
;
1266 *v
= ctx
->EvalMap
.Map1Index
.Order
;
1268 case GL_MAP1_NORMAL
:
1269 *v
= ctx
->EvalMap
.Map1Normal
.Order
;
1271 case GL_MAP1_TEXTURE_COORD_1
:
1272 *v
= ctx
->EvalMap
.Map1Texture1
.Order
;
1274 case GL_MAP1_TEXTURE_COORD_2
:
1275 *v
= ctx
->EvalMap
.Map1Texture2
.Order
;
1277 case GL_MAP1_TEXTURE_COORD_3
:
1278 *v
= ctx
->EvalMap
.Map1Texture3
.Order
;
1280 case GL_MAP1_TEXTURE_COORD_4
:
1281 *v
= ctx
->EvalMap
.Map1Texture4
.Order
;
1283 case GL_MAP1_VERTEX_3
:
1284 *v
= ctx
->EvalMap
.Map1Vertex3
.Order
;
1286 case GL_MAP1_VERTEX_4
:
1287 *v
= ctx
->EvalMap
.Map1Vertex4
.Order
;
1289 case GL_MAP2_COLOR_4
:
1290 v
[0] = ctx
->EvalMap
.Map2Color4
.Uorder
;
1291 v
[1] = ctx
->EvalMap
.Map2Color4
.Vorder
;
1294 v
[0] = ctx
->EvalMap
.Map2Index
.Uorder
;
1295 v
[1] = ctx
->EvalMap
.Map2Index
.Vorder
;
1297 case GL_MAP2_NORMAL
:
1298 v
[0] = ctx
->EvalMap
.Map2Normal
.Uorder
;
1299 v
[1] = ctx
->EvalMap
.Map2Normal
.Vorder
;
1301 case GL_MAP2_TEXTURE_COORD_1
:
1302 v
[0] = ctx
->EvalMap
.Map2Texture1
.Uorder
;
1303 v
[1] = ctx
->EvalMap
.Map2Texture1
.Vorder
;
1305 case GL_MAP2_TEXTURE_COORD_2
:
1306 v
[0] = ctx
->EvalMap
.Map2Texture2
.Uorder
;
1307 v
[1] = ctx
->EvalMap
.Map2Texture2
.Vorder
;
1309 case GL_MAP2_TEXTURE_COORD_3
:
1310 v
[0] = ctx
->EvalMap
.Map2Texture3
.Uorder
;
1311 v
[1] = ctx
->EvalMap
.Map2Texture3
.Vorder
;
1313 case GL_MAP2_TEXTURE_COORD_4
:
1314 v
[0] = ctx
->EvalMap
.Map2Texture4
.Uorder
;
1315 v
[1] = ctx
->EvalMap
.Map2Texture4
.Vorder
;
1317 case GL_MAP2_VERTEX_3
:
1318 v
[0] = ctx
->EvalMap
.Map2Vertex3
.Uorder
;
1319 v
[1] = ctx
->EvalMap
.Map2Vertex3
.Vorder
;
1321 case GL_MAP2_VERTEX_4
:
1322 v
[0] = ctx
->EvalMap
.Map2Vertex4
.Uorder
;
1323 v
[1] = ctx
->EvalMap
.Map2Vertex4
.Vorder
;
1326 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(target)" );
1332 case GL_MAP1_COLOR_4
:
1333 v
[0] = ctx
->EvalMap
.Map1Color4
.u1
;
1334 v
[1] = ctx
->EvalMap
.Map1Color4
.u2
;
1337 v
[0] = ctx
->EvalMap
.Map1Index
.u1
;
1338 v
[1] = ctx
->EvalMap
.Map1Index
.u2
;
1340 case GL_MAP1_NORMAL
:
1341 v
[0] = ctx
->EvalMap
.Map1Normal
.u1
;
1342 v
[1] = ctx
->EvalMap
.Map1Normal
.u2
;
1344 case GL_MAP1_TEXTURE_COORD_1
:
1345 v
[0] = ctx
->EvalMap
.Map1Texture1
.u1
;
1346 v
[1] = ctx
->EvalMap
.Map1Texture1
.u2
;
1348 case GL_MAP1_TEXTURE_COORD_2
:
1349 v
[0] = ctx
->EvalMap
.Map1Texture2
.u1
;
1350 v
[1] = ctx
->EvalMap
.Map1Texture2
.u2
;
1352 case GL_MAP1_TEXTURE_COORD_3
:
1353 v
[0] = ctx
->EvalMap
.Map1Texture3
.u1
;
1354 v
[1] = ctx
->EvalMap
.Map1Texture3
.u2
;
1356 case GL_MAP1_TEXTURE_COORD_4
:
1357 v
[0] = ctx
->EvalMap
.Map1Texture4
.u1
;
1358 v
[1] = ctx
->EvalMap
.Map1Texture4
.u2
;
1360 case GL_MAP1_VERTEX_3
:
1361 v
[0] = ctx
->EvalMap
.Map1Vertex3
.u1
;
1362 v
[1] = ctx
->EvalMap
.Map1Vertex3
.u2
;
1364 case GL_MAP1_VERTEX_4
:
1365 v
[0] = ctx
->EvalMap
.Map1Vertex4
.u1
;
1366 v
[1] = ctx
->EvalMap
.Map1Vertex4
.u2
;
1368 case GL_MAP2_COLOR_4
:
1369 v
[0] = ctx
->EvalMap
.Map2Color4
.u1
;
1370 v
[1] = ctx
->EvalMap
.Map2Color4
.u2
;
1371 v
[2] = ctx
->EvalMap
.Map2Color4
.v1
;
1372 v
[3] = ctx
->EvalMap
.Map2Color4
.v2
;
1375 v
[0] = ctx
->EvalMap
.Map2Index
.u1
;
1376 v
[1] = ctx
->EvalMap
.Map2Index
.u2
;
1377 v
[2] = ctx
->EvalMap
.Map2Index
.v1
;
1378 v
[3] = ctx
->EvalMap
.Map2Index
.v2
;
1380 case GL_MAP2_NORMAL
:
1381 v
[0] = ctx
->EvalMap
.Map2Normal
.u1
;
1382 v
[1] = ctx
->EvalMap
.Map2Normal
.u2
;
1383 v
[2] = ctx
->EvalMap
.Map2Normal
.v1
;
1384 v
[3] = ctx
->EvalMap
.Map2Normal
.v2
;
1386 case GL_MAP2_TEXTURE_COORD_1
:
1387 v
[0] = ctx
->EvalMap
.Map2Texture1
.u1
;
1388 v
[1] = ctx
->EvalMap
.Map2Texture1
.u2
;
1389 v
[2] = ctx
->EvalMap
.Map2Texture1
.v1
;
1390 v
[3] = ctx
->EvalMap
.Map2Texture1
.v2
;
1392 case GL_MAP2_TEXTURE_COORD_2
:
1393 v
[0] = ctx
->EvalMap
.Map2Texture2
.u1
;
1394 v
[1] = ctx
->EvalMap
.Map2Texture2
.u2
;
1395 v
[2] = ctx
->EvalMap
.Map2Texture2
.v1
;
1396 v
[3] = ctx
->EvalMap
.Map2Texture2
.v2
;
1398 case GL_MAP2_TEXTURE_COORD_3
:
1399 v
[0] = ctx
->EvalMap
.Map2Texture3
.u1
;
1400 v
[1] = ctx
->EvalMap
.Map2Texture3
.u2
;
1401 v
[2] = ctx
->EvalMap
.Map2Texture3
.v1
;
1402 v
[3] = ctx
->EvalMap
.Map2Texture3
.v2
;
1404 case GL_MAP2_TEXTURE_COORD_4
:
1405 v
[0] = ctx
->EvalMap
.Map2Texture4
.u1
;
1406 v
[1] = ctx
->EvalMap
.Map2Texture4
.u2
;
1407 v
[2] = ctx
->EvalMap
.Map2Texture4
.v1
;
1408 v
[3] = ctx
->EvalMap
.Map2Texture4
.v2
;
1410 case GL_MAP2_VERTEX_3
:
1411 v
[0] = ctx
->EvalMap
.Map2Vertex3
.u1
;
1412 v
[1] = ctx
->EvalMap
.Map2Vertex3
.u2
;
1413 v
[2] = ctx
->EvalMap
.Map2Vertex3
.v1
;
1414 v
[3] = ctx
->EvalMap
.Map2Vertex3
.v2
;
1416 case GL_MAP2_VERTEX_4
:
1417 v
[0] = ctx
->EvalMap
.Map2Vertex4
.u1
;
1418 v
[1] = ctx
->EvalMap
.Map2Vertex4
.u2
;
1419 v
[2] = ctx
->EvalMap
.Map2Vertex4
.v1
;
1420 v
[3] = ctx
->EvalMap
.Map2Vertex4
.v2
;
1423 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(target)" );
1427 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(query)" );
1433 _mesa_GetMapfv( GLenum target
, GLenum query
, GLfloat
*v
)
1435 GET_CURRENT_CONTEXT(ctx
);
1442 case GL_MAP1_COLOR_4
:
1443 data
= ctx
->EvalMap
.Map1Color4
.Points
;
1444 n
= ctx
->EvalMap
.Map1Color4
.Order
* 4;
1447 data
= ctx
->EvalMap
.Map1Index
.Points
;
1448 n
= ctx
->EvalMap
.Map1Index
.Order
;
1450 case GL_MAP1_NORMAL
:
1451 data
= ctx
->EvalMap
.Map1Normal
.Points
;
1452 n
= ctx
->EvalMap
.Map1Normal
.Order
* 3;
1454 case GL_MAP1_TEXTURE_COORD_1
:
1455 data
= ctx
->EvalMap
.Map1Texture1
.Points
;
1456 n
= ctx
->EvalMap
.Map1Texture1
.Order
* 1;
1458 case GL_MAP1_TEXTURE_COORD_2
:
1459 data
= ctx
->EvalMap
.Map1Texture2
.Points
;
1460 n
= ctx
->EvalMap
.Map1Texture2
.Order
* 2;
1462 case GL_MAP1_TEXTURE_COORD_3
:
1463 data
= ctx
->EvalMap
.Map1Texture3
.Points
;
1464 n
= ctx
->EvalMap
.Map1Texture3
.Order
* 3;
1466 case GL_MAP1_TEXTURE_COORD_4
:
1467 data
= ctx
->EvalMap
.Map1Texture4
.Points
;
1468 n
= ctx
->EvalMap
.Map1Texture4
.Order
* 4;
1470 case GL_MAP1_VERTEX_3
:
1471 data
= ctx
->EvalMap
.Map1Vertex3
.Points
;
1472 n
= ctx
->EvalMap
.Map1Vertex3
.Order
* 3;
1474 case GL_MAP1_VERTEX_4
:
1475 data
= ctx
->EvalMap
.Map1Vertex4
.Points
;
1476 n
= ctx
->EvalMap
.Map1Vertex4
.Order
* 4;
1478 case GL_MAP2_COLOR_4
:
1479 data
= ctx
->EvalMap
.Map2Color4
.Points
;
1480 n
= ctx
->EvalMap
.Map2Color4
.Uorder
1481 * ctx
->EvalMap
.Map2Color4
.Vorder
* 4;
1484 data
= ctx
->EvalMap
.Map2Index
.Points
;
1485 n
= ctx
->EvalMap
.Map2Index
.Uorder
1486 * ctx
->EvalMap
.Map2Index
.Vorder
;
1488 case GL_MAP2_NORMAL
:
1489 data
= ctx
->EvalMap
.Map2Normal
.Points
;
1490 n
= ctx
->EvalMap
.Map2Normal
.Uorder
1491 * ctx
->EvalMap
.Map2Normal
.Vorder
* 3;
1493 case GL_MAP2_TEXTURE_COORD_1
:
1494 data
= ctx
->EvalMap
.Map2Texture1
.Points
;
1495 n
= ctx
->EvalMap
.Map2Texture1
.Uorder
1496 * ctx
->EvalMap
.Map2Texture1
.Vorder
* 1;
1498 case GL_MAP2_TEXTURE_COORD_2
:
1499 data
= ctx
->EvalMap
.Map2Texture2
.Points
;
1500 n
= ctx
->EvalMap
.Map2Texture2
.Uorder
1501 * ctx
->EvalMap
.Map2Texture2
.Vorder
* 2;
1503 case GL_MAP2_TEXTURE_COORD_3
:
1504 data
= ctx
->EvalMap
.Map2Texture3
.Points
;
1505 n
= ctx
->EvalMap
.Map2Texture3
.Uorder
1506 * ctx
->EvalMap
.Map2Texture3
.Vorder
* 3;
1508 case GL_MAP2_TEXTURE_COORD_4
:
1509 data
= ctx
->EvalMap
.Map2Texture4
.Points
;
1510 n
= ctx
->EvalMap
.Map2Texture4
.Uorder
1511 * ctx
->EvalMap
.Map2Texture4
.Vorder
* 4;
1513 case GL_MAP2_VERTEX_3
:
1514 data
= ctx
->EvalMap
.Map2Vertex3
.Points
;
1515 n
= ctx
->EvalMap
.Map2Vertex3
.Uorder
1516 * ctx
->EvalMap
.Map2Vertex3
.Vorder
* 3;
1518 case GL_MAP2_VERTEX_4
:
1519 data
= ctx
->EvalMap
.Map2Vertex4
.Points
;
1520 n
= ctx
->EvalMap
.Map2Vertex4
.Uorder
1521 * ctx
->EvalMap
.Map2Vertex4
.Vorder
* 4;
1524 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(target)" );
1535 case GL_MAP1_COLOR_4
:
1536 *v
= ctx
->EvalMap
.Map1Color4
.Order
;
1539 *v
= ctx
->EvalMap
.Map1Index
.Order
;
1541 case GL_MAP1_NORMAL
:
1542 *v
= ctx
->EvalMap
.Map1Normal
.Order
;
1544 case GL_MAP1_TEXTURE_COORD_1
:
1545 *v
= ctx
->EvalMap
.Map1Texture1
.Order
;
1547 case GL_MAP1_TEXTURE_COORD_2
:
1548 *v
= ctx
->EvalMap
.Map1Texture2
.Order
;
1550 case GL_MAP1_TEXTURE_COORD_3
:
1551 *v
= ctx
->EvalMap
.Map1Texture3
.Order
;
1553 case GL_MAP1_TEXTURE_COORD_4
:
1554 *v
= ctx
->EvalMap
.Map1Texture4
.Order
;
1556 case GL_MAP1_VERTEX_3
:
1557 *v
= ctx
->EvalMap
.Map1Vertex3
.Order
;
1559 case GL_MAP1_VERTEX_4
:
1560 *v
= ctx
->EvalMap
.Map1Vertex4
.Order
;
1562 case GL_MAP2_COLOR_4
:
1563 v
[0] = ctx
->EvalMap
.Map2Color4
.Uorder
;
1564 v
[1] = ctx
->EvalMap
.Map2Color4
.Vorder
;
1567 v
[0] = ctx
->EvalMap
.Map2Index
.Uorder
;
1568 v
[1] = ctx
->EvalMap
.Map2Index
.Vorder
;
1570 case GL_MAP2_NORMAL
:
1571 v
[0] = ctx
->EvalMap
.Map2Normal
.Uorder
;
1572 v
[1] = ctx
->EvalMap
.Map2Normal
.Vorder
;
1574 case GL_MAP2_TEXTURE_COORD_1
:
1575 v
[0] = ctx
->EvalMap
.Map2Texture1
.Uorder
;
1576 v
[1] = ctx
->EvalMap
.Map2Texture1
.Vorder
;
1578 case GL_MAP2_TEXTURE_COORD_2
:
1579 v
[0] = ctx
->EvalMap
.Map2Texture2
.Uorder
;
1580 v
[1] = ctx
->EvalMap
.Map2Texture2
.Vorder
;
1582 case GL_MAP2_TEXTURE_COORD_3
:
1583 v
[0] = ctx
->EvalMap
.Map2Texture3
.Uorder
;
1584 v
[1] = ctx
->EvalMap
.Map2Texture3
.Vorder
;
1586 case GL_MAP2_TEXTURE_COORD_4
:
1587 v
[0] = ctx
->EvalMap
.Map2Texture4
.Uorder
;
1588 v
[1] = ctx
->EvalMap
.Map2Texture4
.Vorder
;
1590 case GL_MAP2_VERTEX_3
:
1591 v
[0] = ctx
->EvalMap
.Map2Vertex3
.Uorder
;
1592 v
[1] = ctx
->EvalMap
.Map2Vertex3
.Vorder
;
1594 case GL_MAP2_VERTEX_4
:
1595 v
[0] = ctx
->EvalMap
.Map2Vertex4
.Uorder
;
1596 v
[1] = ctx
->EvalMap
.Map2Vertex4
.Vorder
;
1599 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(target)" );
1605 case GL_MAP1_COLOR_4
:
1606 v
[0] = ctx
->EvalMap
.Map1Color4
.u1
;
1607 v
[1] = ctx
->EvalMap
.Map1Color4
.u2
;
1610 v
[0] = ctx
->EvalMap
.Map1Index
.u1
;
1611 v
[1] = ctx
->EvalMap
.Map1Index
.u2
;
1613 case GL_MAP1_NORMAL
:
1614 v
[0] = ctx
->EvalMap
.Map1Normal
.u1
;
1615 v
[1] = ctx
->EvalMap
.Map1Normal
.u2
;
1617 case GL_MAP1_TEXTURE_COORD_1
:
1618 v
[0] = ctx
->EvalMap
.Map1Texture1
.u1
;
1619 v
[1] = ctx
->EvalMap
.Map1Texture1
.u2
;
1621 case GL_MAP1_TEXTURE_COORD_2
:
1622 v
[0] = ctx
->EvalMap
.Map1Texture2
.u1
;
1623 v
[1] = ctx
->EvalMap
.Map1Texture2
.u2
;
1625 case GL_MAP1_TEXTURE_COORD_3
:
1626 v
[0] = ctx
->EvalMap
.Map1Texture3
.u1
;
1627 v
[1] = ctx
->EvalMap
.Map1Texture3
.u2
;
1629 case GL_MAP1_TEXTURE_COORD_4
:
1630 v
[0] = ctx
->EvalMap
.Map1Texture4
.u1
;
1631 v
[1] = ctx
->EvalMap
.Map1Texture4
.u2
;
1633 case GL_MAP1_VERTEX_3
:
1634 v
[0] = ctx
->EvalMap
.Map1Vertex3
.u1
;
1635 v
[1] = ctx
->EvalMap
.Map1Vertex3
.u2
;
1637 case GL_MAP1_VERTEX_4
:
1638 v
[0] = ctx
->EvalMap
.Map1Vertex4
.u1
;
1639 v
[1] = ctx
->EvalMap
.Map1Vertex4
.u2
;
1641 case GL_MAP2_COLOR_4
:
1642 v
[0] = ctx
->EvalMap
.Map2Color4
.u1
;
1643 v
[1] = ctx
->EvalMap
.Map2Color4
.u2
;
1644 v
[2] = ctx
->EvalMap
.Map2Color4
.v1
;
1645 v
[3] = ctx
->EvalMap
.Map2Color4
.v2
;
1648 v
[0] = ctx
->EvalMap
.Map2Index
.u1
;
1649 v
[1] = ctx
->EvalMap
.Map2Index
.u2
;
1650 v
[2] = ctx
->EvalMap
.Map2Index
.v1
;
1651 v
[3] = ctx
->EvalMap
.Map2Index
.v2
;
1653 case GL_MAP2_NORMAL
:
1654 v
[0] = ctx
->EvalMap
.Map2Normal
.u1
;
1655 v
[1] = ctx
->EvalMap
.Map2Normal
.u2
;
1656 v
[2] = ctx
->EvalMap
.Map2Normal
.v1
;
1657 v
[3] = ctx
->EvalMap
.Map2Normal
.v2
;
1659 case GL_MAP2_TEXTURE_COORD_1
:
1660 v
[0] = ctx
->EvalMap
.Map2Texture1
.u1
;
1661 v
[1] = ctx
->EvalMap
.Map2Texture1
.u2
;
1662 v
[2] = ctx
->EvalMap
.Map2Texture1
.v1
;
1663 v
[3] = ctx
->EvalMap
.Map2Texture1
.v2
;
1665 case GL_MAP2_TEXTURE_COORD_2
:
1666 v
[0] = ctx
->EvalMap
.Map2Texture2
.u1
;
1667 v
[1] = ctx
->EvalMap
.Map2Texture2
.u2
;
1668 v
[2] = ctx
->EvalMap
.Map2Texture2
.v1
;
1669 v
[3] = ctx
->EvalMap
.Map2Texture2
.v2
;
1671 case GL_MAP2_TEXTURE_COORD_3
:
1672 v
[0] = ctx
->EvalMap
.Map2Texture3
.u1
;
1673 v
[1] = ctx
->EvalMap
.Map2Texture3
.u2
;
1674 v
[2] = ctx
->EvalMap
.Map2Texture3
.v1
;
1675 v
[3] = ctx
->EvalMap
.Map2Texture3
.v2
;
1677 case GL_MAP2_TEXTURE_COORD_4
:
1678 v
[0] = ctx
->EvalMap
.Map2Texture4
.u1
;
1679 v
[1] = ctx
->EvalMap
.Map2Texture4
.u2
;
1680 v
[2] = ctx
->EvalMap
.Map2Texture4
.v1
;
1681 v
[3] = ctx
->EvalMap
.Map2Texture4
.v2
;
1683 case GL_MAP2_VERTEX_3
:
1684 v
[0] = ctx
->EvalMap
.Map2Vertex3
.u1
;
1685 v
[1] = ctx
->EvalMap
.Map2Vertex3
.u2
;
1686 v
[2] = ctx
->EvalMap
.Map2Vertex3
.v1
;
1687 v
[3] = ctx
->EvalMap
.Map2Vertex3
.v2
;
1689 case GL_MAP2_VERTEX_4
:
1690 v
[0] = ctx
->EvalMap
.Map2Vertex4
.u1
;
1691 v
[1] = ctx
->EvalMap
.Map2Vertex4
.u2
;
1692 v
[2] = ctx
->EvalMap
.Map2Vertex4
.v1
;
1693 v
[3] = ctx
->EvalMap
.Map2Vertex4
.v2
;
1696 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(target)" );
1700 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(query)" );
1706 _mesa_GetMapiv( GLenum target
, GLenum query
, GLint
*v
)
1708 GET_CURRENT_CONTEXT(ctx
);
1715 case GL_MAP1_COLOR_4
:
1716 data
= ctx
->EvalMap
.Map1Color4
.Points
;
1717 n
= ctx
->EvalMap
.Map1Color4
.Order
* 4;
1720 data
= ctx
->EvalMap
.Map1Index
.Points
;
1721 n
= ctx
->EvalMap
.Map1Index
.Order
;
1723 case GL_MAP1_NORMAL
:
1724 data
= ctx
->EvalMap
.Map1Normal
.Points
;
1725 n
= ctx
->EvalMap
.Map1Normal
.Order
* 3;
1727 case GL_MAP1_TEXTURE_COORD_1
:
1728 data
= ctx
->EvalMap
.Map1Texture1
.Points
;
1729 n
= ctx
->EvalMap
.Map1Texture1
.Order
* 1;
1731 case GL_MAP1_TEXTURE_COORD_2
:
1732 data
= ctx
->EvalMap
.Map1Texture2
.Points
;
1733 n
= ctx
->EvalMap
.Map1Texture2
.Order
* 2;
1735 case GL_MAP1_TEXTURE_COORD_3
:
1736 data
= ctx
->EvalMap
.Map1Texture3
.Points
;
1737 n
= ctx
->EvalMap
.Map1Texture3
.Order
* 3;
1739 case GL_MAP1_TEXTURE_COORD_4
:
1740 data
= ctx
->EvalMap
.Map1Texture4
.Points
;
1741 n
= ctx
->EvalMap
.Map1Texture4
.Order
* 4;
1743 case GL_MAP1_VERTEX_3
:
1744 data
= ctx
->EvalMap
.Map1Vertex3
.Points
;
1745 n
= ctx
->EvalMap
.Map1Vertex3
.Order
* 3;
1747 case GL_MAP1_VERTEX_4
:
1748 data
= ctx
->EvalMap
.Map1Vertex4
.Points
;
1749 n
= ctx
->EvalMap
.Map1Vertex4
.Order
* 4;
1751 case GL_MAP2_COLOR_4
:
1752 data
= ctx
->EvalMap
.Map2Color4
.Points
;
1753 n
= ctx
->EvalMap
.Map2Color4
.Uorder
1754 * ctx
->EvalMap
.Map2Color4
.Vorder
* 4;
1757 data
= ctx
->EvalMap
.Map2Index
.Points
;
1758 n
= ctx
->EvalMap
.Map2Index
.Uorder
1759 * ctx
->EvalMap
.Map2Index
.Vorder
;
1761 case GL_MAP2_NORMAL
:
1762 data
= ctx
->EvalMap
.Map2Normal
.Points
;
1763 n
= ctx
->EvalMap
.Map2Normal
.Uorder
1764 * ctx
->EvalMap
.Map2Normal
.Vorder
* 3;
1766 case GL_MAP2_TEXTURE_COORD_1
:
1767 data
= ctx
->EvalMap
.Map2Texture1
.Points
;
1768 n
= ctx
->EvalMap
.Map2Texture1
.Uorder
1769 * ctx
->EvalMap
.Map2Texture1
.Vorder
* 1;
1771 case GL_MAP2_TEXTURE_COORD_2
:
1772 data
= ctx
->EvalMap
.Map2Texture2
.Points
;
1773 n
= ctx
->EvalMap
.Map2Texture2
.Uorder
1774 * ctx
->EvalMap
.Map2Texture2
.Vorder
* 2;
1776 case GL_MAP2_TEXTURE_COORD_3
:
1777 data
= ctx
->EvalMap
.Map2Texture3
.Points
;
1778 n
= ctx
->EvalMap
.Map2Texture3
.Uorder
1779 * ctx
->EvalMap
.Map2Texture3
.Vorder
* 3;
1781 case GL_MAP2_TEXTURE_COORD_4
:
1782 data
= ctx
->EvalMap
.Map2Texture4
.Points
;
1783 n
= ctx
->EvalMap
.Map2Texture4
.Uorder
1784 * ctx
->EvalMap
.Map2Texture4
.Vorder
* 4;
1786 case GL_MAP2_VERTEX_3
:
1787 data
= ctx
->EvalMap
.Map2Vertex3
.Points
;
1788 n
= ctx
->EvalMap
.Map2Vertex3
.Uorder
1789 * ctx
->EvalMap
.Map2Vertex3
.Vorder
* 3;
1791 case GL_MAP2_VERTEX_4
:
1792 data
= ctx
->EvalMap
.Map2Vertex4
.Points
;
1793 n
= ctx
->EvalMap
.Map2Vertex4
.Uorder
1794 * ctx
->EvalMap
.Map2Vertex4
.Vorder
* 4;
1797 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(target)" );
1802 v
[i
] = ROUNDF(data
[i
]);
1808 case GL_MAP1_COLOR_4
:
1809 *v
= ctx
->EvalMap
.Map1Color4
.Order
;
1812 *v
= ctx
->EvalMap
.Map1Index
.Order
;
1814 case GL_MAP1_NORMAL
:
1815 *v
= ctx
->EvalMap
.Map1Normal
.Order
;
1817 case GL_MAP1_TEXTURE_COORD_1
:
1818 *v
= ctx
->EvalMap
.Map1Texture1
.Order
;
1820 case GL_MAP1_TEXTURE_COORD_2
:
1821 *v
= ctx
->EvalMap
.Map1Texture2
.Order
;
1823 case GL_MAP1_TEXTURE_COORD_3
:
1824 *v
= ctx
->EvalMap
.Map1Texture3
.Order
;
1826 case GL_MAP1_TEXTURE_COORD_4
:
1827 *v
= ctx
->EvalMap
.Map1Texture4
.Order
;
1829 case GL_MAP1_VERTEX_3
:
1830 *v
= ctx
->EvalMap
.Map1Vertex3
.Order
;
1832 case GL_MAP1_VERTEX_4
:
1833 *v
= ctx
->EvalMap
.Map1Vertex4
.Order
;
1835 case GL_MAP2_COLOR_4
:
1836 v
[0] = ctx
->EvalMap
.Map2Color4
.Uorder
;
1837 v
[1] = ctx
->EvalMap
.Map2Color4
.Vorder
;
1840 v
[0] = ctx
->EvalMap
.Map2Index
.Uorder
;
1841 v
[1] = ctx
->EvalMap
.Map2Index
.Vorder
;
1843 case GL_MAP2_NORMAL
:
1844 v
[0] = ctx
->EvalMap
.Map2Normal
.Uorder
;
1845 v
[1] = ctx
->EvalMap
.Map2Normal
.Vorder
;
1847 case GL_MAP2_TEXTURE_COORD_1
:
1848 v
[0] = ctx
->EvalMap
.Map2Texture1
.Uorder
;
1849 v
[1] = ctx
->EvalMap
.Map2Texture1
.Vorder
;
1851 case GL_MAP2_TEXTURE_COORD_2
:
1852 v
[0] = ctx
->EvalMap
.Map2Texture2
.Uorder
;
1853 v
[1] = ctx
->EvalMap
.Map2Texture2
.Vorder
;
1855 case GL_MAP2_TEXTURE_COORD_3
:
1856 v
[0] = ctx
->EvalMap
.Map2Texture3
.Uorder
;
1857 v
[1] = ctx
->EvalMap
.Map2Texture3
.Vorder
;
1859 case GL_MAP2_TEXTURE_COORD_4
:
1860 v
[0] = ctx
->EvalMap
.Map2Texture4
.Uorder
;
1861 v
[1] = ctx
->EvalMap
.Map2Texture4
.Vorder
;
1863 case GL_MAP2_VERTEX_3
:
1864 v
[0] = ctx
->EvalMap
.Map2Vertex3
.Uorder
;
1865 v
[1] = ctx
->EvalMap
.Map2Vertex3
.Vorder
;
1867 case GL_MAP2_VERTEX_4
:
1868 v
[0] = ctx
->EvalMap
.Map2Vertex4
.Uorder
;
1869 v
[1] = ctx
->EvalMap
.Map2Vertex4
.Vorder
;
1872 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(target)" );
1878 case GL_MAP1_COLOR_4
:
1879 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Color4
.u1
);
1880 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Color4
.u2
);
1883 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Index
.u1
);
1884 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Index
.u2
);
1886 case GL_MAP1_NORMAL
:
1887 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Normal
.u1
);
1888 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Normal
.u2
);
1890 case GL_MAP1_TEXTURE_COORD_1
:
1891 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Texture1
.u1
);
1892 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Texture1
.u2
);
1894 case GL_MAP1_TEXTURE_COORD_2
:
1895 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Texture2
.u1
);
1896 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Texture2
.u2
);
1898 case GL_MAP1_TEXTURE_COORD_3
:
1899 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Texture3
.u1
);
1900 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Texture3
.u2
);
1902 case GL_MAP1_TEXTURE_COORD_4
:
1903 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Texture4
.u1
);
1904 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Texture4
.u2
);
1906 case GL_MAP1_VERTEX_3
:
1907 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Vertex3
.u1
);
1908 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Vertex3
.u2
);
1910 case GL_MAP1_VERTEX_4
:
1911 v
[0] = ROUNDF(ctx
->EvalMap
.Map1Vertex4
.u1
);
1912 v
[1] = ROUNDF(ctx
->EvalMap
.Map1Vertex4
.u2
);
1914 case GL_MAP2_COLOR_4
:
1915 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Color4
.u1
);
1916 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Color4
.u2
);
1917 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Color4
.v1
);
1918 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Color4
.v2
);
1921 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Index
.u1
);
1922 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Index
.u2
);
1923 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Index
.v1
);
1924 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Index
.v2
);
1926 case GL_MAP2_NORMAL
:
1927 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Normal
.u1
);
1928 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Normal
.u2
);
1929 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Normal
.v1
);
1930 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Normal
.v2
);
1932 case GL_MAP2_TEXTURE_COORD_1
:
1933 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Texture1
.u1
);
1934 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Texture1
.u2
);
1935 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Texture1
.v1
);
1936 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Texture1
.v2
);
1938 case GL_MAP2_TEXTURE_COORD_2
:
1939 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Texture2
.u1
);
1940 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Texture2
.u2
);
1941 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Texture2
.v1
);
1942 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Texture2
.v2
);
1944 case GL_MAP2_TEXTURE_COORD_3
:
1945 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Texture3
.u1
);
1946 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Texture3
.u2
);
1947 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Texture3
.v1
);
1948 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Texture3
.v2
);
1950 case GL_MAP2_TEXTURE_COORD_4
:
1951 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Texture4
.u1
);
1952 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Texture4
.u2
);
1953 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Texture4
.v1
);
1954 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Texture4
.v2
);
1956 case GL_MAP2_VERTEX_3
:
1957 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Vertex3
.u1
);
1958 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Vertex3
.u2
);
1959 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Vertex3
.v1
);
1960 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Vertex3
.v2
);
1962 case GL_MAP2_VERTEX_4
:
1963 v
[0] = ROUNDF(ctx
->EvalMap
.Map2Vertex4
.u1
);
1964 v
[1] = ROUNDF(ctx
->EvalMap
.Map2Vertex4
.u2
);
1965 v
[2] = ROUNDF(ctx
->EvalMap
.Map2Vertex4
.v1
);
1966 v
[3] = ROUNDF(ctx
->EvalMap
.Map2Vertex4
.v2
);
1969 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(target)" );
1973 gl_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(query)" );
1979 static void eval_points1( GLfloat outcoord
[][4],
1981 const GLuint
*flags
,
1983 GLfloat du
, GLfloat u1
)
1986 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
1987 if (flags
[i
] & VERT_EVAL_P1
)
1988 outcoord
[i
][0] = coord
[i
][0] * du
+ u1
;
1989 else if (flags
[i
] & VERT_EVAL_ANY
) {
1990 outcoord
[i
][0] = coord
[i
][0];
1991 outcoord
[i
][1] = coord
[i
][1];
1995 static void eval_points2( GLfloat outcoord
[][4],
1997 const GLuint
*flags
,
1999 GLfloat du
, GLfloat u1
,
2000 GLfloat dv
, GLfloat v1
)
2003 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2004 if (flags
[i
] & VERT_EVAL_P2
) {
2005 outcoord
[i
][0] = coord
[i
][0] * du
+ u1
;
2006 outcoord
[i
][1] = coord
[i
][1] * dv
+ v1
;
2007 } else if (flags
[i
] & VERT_EVAL_ANY
) {
2008 outcoord
[i
][0] = coord
[i
][0];
2009 outcoord
[i
][1] = coord
[i
][1];
2014 static const GLubyte dirty_flags
[5] = {
2015 0, /* not possible */
2023 static GLvector4f
*eval1_4f( GLvector4f
*dest
,
2025 const GLuint
*flags
,
2028 struct gl_1d_map
*map
)
2030 const GLfloat u1
= map
->u1
;
2031 const GLfloat du
= map
->du
;
2032 GLfloat (*to
)[4] = dest
->data
;
2035 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2036 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
2037 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2038 ASSIGN_4V(to
[i
], 0,0,0,1);
2039 horner_bezier_curve(map
->Points
, to
[i
], u
, dimension
, map
->Order
);
2043 dest
->start
= VEC_ELT(dest
, GLfloat
, start
);
2044 dest
->size
= MAX2(dest
->size
, dimension
);
2045 dest
->flags
|= dirty_flags
[dimension
];
2050 static GLvector1ui
*eval1_1ui( GLvector1ui
*dest
,
2052 const GLuint
*flags
,
2054 struct gl_1d_map
*map
)
2056 const GLfloat u1
= map
->u1
;
2057 const GLfloat du
= map
->du
;
2058 GLuint
*to
= dest
->data
;
2061 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2062 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
2063 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2065 horner_bezier_curve(map
->Points
, &tmp
, u
, 1, map
->Order
);
2066 to
[i
] = (GLuint
) (GLint
) tmp
;
2069 dest
->start
= VEC_ELT(dest
, GLuint
, start
);
2074 static GLvector3f
*eval1_norm( GLvector3f
*dest
,
2076 GLuint
*flags
, /* not const */
2078 struct gl_1d_map
*map
)
2080 const GLfloat u1
= map
->u1
;
2081 const GLfloat du
= map
->du
;
2082 GLfloat (*to
)[3] = dest
->data
;
2085 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2086 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
2087 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2088 horner_bezier_curve(map
->Points
, to
[i
], u
, 3, map
->Order
);
2089 flags
[i
+1] |= VERT_NORM
; /* reset */
2092 dest
->start
= VEC_ELT(dest
, GLfloat
, start
);
2097 static GLvector4ub
*eval1_color( GLvector4ub
*dest
,
2099 GLuint
*flags
, /* not const */
2101 struct gl_1d_map
*map
)
2103 const GLfloat u1
= map
->u1
;
2104 const GLfloat du
= map
->du
;
2105 GLubyte (*to
)[4] = dest
->data
;
2108 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2109 if (flags
[i
] & (VERT_EVAL_C1
|VERT_EVAL_P1
)) {
2110 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2112 horner_bezier_curve(map
->Points
, fcolor
, u
, 4, map
->Order
);
2113 FLOAT_RGBA_TO_UBYTE_RGBA(to
[i
], fcolor
);
2114 flags
[i
+1] |= VERT_RGBA
; /* reset */
2117 dest
->start
= VEC_ELT(dest
, GLubyte
, start
);
2125 static GLvector4f
*eval2_obj_norm( GLvector4f
*obj_ptr
,
2126 GLvector3f
*norm_ptr
,
2131 struct gl_2d_map
*map
)
2133 const GLfloat u1
= map
->u1
;
2134 const GLfloat du
= map
->du
;
2135 const GLfloat v1
= map
->v1
;
2136 const GLfloat dv
= map
->dv
;
2137 GLfloat (*obj
)[4] = obj_ptr
->data
;
2138 GLfloat (*normal
)[3] = norm_ptr
->data
;
2141 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2142 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
2143 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2144 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
2145 GLfloat du
[4], dv
[4];
2147 ASSIGN_4V(obj
[i
], 0,0,0,1);
2148 de_casteljau_surf(map
->Points
, obj
[i
], du
, dv
, u
, v
, dimension
,
2149 map
->Uorder
, map
->Vorder
);
2151 CROSS3(normal
[i
], du
, dv
);
2152 NORMALIZE_3FV(normal
[i
]);
2153 flags
[i
+1] |= VERT_NORM
;
2156 obj_ptr
->start
= VEC_ELT(obj_ptr
, GLfloat
, start
);
2158 obj_ptr
->size
= MAX2(obj_ptr
->size
, dimension
);
2159 obj_ptr
->flags
|= dirty_flags
[dimension
];
2164 static GLvector4f
*eval2_4f( GLvector4f
*dest
,
2166 const GLuint
*flags
,
2169 struct gl_2d_map
*map
)
2171 const GLfloat u1
= map
->u1
;
2172 const GLfloat du
= map
->du
;
2173 const GLfloat v1
= map
->v1
;
2174 const GLfloat dv
= map
->dv
;
2175 GLfloat (*to
)[4] = dest
->data
;
2178 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2179 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
2180 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2181 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
2182 horner_bezier_surf(map
->Points
, to
[i
], u
, v
, dimension
,
2183 map
->Uorder
, map
->Vorder
);
2186 dest
->start
= VEC_ELT(dest
, GLfloat
, start
);
2188 dest
->size
= MAX2(dest
->size
, dimension
);
2189 dest
->flags
|= dirty_flags
[dimension
];
2194 static GLvector3f
*eval2_norm( GLvector3f
*dest
,
2198 struct gl_2d_map
*map
)
2200 const GLfloat u1
= map
->u1
;
2201 const GLfloat du
= map
->du
;
2202 const GLfloat v1
= map
->v1
;
2203 const GLfloat dv
= map
->dv
;
2204 GLfloat (*to
)[3] = dest
->data
;
2207 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2208 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
2209 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2210 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
2211 horner_bezier_surf(map
->Points
, to
[i
], u
, v
, 3,
2212 map
->Uorder
, map
->Vorder
);
2213 flags
[i
+1] |= VERT_NORM
; /* reset */
2216 dest
->start
= VEC_ELT(dest
, GLfloat
, start
);
2222 static GLvector1ui
*eval2_1ui( GLvector1ui
*dest
,
2224 const GLuint
*flags
,
2226 struct gl_2d_map
*map
)
2228 const GLfloat u1
= map
->u1
;
2229 const GLfloat du
= map
->du
;
2230 const GLfloat v1
= map
->v1
;
2231 const GLfloat dv
= map
->dv
;
2232 GLuint
*to
= dest
->data
;
2235 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2236 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
2237 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2238 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
2240 horner_bezier_surf(map
->Points
, &tmp
, u
, v
, 1,
2241 map
->Uorder
, map
->Vorder
);
2243 to
[i
] = (GLuint
) (GLint
) tmp
;
2246 dest
->start
= VEC_ELT(dest
, GLuint
, start
);
2253 static GLvector4ub
*eval2_color( GLvector4ub
*dest
,
2257 struct gl_2d_map
*map
)
2259 const GLfloat u1
= map
->u1
;
2260 const GLfloat du
= map
->du
;
2261 const GLfloat v1
= map
->v1
;
2262 const GLfloat dv
= map
->dv
;
2263 GLubyte (*to
)[4] = dest
->data
;
2266 for (i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2267 if (flags
[i
] & (VERT_EVAL_C2
|VERT_EVAL_P2
)) {
2268 GLfloat u
= (coord
[i
][0] - u1
) * du
;
2269 GLfloat v
= (coord
[i
][1] - v1
) * dv
;
2271 horner_bezier_surf(map
->Points
, fcolor
, u
, v
, 4,
2272 map
->Uorder
, map
->Vorder
);
2273 FLOAT_RGBA_TO_UBYTE_RGBA(to
[i
], fcolor
);
2274 flags
[i
+1] |= VERT_RGBA
; /* reset */
2277 dest
->start
= VEC_ELT(dest
, GLubyte
, start
);
2283 static GLvector4f
*copy_4f( GLvector4f
*out
, CONST GLvector4f
*in
,
2284 const GLuint
*flags
,
2287 GLfloat (*to
)[4] = out
->data
;
2288 GLfloat (*from
)[4] = in
->data
;
2291 for ( i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2292 if (!(flags
[i
] & VERT_EVAL_ANY
))
2293 COPY_4FV( to
[i
], from
[i
] );
2295 out
->start
= VEC_ELT(out
, GLfloat
, start
);
2299 static GLvector3f
*copy_3f( GLvector3f
*out
, CONST GLvector3f
*in
,
2300 const GLuint
*flags
,
2303 GLfloat (*to
)[3] = out
->data
;
2304 GLfloat (*from
)[3] = in
->data
;
2307 for ( i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2308 if (!(flags
[i
] & VERT_EVAL_ANY
))
2309 COPY_3V( to
[i
], from
[i
] );
2311 out
->start
= VEC_ELT(out
, GLfloat
, start
);
2315 static GLvector4ub
*copy_4ub( GLvector4ub
*out
,
2316 CONST GLvector4ub
*in
,
2317 const GLuint
*flags
,
2320 GLubyte (*to
)[4] = out
->data
;
2321 GLubyte (*from
)[4] = in
->data
;
2324 for ( i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2325 if (!(flags
[i
] & VERT_EVAL_ANY
))
2326 COPY_4UBV( to
[i
], from
[i
] );
2328 out
->start
= VEC_ELT(out
, GLubyte
, start
);
2332 static GLvector1ui
*copy_1ui( GLvector1ui
*out
,
2333 CONST GLvector1ui
*in
,
2334 const GLuint
*flags
,
2337 GLuint
*to
= out
->data
;
2338 CONST GLuint
*from
= in
->data
;
2341 for ( i
= start
; !(flags
[i
] & VERT_END_VB
) ; i
++)
2342 if (!(flags
[i
] & VERT_EVAL_ANY
))
2345 out
->start
= VEC_ELT(out
, GLuint
, start
);
2350 /* KW: Rewrote this to perform eval on a whole buffer at once.
2351 * Only evaluates active data items, and avoids scribbling
2352 * the source buffer if we are running from a display list.
2354 * If the user (in this case looser) sends eval coordinates
2355 * or runs a display list containing eval coords with no
2356 * vertex maps enabled, we have to either copy all non-eval
2357 * data to a new buffer, or find a way of working around
2358 * the eval data. I choose the second option.
2360 * KW: This code not reached by cva - use IM to access storage.
2362 void gl_eval_vb( struct vertex_buffer
*VB
)
2364 struct immediate
*IM
= VB
->IM
;
2365 GLcontext
*ctx
= VB
->ctx
;
2366 GLuint req
= ctx
->CVA
.elt
.inputs
;
2367 GLfloat (*coord
)[4] = VB
->ObjPtr
->data
;
2368 GLuint
*flags
= VB
->Flag
;
2369 GLuint new_flags
= 0;
2372 GLuint any_eval1
= VB
->OrFlag
& (VERT_EVAL_C1
|VERT_EVAL_P1
);
2373 GLuint any_eval2
= VB
->OrFlag
& (VERT_EVAL_C2
|VERT_EVAL_P2
);
2374 GLuint all_eval
= IM
->AndFlag
& VERT_EVAL_ANY
;
2376 /* Handle the degenerate cases.
2378 if (any_eval1
&& !ctx
->Eval
.Map1Vertex4
&& !ctx
->Eval
.Map1Vertex3
) {
2379 VB
->PurgeFlags
|= (VERT_EVAL_C1
|VERT_EVAL_P1
);
2381 any_eval1
= GL_FALSE
;
2384 if (any_eval2
&& !ctx
->Eval
.Map2Vertex4
&& !ctx
->Eval
.Map2Vertex3
) {
2385 VB
->PurgeFlags
|= (VERT_EVAL_C2
|VERT_EVAL_P2
);
2387 any_eval2
= GL_FALSE
;
2390 /* KW: This really is a degenerate case - doing this disables
2391 * culling, and causes dummy values for the missing vertices to be
2392 * transformed and clip tested. It also forces the individual
2393 * cliptesting of each primitive in vb_render. I wish there was a
2394 * nice alternative, but I can't say I want to put effort into
2395 * optimizing such a bad usage of the library - I'd much rather
2396 * work on useful changes.
2398 if (VB
->PurgeFlags
) {
2399 if (!any_eval1
&& !any_eval2
&& all_eval
) VB
->Count
= VB
->Start
;
2400 gl_purge_vertices( VB
);
2401 if (!any_eval1
&& !any_eval2
) return;
2403 VB
->IndirectCount
= VB
->Count
;
2405 /* Translate points into coords.
2407 if (any_eval1
&& (VB
->OrFlag
& VERT_EVAL_P1
))
2409 eval_points1( IM
->Obj
, coord
, flags
, IM
->Start
,
2410 ctx
->Eval
.MapGrid1du
,
2411 ctx
->Eval
.MapGrid1u1
);
2416 if (any_eval2
&& (VB
->OrFlag
& VERT_EVAL_P2
))
2418 eval_points2( IM
->Obj
, coord
, flags
, IM
->Start
,
2419 ctx
->Eval
.MapGrid2du
,
2420 ctx
->Eval
.MapGrid2u1
,
2421 ctx
->Eval
.MapGrid2dv
,
2422 ctx
->Eval
.MapGrid2v1
);
2427 /* Perform the evaluations on active data elements.
2429 if (req
& VERT_INDEX
)
2431 GLvector1ui
*in_index
= VB
->IndexPtr
;
2432 GLvector1ui
*out_index
= &IM
->v
.Index
;
2434 if (ctx
->Eval
.Map1Index
&& any_eval1
)
2435 VB
->IndexPtr
= eval1_1ui( out_index
, coord
, flags
, IM
->Start
,
2436 &ctx
->EvalMap
.Map1Index
);
2438 if (ctx
->Eval
.Map2Index
&& any_eval2
)
2439 VB
->IndexPtr
= eval2_1ui( out_index
, coord
, flags
, IM
->Start
,
2440 &ctx
->EvalMap
.Map2Index
);
2442 if (VB
->IndexPtr
!= in_index
) {
2443 new_flags
|= VERT_INDEX
;
2445 VB
->IndexPtr
= copy_1ui( out_index
, in_index
, flags
, IM
->Start
);
2449 if (req
& VERT_RGBA
)
2451 GLvector4ub
*in_color
= VB
->ColorPtr
;
2452 GLvector4ub
*out_color
= &IM
->v
.Color
;
2454 if (ctx
->Eval
.Map1Color4
&& any_eval1
)
2455 VB
->ColorPtr
= eval1_color( out_color
, coord
, flags
, IM
->Start
,
2456 &ctx
->EvalMap
.Map1Color4
);
2458 if (ctx
->Eval
.Map2Color4
&& any_eval2
)
2459 VB
->ColorPtr
= eval2_color( out_color
, coord
, flags
, IM
->Start
,
2460 &ctx
->EvalMap
.Map2Color4
);
2462 if (VB
->ColorPtr
!= in_color
) {
2463 new_flags
|= VERT_RGBA
;
2465 VB
->ColorPtr
= copy_4ub( out_color
, in_color
, flags
, IM
->Start
);
2468 VB
->Color
[0] = VB
->Color
[1] = VB
->ColorPtr
;
2472 if (req
& VERT_NORM
)
2474 GLvector3f
*in_normal
= VB
->NormalPtr
;
2475 GLvector3f
*out_normal
= &IM
->v
.Normal
;
2477 if (ctx
->Eval
.Map1Normal
&& any_eval1
)
2478 VB
->NormalPtr
= eval1_norm( out_normal
, coord
, flags
, IM
->Start
,
2479 &ctx
->EvalMap
.Map1Normal
);
2481 if (ctx
->Eval
.Map2Normal
&& any_eval2
)
2482 VB
->NormalPtr
= eval2_norm( out_normal
, coord
, flags
, IM
->Start
,
2483 &ctx
->EvalMap
.Map2Normal
);
2485 if (VB
->NormalPtr
!= in_normal
) {
2486 new_flags
|= VERT_NORM
;
2488 VB
->NormalPtr
= copy_3f( out_normal
, in_normal
, flags
, IM
->Start
);
2493 if (req
& VERT_TEX_ANY(0))
2495 GLvector4f
*tc
= VB
->TexCoordPtr
[0];
2496 GLvector4f
*in
= tc
;
2497 GLvector4f
*out
= &IM
->v
.TexCoord
[0];
2500 if (ctx
->Eval
.Map1TextureCoord4
)
2501 tc
= eval1_4f( out
, coord
, flags
, IM
->Start
,
2502 4, &ctx
->EvalMap
.Map1Texture4
);
2503 else if (ctx
->Eval
.Map1TextureCoord3
)
2504 tc
= eval1_4f( out
, coord
, flags
, IM
->Start
, 3,
2505 &ctx
->EvalMap
.Map1Texture3
);
2506 else if (ctx
->Eval
.Map1TextureCoord2
)
2507 tc
= eval1_4f( out
, coord
, flags
, IM
->Start
, 2,
2508 &ctx
->EvalMap
.Map1Texture2
);
2509 else if (ctx
->Eval
.Map1TextureCoord1
)
2510 tc
= eval1_4f( out
, coord
, flags
, IM
->Start
, 1,
2511 &ctx
->EvalMap
.Map1Texture1
);
2515 if (ctx
->Eval
.Map2TextureCoord4
)
2516 tc
= eval2_4f( out
, coord
, flags
, IM
->Start
,
2517 4, &ctx
->EvalMap
.Map2Texture4
);
2518 else if (ctx
->Eval
.Map2TextureCoord3
)
2519 tc
= eval2_4f( out
, coord
, flags
, IM
->Start
,
2520 3, &ctx
->EvalMap
.Map2Texture3
);
2521 else if (ctx
->Eval
.Map2TextureCoord2
)
2522 tc
= eval2_4f( out
, coord
, flags
, IM
->Start
,
2523 2, &ctx
->EvalMap
.Map2Texture2
);
2524 else if (ctx
->Eval
.Map2TextureCoord1
)
2525 tc
= eval2_4f( out
, coord
, flags
, IM
->Start
,
2526 1, &ctx
->EvalMap
.Map2Texture1
);
2530 new_flags
|= VERT_TEX_ANY(0); /* fix for sizes.. */
2532 tc
= copy_4f( out
, in
, flags
, IM
->Start
);
2535 VB
->TexCoordPtr
[0] = tc
;
2540 GLvector4f
*in
= VB
->ObjPtr
;
2541 GLvector4f
*out
= &IM
->v
.Obj
;
2542 GLvector4f
*obj
= in
;
2545 if (ctx
->Eval
.Map1Vertex4
)
2546 obj
= eval1_4f( out
, coord
, flags
, IM
->Start
,
2547 4, &ctx
->EvalMap
.Map1Vertex4
);
2549 obj
= eval1_4f( out
, coord
, flags
, IM
->Start
,
2550 3, &ctx
->EvalMap
.Map1Vertex3
);
2554 if (ctx
->Eval
.Map2Vertex4
)
2556 if (ctx
->Eval
.AutoNormal
&& (req
& VERT_NORM
))
2557 obj
= eval2_obj_norm( out
, VB
->NormalPtr
, coord
, flags
, IM
->Start
,
2558 4, &ctx
->EvalMap
.Map2Vertex4
);
2560 obj
= eval2_4f( out
, coord
, flags
, IM
->Start
,
2561 4, &ctx
->EvalMap
.Map2Vertex4
);
2563 else if (ctx
->Eval
.Map2Vertex3
)
2565 if (ctx
->Eval
.AutoNormal
&& (req
& VERT_NORM
))
2566 obj
= eval2_obj_norm( out
, VB
->NormalPtr
, coord
, flags
, IM
->Start
,
2567 3, &ctx
->EvalMap
.Map2Vertex3
);
2569 obj
= eval2_4f( out
, coord
, flags
, IM
->Start
,
2570 3, &ctx
->EvalMap
.Map2Vertex3
);
2574 if (obj
!= in
&& !all_eval
)
2575 obj
= copy_4f( out
, in
, flags
, IM
->Start
);
2581 GLuint
*oldflags
= VB
->Flag
;
2582 GLuint
*flags
= VB
->Flag
= VB
->EvaluatedFlags
;
2584 GLuint count
= VB
->Count
;
2587 VB
->EvaluatedFlags
= (GLuint
*) MALLOC(VB
->Size
* sizeof(GLuint
));
2588 flags
= VB
->Flag
= VB
->EvaluatedFlags
;
2592 for (i
= 0 ; i
< count
; i
++)
2593 flags
[i
] = oldflags
[i
] | new_flags
;
2595 GLuint andflag
= ~0;
2596 for (i
= 0 ; i
< count
; i
++) {
2597 if (oldflags
[i
] & VERT_EVAL_ANY
)
2598 flags
[i
] = oldflags
[i
] | new_flags
;
2599 andflag
&= flags
[i
];
2607 _mesa_MapGrid1f( GLint un
, GLfloat u1
, GLfloat u2
)
2609 GET_CURRENT_CONTEXT(ctx
);
2610 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glMapGrid1f");
2613 gl_error( ctx
, GL_INVALID_VALUE
, "glMapGrid1f" );
2616 ctx
->Eval
.MapGrid1un
= un
;
2617 ctx
->Eval
.MapGrid1u1
= u1
;
2618 ctx
->Eval
.MapGrid1u2
= u2
;
2619 ctx
->Eval
.MapGrid1du
= (u2
- u1
) / (GLfloat
) un
;
2624 _mesa_MapGrid1d( GLint un
, GLdouble u1
, GLdouble u2
)
2626 _mesa_MapGrid1f( un
, u1
, u2
);
2631 _mesa_MapGrid2f( GLint un
, GLfloat u1
, GLfloat u2
,
2632 GLint vn
, GLfloat v1
, GLfloat v2
)
2634 GET_CURRENT_CONTEXT(ctx
);
2635 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glMapGrid2f");
2637 gl_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(un)" );
2641 gl_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(vn)" );
2644 ctx
->Eval
.MapGrid2un
= un
;
2645 ctx
->Eval
.MapGrid2u1
= u1
;
2646 ctx
->Eval
.MapGrid2u2
= u2
;
2647 ctx
->Eval
.MapGrid2du
= (u2
- u1
) / (GLfloat
) un
;
2648 ctx
->Eval
.MapGrid2vn
= vn
;
2649 ctx
->Eval
.MapGrid2v1
= v1
;
2650 ctx
->Eval
.MapGrid2v2
= v2
;
2651 ctx
->Eval
.MapGrid2dv
= (v2
- v1
) / (GLfloat
) vn
;
2656 _mesa_MapGrid2d( GLint un
, GLdouble u1
, GLdouble u2
,
2657 GLint vn
, GLdouble v1
, GLdouble v2
)
2659 _mesa_MapGrid2f( un
, u1
, u2
, vn
, v1
, v2
);
2665 /* KW: If are compiling, we don't know whether eval will produce a
2666 * vertex when it is run in the future. If this is pure immediate
2667 * mode, eval is a noop if neither vertex map is enabled.
2669 * Thus we need to have a check in the display list code or
2670 * elsewhere for eval(1,2) vertices in the case where
2671 * map(1,2)_vertex is disabled, and to purge those vertices from
2672 * the vb. This is currently done
2673 * via modifications to the cull_vb and render_vb operations, and
2674 * by using the existing cullmask mechanism for all other operations.
2678 /* KW: Because the eval values don't become 'current', fixup will flow
2679 * through these vertices, and then evaluation will write on top
2680 * of the fixup results.
2682 * This is a little inefficient, but at least it is correct. This
2683 * could be short-circuited in the case where all vertices are
2684 * eval-vertices, or more generally by a cullmask in fixup.
2686 * Note: using Obj to hold eval coord data. This data is actually
2687 * transformed if eval is disabled. But disabling eval & sending
2688 * eval coords is stupid, right?
2692 #define EVALCOORD1(IM, x) \
2694 GLuint count = IM->Count++; \
2695 IM->Flag[count] |= VERT_EVAL_C1; \
2696 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
2697 if (count == VB_MAX-1) \
2698 IM->maybe_transform_vb( IM ); \
2701 #define EVALCOORD2(IM, x, y) \
2703 GLuint count = IM->Count++; \
2704 IM->Flag[count] |= VERT_EVAL_C2; \
2705 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
2706 if (count == VB_MAX-1) \
2707 IM->maybe_transform_vb( IM ); \
2710 #define EVALPOINT1(IM, x) \
2712 GLuint count = IM->Count++; \
2713 IM->Flag[count] |= VERT_EVAL_P1; \
2714 ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
2715 if (count == VB_MAX-1) \
2716 IM->maybe_transform_vb( IM ); \
2719 #define EVALPOINT2(IM, x, y) \
2721 GLuint count = IM->Count++; \
2722 IM->Flag[count] |= VERT_EVAL_P2; \
2723 ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
2724 if (count == VB_MAX-1) \
2725 IM->maybe_transform_vb( IM ); \
2729 /* Lame internal function:
2732 eval_coord1f( GLcontext
*CC
, GLfloat u
)
2734 struct immediate
*i
= CC
->input
;
2740 _mesa_EvalCoord1d( GLdouble u
)
2743 EVALCOORD1( IM
, (GLfloat
) u
);
2748 _mesa_EvalCoord1f( GLfloat u
)
2751 EVALCOORD1( IM
, u
);
2756 _mesa_EvalCoord1dv( const GLdouble
*u
)
2759 EVALCOORD1( IM
, (GLfloat
) *u
);
2764 _mesa_EvalCoord1fv( const GLfloat
*u
)
2767 EVALCOORD1( IM
, (GLfloat
) *u
);
2772 _mesa_EvalCoord2d( GLdouble u
, GLdouble v
)
2775 EVALCOORD2( IM
, (GLfloat
) u
, (GLfloat
) v
);
2780 _mesa_EvalCoord2f( GLfloat u
, GLfloat v
)
2783 EVALCOORD2( IM
, u
, v
);
2787 /* Lame internal function:
2790 eval_coord2f( GLcontext
*CC
, GLfloat u
, GLfloat v
)
2792 struct immediate
*i
= CC
->input
;
2793 EVALCOORD2( i
, u
, v
);
2798 _mesa_EvalCoord2dv( const GLdouble
*u
)
2801 EVALCOORD2( IM
, (GLfloat
) u
[0], (GLfloat
) u
[1] );
2806 _mesa_EvalCoord2fv( const GLfloat
*u
)
2809 EVALCOORD2( IM
, u
[0], u
[1] );
2814 _mesa_EvalPoint1( GLint i
)
2817 EVALPOINT1( IM
, i
);
2822 _mesa_EvalPoint2( GLint i
, GLint j
)
2825 EVALPOINT2( IM
, i
, j
);
2833 _mesa_EvalMesh1( GLenum mode
, GLint i1
, GLint i2
)
2835 GET_CURRENT_CONTEXT(ctx
);
2840 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glEvalMesh1");
2847 prim
= GL_LINE_STRIP
;
2850 gl_error( ctx
, GL_INVALID_ENUM
, "glEvalMesh1(mode)" );
2854 /* No effect if vertex maps disabled.
2856 if (!ctx
->Eval
.Map1Vertex4
&& !ctx
->Eval
.Map1Vertex3
)
2859 du
= ctx
->Eval
.MapGrid1du
;
2860 u
= ctx
->Eval
.MapGrid1u1
+ i1
* du
;
2862 /* KW: Could short-circuit this to avoid the immediate mechanism.
2864 RESET_IMMEDIATE(ctx
);
2866 gl_Begin( ctx
, prim
);
2867 for (i
=i1
;i
<=i2
;i
++,u
+=du
) {
2868 eval_coord1f( ctx
, u
);
2876 _mesa_EvalMesh2( GLenum mode
, GLint i1
, GLint i2
, GLint j1
, GLint j2
)
2878 GET_CURRENT_CONTEXT(ctx
);
2880 GLfloat u
, du
, v
, dv
, v1
, u1
;
2882 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glEvalMesh2");
2884 /* No effect if vertex maps disabled.
2886 if (!ctx
->Eval
.Map2Vertex4
&& !ctx
->Eval
.Map2Vertex3
)
2889 du
= ctx
->Eval
.MapGrid2du
;
2890 dv
= ctx
->Eval
.MapGrid2dv
;
2891 v1
= ctx
->Eval
.MapGrid2v1
+ j1
* dv
;
2892 u1
= ctx
->Eval
.MapGrid2u1
+ i1
* du
;
2894 RESET_IMMEDIATE(ctx
);
2898 gl_Begin( ctx
, GL_POINTS
);
2899 for (v
=v1
,j
=j1
;j
<=j2
;j
++,v
+=dv
) {
2900 for (u
=u1
,i
=i1
;i
<=i2
;i
++,u
+=du
) {
2901 eval_coord2f( ctx
, u
, v
);
2907 for (v
=v1
,j
=j1
;j
<=j2
;j
++,v
+=dv
) {
2908 gl_Begin( ctx
, GL_LINE_STRIP
);
2909 for (u
=u1
,i
=i1
;i
<=i2
;i
++,u
+=du
) {
2910 eval_coord2f( ctx
, u
, v
);
2914 for (u
=u1
,i
=i1
;i
<=i2
;i
++,u
+=du
) {
2915 gl_Begin( ctx
, GL_LINE_STRIP
);
2916 for (v
=v1
,j
=j1
;j
<=j2
;j
++,v
+=dv
) {
2917 eval_coord2f( ctx
, u
, v
);
2923 for (v
=v1
,j
=j1
;j
<j2
;j
++,v
+=dv
) {
2924 /* NOTE: a quad strip can't be used because the four */
2925 /* can't be guaranteed to be coplanar! */
2926 gl_Begin( ctx
, GL_TRIANGLE_STRIP
);
2927 for (u
=u1
,i
=i1
;i
<=i2
;i
++,u
+=du
) {
2928 eval_coord2f( ctx
, u
, v
);
2929 eval_coord2f( ctx
, u
, v
+dv
);
2935 gl_error( ctx
, GL_INVALID_ENUM
, "glEvalMesh2(mode)" );