3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * eval.c was written by
29 * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
30 * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
32 * My original implementation of evaluators was simplistic and didn't
33 * compute surface normal vectors properly. Bernd and Volker applied
34 * used more sophisticated methods to get better results.
46 #include "mfeatures.h"
48 #include "main/dispatch.h"
52 * Return the number of components per control point for any type of
53 * evaluator. Return 0 if bad target.
54 * See table 5.1 in the OpenGL 1.2 spec.
56 GLuint
_mesa_evaluator_components( GLenum target
)
59 case GL_MAP1_VERTEX_3
: return 3;
60 case GL_MAP1_VERTEX_4
: return 4;
61 case GL_MAP1_INDEX
: return 1;
62 case GL_MAP1_COLOR_4
: return 4;
63 case GL_MAP1_NORMAL
: return 3;
64 case GL_MAP1_TEXTURE_COORD_1
: return 1;
65 case GL_MAP1_TEXTURE_COORD_2
: return 2;
66 case GL_MAP1_TEXTURE_COORD_3
: return 3;
67 case GL_MAP1_TEXTURE_COORD_4
: return 4;
68 case GL_MAP2_VERTEX_3
: return 3;
69 case GL_MAP2_VERTEX_4
: return 4;
70 case GL_MAP2_INDEX
: return 1;
71 case GL_MAP2_COLOR_4
: return 4;
72 case GL_MAP2_NORMAL
: return 3;
73 case GL_MAP2_TEXTURE_COORD_1
: return 1;
74 case GL_MAP2_TEXTURE_COORD_2
: return 2;
75 case GL_MAP2_TEXTURE_COORD_3
: return 3;
76 case GL_MAP2_TEXTURE_COORD_4
: return 4;
85 * Return pointer to the gl_1d_map struct for the named target.
87 static struct gl_1d_map
*
88 get_1d_map( struct gl_context
*ctx
, GLenum target
)
91 case GL_MAP1_VERTEX_3
:
92 return &ctx
->EvalMap
.Map1Vertex3
;
93 case GL_MAP1_VERTEX_4
:
94 return &ctx
->EvalMap
.Map1Vertex4
;
96 return &ctx
->EvalMap
.Map1Index
;
98 return &ctx
->EvalMap
.Map1Color4
;
100 return &ctx
->EvalMap
.Map1Normal
;
101 case GL_MAP1_TEXTURE_COORD_1
:
102 return &ctx
->EvalMap
.Map1Texture1
;
103 case GL_MAP1_TEXTURE_COORD_2
:
104 return &ctx
->EvalMap
.Map1Texture2
;
105 case GL_MAP1_TEXTURE_COORD_3
:
106 return &ctx
->EvalMap
.Map1Texture3
;
107 case GL_MAP1_TEXTURE_COORD_4
:
108 return &ctx
->EvalMap
.Map1Texture4
;
116 * Return pointer to the gl_2d_map struct for the named target.
118 static struct gl_2d_map
*
119 get_2d_map( struct gl_context
*ctx
, GLenum target
)
122 case GL_MAP2_VERTEX_3
:
123 return &ctx
->EvalMap
.Map2Vertex3
;
124 case GL_MAP2_VERTEX_4
:
125 return &ctx
->EvalMap
.Map2Vertex4
;
127 return &ctx
->EvalMap
.Map2Index
;
128 case GL_MAP2_COLOR_4
:
129 return &ctx
->EvalMap
.Map2Color4
;
131 return &ctx
->EvalMap
.Map2Normal
;
132 case GL_MAP2_TEXTURE_COORD_1
:
133 return &ctx
->EvalMap
.Map2Texture1
;
134 case GL_MAP2_TEXTURE_COORD_2
:
135 return &ctx
->EvalMap
.Map2Texture2
;
136 case GL_MAP2_TEXTURE_COORD_3
:
137 return &ctx
->EvalMap
.Map2Texture3
;
138 case GL_MAP2_TEXTURE_COORD_4
:
139 return &ctx
->EvalMap
.Map2Texture4
;
146 /**********************************************************************/
147 /*** Copy and deallocate control points ***/
148 /**********************************************************************/
152 * Copy 1-parametric evaluator control points from user-specified
153 * memory space to a buffer of contiguous control points.
154 * \param see glMap1f for details
155 * \return pointer to buffer of contiguous control points or NULL if out
158 GLfloat
*_mesa_copy_map_points1f( GLenum target
, GLint ustride
, GLint uorder
,
159 const GLfloat
*points
)
162 GLint i
, k
, size
= _mesa_evaluator_components(target
);
164 if (!points
|| !size
)
167 buffer
= malloc(uorder
* size
* sizeof(GLfloat
));
170 for (i
= 0, p
= buffer
; i
< uorder
; i
++, points
+= ustride
)
171 for (k
= 0; k
< size
; k
++)
180 * Same as above but convert doubles to floats.
182 GLfloat
*_mesa_copy_map_points1d( GLenum target
, GLint ustride
, GLint uorder
,
183 const GLdouble
*points
)
186 GLint i
, k
, size
= _mesa_evaluator_components(target
);
188 if (!points
|| !size
)
191 buffer
= malloc(uorder
* size
* sizeof(GLfloat
));
194 for (i
= 0, p
= buffer
; i
< uorder
; i
++, points
+= ustride
)
195 for (k
= 0; k
< size
; k
++)
196 *p
++ = (GLfloat
) points
[k
];
204 * Copy 2-parametric evaluator control points from user-specified
205 * memory space to a buffer of contiguous control points.
206 * Additional memory is allocated to be used by the horner and
207 * de Casteljau evaluation schemes.
209 * \param see glMap2f for details
210 * \return pointer to buffer of contiguous control points or NULL if out
213 GLfloat
*_mesa_copy_map_points2f( GLenum target
,
214 GLint ustride
, GLint uorder
,
215 GLint vstride
, GLint vorder
,
216 const GLfloat
*points
)
219 GLint i
, j
, k
, size
, dsize
, hsize
;
222 size
= _mesa_evaluator_components(target
);
224 if (!points
|| size
==0) {
228 /* max(uorder, vorder) additional points are used in */
229 /* horner evaluation and uorder*vorder additional */
230 /* values are needed for de Casteljau */
231 dsize
= (uorder
== 2 && vorder
== 2)? 0 : uorder
*vorder
;
232 hsize
= (uorder
> vorder
? uorder
: vorder
)*size
;
235 buffer
= malloc((uorder
*vorder
*size
+hsize
)*sizeof(GLfloat
));
237 buffer
= malloc((uorder
*vorder
*size
+dsize
)*sizeof(GLfloat
));
239 /* compute the increment value for the u-loop */
240 uinc
= ustride
- vorder
*vstride
;
243 for (i
=0, p
=buffer
; i
<uorder
; i
++, points
+= uinc
)
244 for (j
=0; j
<vorder
; j
++, points
+= vstride
)
245 for (k
=0; k
<size
; k
++)
254 * Same as above but convert doubles to floats.
256 GLfloat
*_mesa_copy_map_points2d(GLenum target
,
257 GLint ustride
, GLint uorder
,
258 GLint vstride
, GLint vorder
,
259 const GLdouble
*points
)
262 GLint i
, j
, k
, size
, hsize
, dsize
;
265 size
= _mesa_evaluator_components(target
);
267 if (!points
|| size
==0) {
271 /* max(uorder, vorder) additional points are used in */
272 /* horner evaluation and uorder*vorder additional */
273 /* values are needed for de Casteljau */
274 dsize
= (uorder
== 2 && vorder
== 2)? 0 : uorder
*vorder
;
275 hsize
= (uorder
> vorder
? uorder
: vorder
)*size
;
278 buffer
= malloc((uorder
*vorder
*size
+hsize
)*sizeof(GLfloat
));
280 buffer
= malloc((uorder
*vorder
*size
+dsize
)*sizeof(GLfloat
));
282 /* compute the increment value for the u-loop */
283 uinc
= ustride
- vorder
*vstride
;
286 for (i
=0, p
=buffer
; i
<uorder
; i
++, points
+= uinc
)
287 for (j
=0; j
<vorder
; j
++, points
+= vstride
)
288 for (k
=0; k
<size
; k
++)
289 *p
++ = (GLfloat
) points
[k
];
297 /**********************************************************************/
298 /*** API entry points ***/
299 /**********************************************************************/
303 * This does the work of glMap1[fd].
306 map1(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustride
,
307 GLint uorder
, const GLvoid
*points
, GLenum type
)
309 GET_CURRENT_CONTEXT(ctx
);
312 struct gl_1d_map
*map
= NULL
;
314 ASSERT_OUTSIDE_BEGIN_END(ctx
);
315 ASSERT(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
318 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(u1,u2)" );
321 if (uorder
< 1 || uorder
> MAX_EVAL_ORDER
) {
322 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(order)" );
326 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(points)" );
330 k
= _mesa_evaluator_components( target
);
332 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
337 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(stride)" );
341 if (ctx
->Texture
.CurrentUnit
!= 0) {
342 /* See OpenGL 1.2.1 spec, section F.2.13 */
343 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glMap2(ACTIVE_TEXTURE != 0)" );
347 map
= get_1d_map(ctx
, target
);
349 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
353 /* make copy of the control points */
354 if (type
== GL_FLOAT
)
355 pnts
= _mesa_copy_map_points1f(target
, ustride
, uorder
, (GLfloat
*) points
);
357 pnts
= _mesa_copy_map_points1d(target
, ustride
, uorder
, (GLdouble
*) points
);
360 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
364 map
->du
= 1.0F
/ (u2
- u1
);
371 static void GLAPIENTRY
372 _mesa_Map1f( GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
373 GLint order
, const GLfloat
*points
)
375 map1(target
, u1
, u2
, stride
, order
, points
, GL_FLOAT
);
379 static void GLAPIENTRY
380 _mesa_Map1d( GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
381 GLint order
, const GLdouble
*points
)
383 map1(target
, (GLfloat
) u1
, (GLfloat
) u2
, stride
, order
, points
, GL_DOUBLE
);
388 map2( GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
389 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
390 const GLvoid
*points
, GLenum type
)
392 GET_CURRENT_CONTEXT(ctx
);
395 struct gl_2d_map
*map
= NULL
;
397 ASSERT_OUTSIDE_BEGIN_END(ctx
);
398 ASSERT(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
401 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(u1,u2)" );
406 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(v1,v2)" );
410 if (uorder
<1 || uorder
>MAX_EVAL_ORDER
) {
411 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(uorder)" );
415 if (vorder
<1 || vorder
>MAX_EVAL_ORDER
) {
416 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(vorder)" );
420 k
= _mesa_evaluator_components( target
);
422 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
427 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(ustride)" );
431 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(vstride)" );
435 if (ctx
->Texture
.CurrentUnit
!= 0) {
436 /* See OpenGL 1.2.1 spec, section F.2.13 */
437 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glMap2(ACTIVE_TEXTURE != 0)" );
441 map
= get_2d_map(ctx
, target
);
443 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
447 /* make copy of the control points */
448 if (type
== GL_FLOAT
)
449 pnts
= _mesa_copy_map_points2f(target
, ustride
, uorder
,
450 vstride
, vorder
, (GLfloat
*) points
);
452 pnts
= _mesa_copy_map_points2d(target
, ustride
, uorder
,
453 vstride
, vorder
, (GLdouble
*) points
);
456 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
457 map
->Uorder
= uorder
;
460 map
->du
= 1.0F
/ (u2
- u1
);
461 map
->Vorder
= vorder
;
464 map
->dv
= 1.0F
/ (v2
- v1
);
470 static void GLAPIENTRY
471 _mesa_Map2f( GLenum target
,
472 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
473 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
474 const GLfloat
*points
)
476 map2(target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
,
481 static void GLAPIENTRY
482 _mesa_Map2d( GLenum target
,
483 GLdouble u1
, GLdouble u2
, GLint ustride
, GLint uorder
,
484 GLdouble v1
, GLdouble v2
, GLint vstride
, GLint vorder
,
485 const GLdouble
*points
)
487 map2(target
, (GLfloat
) u1
, (GLfloat
) u2
, ustride
, uorder
,
488 (GLfloat
) v1
, (GLfloat
) v2
, vstride
, vorder
, points
, GL_DOUBLE
);
493 static void GLAPIENTRY
494 _mesa_GetnMapdvARB( GLenum target
, GLenum query
, GLsizei bufSize
, GLdouble
*v
)
496 GET_CURRENT_CONTEXT(ctx
);
497 struct gl_1d_map
*map1d
;
498 struct gl_2d_map
*map2d
;
504 ASSERT_OUTSIDE_BEGIN_END(ctx
);
506 comps
= _mesa_evaluator_components(target
);
508 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(target)" );
512 map1d
= get_1d_map(ctx
, target
);
513 map2d
= get_2d_map(ctx
, target
);
514 ASSERT(map1d
|| map2d
);
519 data
= map1d
->Points
;
520 n
= map1d
->Order
* comps
;
523 data
= map2d
->Points
;
524 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
527 numBytes
= n
* sizeof *v
;
528 if (bufSize
< numBytes
)
537 numBytes
= 1 * sizeof *v
;
538 if (bufSize
< numBytes
)
540 v
[0] = (GLdouble
) map1d
->Order
;
543 numBytes
= 2 * sizeof *v
;
544 if (bufSize
< numBytes
)
546 v
[0] = (GLdouble
) map2d
->Uorder
;
547 v
[1] = (GLdouble
) map2d
->Vorder
;
552 numBytes
= 2 * sizeof *v
;
553 if (bufSize
< numBytes
)
555 v
[0] = (GLdouble
) map1d
->u1
;
556 v
[1] = (GLdouble
) map1d
->u2
;
559 numBytes
= 4 * sizeof *v
;
560 if (bufSize
< numBytes
)
562 v
[0] = (GLdouble
) map2d
->u1
;
563 v
[1] = (GLdouble
) map2d
->u2
;
564 v
[2] = (GLdouble
) map2d
->v1
;
565 v
[3] = (GLdouble
) map2d
->v2
;
569 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(query)" );
574 _mesa_error( ctx
, GL_INVALID_OPERATION
,
575 "glGetnMapdvARB(out of bounds: bufSize is %d,"
576 " but %d bytes are required)", bufSize
, numBytes
);
579 static void GLAPIENTRY
580 _mesa_GetMapdv( GLenum target
, GLenum query
, GLdouble
*v
)
582 _mesa_GetnMapdvARB(target
, query
, INT_MAX
, v
);
585 static void GLAPIENTRY
586 _mesa_GetnMapfvARB( GLenum target
, GLenum query
, GLsizei bufSize
, GLfloat
*v
)
588 GET_CURRENT_CONTEXT(ctx
);
589 struct gl_1d_map
*map1d
;
590 struct gl_2d_map
*map2d
;
596 ASSERT_OUTSIDE_BEGIN_END(ctx
);
598 comps
= _mesa_evaluator_components(target
);
600 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(target)" );
604 map1d
= get_1d_map(ctx
, target
);
605 map2d
= get_2d_map(ctx
, target
);
606 ASSERT(map1d
|| map2d
);
611 data
= map1d
->Points
;
612 n
= map1d
->Order
* comps
;
615 data
= map2d
->Points
;
616 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
619 numBytes
= n
* sizeof *v
;
620 if (bufSize
< numBytes
)
629 numBytes
= 1 * sizeof *v
;
630 if (bufSize
< numBytes
)
632 v
[0] = (GLfloat
) map1d
->Order
;
635 numBytes
= 2 * sizeof *v
;
636 if (bufSize
< numBytes
)
638 v
[0] = (GLfloat
) map2d
->Uorder
;
639 v
[1] = (GLfloat
) map2d
->Vorder
;
644 numBytes
= 2 * sizeof *v
;
645 if (bufSize
< numBytes
)
651 numBytes
= 4 * sizeof *v
;
652 if (bufSize
< numBytes
)
661 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(query)" );
666 _mesa_error( ctx
, GL_INVALID_OPERATION
,
667 "glGetnMapfvARB(out of bounds: bufSize is %d,"
668 " but %d bytes are required)", bufSize
, numBytes
);
672 static void GLAPIENTRY
673 _mesa_GetMapfv( GLenum target
, GLenum query
, GLfloat
*v
)
675 _mesa_GetnMapfvARB(target
, query
, INT_MAX
, v
);
679 static void GLAPIENTRY
680 _mesa_GetnMapivARB( GLenum target
, GLenum query
, GLsizei bufSize
, GLint
*v
)
682 GET_CURRENT_CONTEXT(ctx
);
683 struct gl_1d_map
*map1d
;
684 struct gl_2d_map
*map2d
;
690 ASSERT_OUTSIDE_BEGIN_END(ctx
);
692 comps
= _mesa_evaluator_components(target
);
694 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(target)" );
698 map1d
= get_1d_map(ctx
, target
);
699 map2d
= get_2d_map(ctx
, target
);
700 ASSERT(map1d
|| map2d
);
705 data
= map1d
->Points
;
706 n
= map1d
->Order
* comps
;
709 data
= map2d
->Points
;
710 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
713 numBytes
= n
* sizeof *v
;
714 if (bufSize
< numBytes
)
717 v
[i
] = IROUND(data
[i
]);
723 numBytes
= 1 * sizeof *v
;
724 if (bufSize
< numBytes
)
729 numBytes
= 2 * sizeof *v
;
730 if (bufSize
< numBytes
)
732 v
[0] = map2d
->Uorder
;
733 v
[1] = map2d
->Vorder
;
738 numBytes
= 2 * sizeof *v
;
739 if (bufSize
< numBytes
)
741 v
[0] = IROUND(map1d
->u1
);
742 v
[1] = IROUND(map1d
->u2
);
745 numBytes
= 4 * sizeof *v
;
746 if (bufSize
< numBytes
)
748 v
[0] = IROUND(map2d
->u1
);
749 v
[1] = IROUND(map2d
->u2
);
750 v
[2] = IROUND(map2d
->v1
);
751 v
[3] = IROUND(map2d
->v2
);
755 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(query)" );
760 _mesa_error( ctx
, GL_INVALID_OPERATION
,
761 "glGetnMapivARB(out of bounds: bufSize is %d,"
762 " but %d bytes are required)", bufSize
, numBytes
);
766 static void GLAPIENTRY
767 _mesa_GetMapiv( GLenum target
, GLenum query
, GLint
*v
)
769 _mesa_GetnMapivARB(target
, query
, INT_MAX
, v
);
773 static void GLAPIENTRY
774 _mesa_MapGrid1f( GLint un
, GLfloat u1
, GLfloat u2
)
776 GET_CURRENT_CONTEXT(ctx
);
777 ASSERT_OUTSIDE_BEGIN_END(ctx
);
780 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid1f" );
783 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
784 ctx
->Eval
.MapGrid1un
= un
;
785 ctx
->Eval
.MapGrid1u1
= u1
;
786 ctx
->Eval
.MapGrid1u2
= u2
;
787 ctx
->Eval
.MapGrid1du
= (u2
- u1
) / (GLfloat
) un
;
791 static void GLAPIENTRY
792 _mesa_MapGrid1d( GLint un
, GLdouble u1
, GLdouble u2
)
794 _mesa_MapGrid1f( un
, (GLfloat
) u1
, (GLfloat
) u2
);
798 static void GLAPIENTRY
799 _mesa_MapGrid2f( GLint un
, GLfloat u1
, GLfloat u2
,
800 GLint vn
, GLfloat v1
, GLfloat v2
)
802 GET_CURRENT_CONTEXT(ctx
);
803 ASSERT_OUTSIDE_BEGIN_END(ctx
);
806 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(un)" );
810 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(vn)" );
814 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
815 ctx
->Eval
.MapGrid2un
= un
;
816 ctx
->Eval
.MapGrid2u1
= u1
;
817 ctx
->Eval
.MapGrid2u2
= u2
;
818 ctx
->Eval
.MapGrid2du
= (u2
- u1
) / (GLfloat
) un
;
819 ctx
->Eval
.MapGrid2vn
= vn
;
820 ctx
->Eval
.MapGrid2v1
= v1
;
821 ctx
->Eval
.MapGrid2v2
= v2
;
822 ctx
->Eval
.MapGrid2dv
= (v2
- v1
) / (GLfloat
) vn
;
826 static void GLAPIENTRY
827 _mesa_MapGrid2d( GLint un
, GLdouble u1
, GLdouble u2
,
828 GLint vn
, GLdouble v1
, GLdouble v2
)
830 _mesa_MapGrid2f( un
, (GLfloat
) u1
, (GLfloat
) u2
,
831 vn
, (GLfloat
) v1
, (GLfloat
) v2
);
836 _mesa_install_eval_vtxfmt(struct _glapi_table
*disp
,
837 const GLvertexformat
*vfmt
)
839 SET_EvalCoord1f(disp
, vfmt
->EvalCoord1f
);
840 SET_EvalCoord1fv(disp
, vfmt
->EvalCoord1fv
);
841 SET_EvalCoord2f(disp
, vfmt
->EvalCoord2f
);
842 SET_EvalCoord2fv(disp
, vfmt
->EvalCoord2fv
);
843 SET_EvalPoint1(disp
, vfmt
->EvalPoint1
);
844 SET_EvalPoint2(disp
, vfmt
->EvalPoint2
);
846 SET_EvalMesh1(disp
, vfmt
->EvalMesh1
);
847 SET_EvalMesh2(disp
, vfmt
->EvalMesh2
);
852 _mesa_init_eval_dispatch(struct _glapi_table
*disp
)
854 SET_GetMapdv(disp
, _mesa_GetMapdv
);
855 SET_GetMapfv(disp
, _mesa_GetMapfv
);
856 SET_GetMapiv(disp
, _mesa_GetMapiv
);
857 SET_Map1d(disp
, _mesa_Map1d
);
858 SET_Map1f(disp
, _mesa_Map1f
);
859 SET_Map2d(disp
, _mesa_Map2d
);
860 SET_Map2f(disp
, _mesa_Map2f
);
861 SET_MapGrid1d(disp
, _mesa_MapGrid1d
);
862 SET_MapGrid1f(disp
, _mesa_MapGrid1f
);
863 SET_MapGrid2d(disp
, _mesa_MapGrid2d
);
864 SET_MapGrid2f(disp
, _mesa_MapGrid2f
);
866 /* GL_ARB_robustness */
867 SET_GetnMapdvARB(disp
, _mesa_GetnMapdvARB
);
868 SET_GetnMapfvARB(disp
, _mesa_GetnMapfvARB
);
869 SET_GetnMapivARB(disp
, _mesa_GetnMapivARB
);
873 /**********************************************************************/
874 /***** Initialization *****/
875 /**********************************************************************/
878 * Initialize a 1-D evaluator map.
881 init_1d_map( struct gl_1d_map
*map
, int n
, const float *initial
)
886 map
->Points
= malloc(n
* sizeof(GLfloat
));
890 map
->Points
[i
] = initial
[i
];
896 * Initialize a 2-D evaluator map
899 init_2d_map( struct gl_2d_map
*map
, int n
, const float *initial
)
907 map
->Points
= malloc(n
* sizeof(GLfloat
));
911 map
->Points
[i
] = initial
[i
];
916 void _mesa_init_eval( struct gl_context
*ctx
)
918 /* Evaluators group */
919 ctx
->Eval
.Map1Color4
= GL_FALSE
;
920 ctx
->Eval
.Map1Index
= GL_FALSE
;
921 ctx
->Eval
.Map1Normal
= GL_FALSE
;
922 ctx
->Eval
.Map1TextureCoord1
= GL_FALSE
;
923 ctx
->Eval
.Map1TextureCoord2
= GL_FALSE
;
924 ctx
->Eval
.Map1TextureCoord3
= GL_FALSE
;
925 ctx
->Eval
.Map1TextureCoord4
= GL_FALSE
;
926 ctx
->Eval
.Map1Vertex3
= GL_FALSE
;
927 ctx
->Eval
.Map1Vertex4
= GL_FALSE
;
928 ctx
->Eval
.Map2Color4
= GL_FALSE
;
929 ctx
->Eval
.Map2Index
= GL_FALSE
;
930 ctx
->Eval
.Map2Normal
= GL_FALSE
;
931 ctx
->Eval
.Map2TextureCoord1
= GL_FALSE
;
932 ctx
->Eval
.Map2TextureCoord2
= GL_FALSE
;
933 ctx
->Eval
.Map2TextureCoord3
= GL_FALSE
;
934 ctx
->Eval
.Map2TextureCoord4
= GL_FALSE
;
935 ctx
->Eval
.Map2Vertex3
= GL_FALSE
;
936 ctx
->Eval
.Map2Vertex4
= GL_FALSE
;
937 ctx
->Eval
.AutoNormal
= GL_FALSE
;
938 ctx
->Eval
.MapGrid1un
= 1;
939 ctx
->Eval
.MapGrid1u1
= 0.0;
940 ctx
->Eval
.MapGrid1u2
= 1.0;
941 ctx
->Eval
.MapGrid2un
= 1;
942 ctx
->Eval
.MapGrid2vn
= 1;
943 ctx
->Eval
.MapGrid2u1
= 0.0;
944 ctx
->Eval
.MapGrid2u2
= 1.0;
945 ctx
->Eval
.MapGrid2v1
= 0.0;
946 ctx
->Eval
.MapGrid2v2
= 1.0;
950 static GLfloat vertex
[4] = { 0.0, 0.0, 0.0, 1.0 };
951 static GLfloat normal
[3] = { 0.0, 0.0, 1.0 };
952 static GLfloat index
[1] = { 1.0 };
953 static GLfloat color
[4] = { 1.0, 1.0, 1.0, 1.0 };
954 static GLfloat texcoord
[4] = { 0.0, 0.0, 0.0, 1.0 };
956 init_1d_map( &ctx
->EvalMap
.Map1Vertex3
, 3, vertex
);
957 init_1d_map( &ctx
->EvalMap
.Map1Vertex4
, 4, vertex
);
958 init_1d_map( &ctx
->EvalMap
.Map1Index
, 1, index
);
959 init_1d_map( &ctx
->EvalMap
.Map1Color4
, 4, color
);
960 init_1d_map( &ctx
->EvalMap
.Map1Normal
, 3, normal
);
961 init_1d_map( &ctx
->EvalMap
.Map1Texture1
, 1, texcoord
);
962 init_1d_map( &ctx
->EvalMap
.Map1Texture2
, 2, texcoord
);
963 init_1d_map( &ctx
->EvalMap
.Map1Texture3
, 3, texcoord
);
964 init_1d_map( &ctx
->EvalMap
.Map1Texture4
, 4, texcoord
);
966 init_2d_map( &ctx
->EvalMap
.Map2Vertex3
, 3, vertex
);
967 init_2d_map( &ctx
->EvalMap
.Map2Vertex4
, 4, vertex
);
968 init_2d_map( &ctx
->EvalMap
.Map2Index
, 1, index
);
969 init_2d_map( &ctx
->EvalMap
.Map2Color4
, 4, color
);
970 init_2d_map( &ctx
->EvalMap
.Map2Normal
, 3, normal
);
971 init_2d_map( &ctx
->EvalMap
.Map2Texture1
, 1, texcoord
);
972 init_2d_map( &ctx
->EvalMap
.Map2Texture2
, 2, texcoord
);
973 init_2d_map( &ctx
->EvalMap
.Map2Texture3
, 3, texcoord
);
974 init_2d_map( &ctx
->EvalMap
.Map2Texture4
, 4, texcoord
);
979 void _mesa_free_eval_data( struct gl_context
*ctx
)
981 /* Free evaluator data */
982 free(ctx
->EvalMap
.Map1Vertex3
.Points
);
983 free(ctx
->EvalMap
.Map1Vertex4
.Points
);
984 free(ctx
->EvalMap
.Map1Index
.Points
);
985 free(ctx
->EvalMap
.Map1Color4
.Points
);
986 free(ctx
->EvalMap
.Map1Normal
.Points
);
987 free(ctx
->EvalMap
.Map1Texture1
.Points
);
988 free(ctx
->EvalMap
.Map1Texture2
.Points
);
989 free(ctx
->EvalMap
.Map1Texture3
.Points
);
990 free(ctx
->EvalMap
.Map1Texture4
.Points
);
992 free(ctx
->EvalMap
.Map2Vertex3
.Points
);
993 free(ctx
->EvalMap
.Map2Vertex4
.Points
);
994 free(ctx
->EvalMap
.Map2Index
.Points
);
995 free(ctx
->EvalMap
.Map2Color4
.Points
);
996 free(ctx
->EvalMap
.Map2Normal
.Points
);
997 free(ctx
->EvalMap
.Map2Texture1
.Points
);
998 free(ctx
->EvalMap
.Map2Texture2
.Points
);
999 free(ctx
->EvalMap
.Map2Texture3
.Points
);
1000 free(ctx
->EvalMap
.Map2Texture4
.Points
);