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.
27 * eval.c was written by
28 * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
29 * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
31 * My original implementation of evaluators was simplistic and didn't
32 * compute surface normal vectors properly. Bernd and Volker applied
33 * used more sophisticated methods to get better results.
40 #if FEATURE_evaluators
44 * Return the number of components per control point for any type of
45 * evaluator. Return 0 if bad target.
46 * See table 5.1 in the OpenGL 1.2 spec.
48 GLuint
_mesa_evaluator_components( GLenum target
)
51 case GL_MAP1_VERTEX_3
: return 3;
52 case GL_MAP1_VERTEX_4
: return 4;
53 case GL_MAP1_INDEX
: return 1;
54 case GL_MAP1_COLOR_4
: return 4;
55 case GL_MAP1_NORMAL
: return 3;
56 case GL_MAP1_TEXTURE_COORD_1
: return 1;
57 case GL_MAP1_TEXTURE_COORD_2
: return 2;
58 case GL_MAP1_TEXTURE_COORD_3
: return 3;
59 case GL_MAP1_TEXTURE_COORD_4
: return 4;
60 case GL_MAP2_VERTEX_3
: return 3;
61 case GL_MAP2_VERTEX_4
: return 4;
62 case GL_MAP2_INDEX
: return 1;
63 case GL_MAP2_COLOR_4
: return 4;
64 case GL_MAP2_NORMAL
: return 3;
65 case GL_MAP2_TEXTURE_COORD_1
: return 1;
66 case GL_MAP2_TEXTURE_COORD_2
: return 2;
67 case GL_MAP2_TEXTURE_COORD_3
: return 3;
68 case GL_MAP2_TEXTURE_COORD_4
: return 4;
72 /* XXX need to check for the vertex program extension
73 if (!ctx->Extensions.NV_vertex_program)
77 if (target
>= GL_MAP1_VERTEX_ATTRIB0_4_NV
&&
78 target
<= GL_MAP1_VERTEX_ATTRIB15_4_NV
)
81 if (target
>= GL_MAP2_VERTEX_ATTRIB0_4_NV
&&
82 target
<= GL_MAP2_VERTEX_ATTRIB15_4_NV
)
90 * Return pointer to the gl_1d_map struct for the named target.
92 static struct gl_1d_map
*
93 get_1d_map( struct gl_context
*ctx
, GLenum target
)
96 case GL_MAP1_VERTEX_3
:
97 return &ctx
->EvalMap
.Map1Vertex3
;
98 case GL_MAP1_VERTEX_4
:
99 return &ctx
->EvalMap
.Map1Vertex4
;
101 return &ctx
->EvalMap
.Map1Index
;
102 case GL_MAP1_COLOR_4
:
103 return &ctx
->EvalMap
.Map1Color4
;
105 return &ctx
->EvalMap
.Map1Normal
;
106 case GL_MAP1_TEXTURE_COORD_1
:
107 return &ctx
->EvalMap
.Map1Texture1
;
108 case GL_MAP1_TEXTURE_COORD_2
:
109 return &ctx
->EvalMap
.Map1Texture2
;
110 case GL_MAP1_TEXTURE_COORD_3
:
111 return &ctx
->EvalMap
.Map1Texture3
;
112 case GL_MAP1_TEXTURE_COORD_4
:
113 return &ctx
->EvalMap
.Map1Texture4
;
121 * Return pointer to the gl_2d_map struct for the named target.
123 static struct gl_2d_map
*
124 get_2d_map( struct gl_context
*ctx
, GLenum target
)
127 case GL_MAP2_VERTEX_3
:
128 return &ctx
->EvalMap
.Map2Vertex3
;
129 case GL_MAP2_VERTEX_4
:
130 return &ctx
->EvalMap
.Map2Vertex4
;
132 return &ctx
->EvalMap
.Map2Index
;
133 case GL_MAP2_COLOR_4
:
134 return &ctx
->EvalMap
.Map2Color4
;
136 return &ctx
->EvalMap
.Map2Normal
;
137 case GL_MAP2_TEXTURE_COORD_1
:
138 return &ctx
->EvalMap
.Map2Texture1
;
139 case GL_MAP2_TEXTURE_COORD_2
:
140 return &ctx
->EvalMap
.Map2Texture2
;
141 case GL_MAP2_TEXTURE_COORD_3
:
142 return &ctx
->EvalMap
.Map2Texture3
;
143 case GL_MAP2_TEXTURE_COORD_4
:
144 return &ctx
->EvalMap
.Map2Texture4
;
151 /**********************************************************************/
152 /*** Copy and deallocate control points ***/
153 /**********************************************************************/
157 * Copy 1-parametric evaluator control points from user-specified
158 * memory space to a buffer of contiguous control points.
159 * \param see glMap1f for details
160 * \return pointer to buffer of contiguous control points or NULL if out
163 GLfloat
*_mesa_copy_map_points1f( GLenum target
, GLint ustride
, GLint uorder
,
164 const GLfloat
*points
)
167 GLint i
, k
, size
= _mesa_evaluator_components(target
);
169 if (!points
|| !size
)
172 buffer
= (GLfloat
*) MALLOC(uorder
* size
* sizeof(GLfloat
));
175 for (i
= 0, p
= buffer
; i
< uorder
; i
++, points
+= ustride
)
176 for (k
= 0; k
< size
; k
++)
185 * Same as above but convert doubles to floats.
187 GLfloat
*_mesa_copy_map_points1d( GLenum target
, GLint ustride
, GLint uorder
,
188 const GLdouble
*points
)
191 GLint i
, k
, size
= _mesa_evaluator_components(target
);
193 if (!points
|| !size
)
196 buffer
= (GLfloat
*) MALLOC(uorder
* size
* sizeof(GLfloat
));
199 for (i
= 0, p
= buffer
; i
< uorder
; i
++, points
+= ustride
)
200 for (k
= 0; k
< size
; k
++)
201 *p
++ = (GLfloat
) points
[k
];
209 * Copy 2-parametric evaluator control points from user-specified
210 * memory space to a buffer of contiguous control points.
211 * Additional memory is allocated to be used by the horner and
212 * de Casteljau evaluation schemes.
214 * \param see glMap2f for details
215 * \return pointer to buffer of contiguous control points or NULL if out
218 GLfloat
*_mesa_copy_map_points2f( GLenum target
,
219 GLint ustride
, GLint uorder
,
220 GLint vstride
, GLint vorder
,
221 const GLfloat
*points
)
224 GLint i
, j
, k
, size
, dsize
, hsize
;
227 size
= _mesa_evaluator_components(target
);
229 if (!points
|| size
==0) {
233 /* max(uorder, vorder) additional points are used in */
234 /* horner evaluation and uorder*vorder additional */
235 /* values are needed for de Casteljau */
236 dsize
= (uorder
== 2 && vorder
== 2)? 0 : uorder
*vorder
;
237 hsize
= (uorder
> vorder
? uorder
: vorder
)*size
;
240 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+hsize
)*sizeof(GLfloat
));
242 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+dsize
)*sizeof(GLfloat
));
244 /* compute the increment value for the u-loop */
245 uinc
= ustride
- vorder
*vstride
;
248 for (i
=0, p
=buffer
; i
<uorder
; i
++, points
+= uinc
)
249 for (j
=0; j
<vorder
; j
++, points
+= vstride
)
250 for (k
=0; k
<size
; k
++)
259 * Same as above but convert doubles to floats.
261 GLfloat
*_mesa_copy_map_points2d(GLenum target
,
262 GLint ustride
, GLint uorder
,
263 GLint vstride
, GLint vorder
,
264 const GLdouble
*points
)
267 GLint i
, j
, k
, size
, hsize
, dsize
;
270 size
= _mesa_evaluator_components(target
);
272 if (!points
|| size
==0) {
276 /* max(uorder, vorder) additional points are used in */
277 /* horner evaluation and uorder*vorder additional */
278 /* values are needed for de Casteljau */
279 dsize
= (uorder
== 2 && vorder
== 2)? 0 : uorder
*vorder
;
280 hsize
= (uorder
> vorder
? uorder
: vorder
)*size
;
283 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+hsize
)*sizeof(GLfloat
));
285 buffer
= (GLfloat
*) MALLOC((uorder
*vorder
*size
+dsize
)*sizeof(GLfloat
));
287 /* compute the increment value for the u-loop */
288 uinc
= ustride
- vorder
*vstride
;
291 for (i
=0, p
=buffer
; i
<uorder
; i
++, points
+= uinc
)
292 for (j
=0; j
<vorder
; j
++, points
+= vstride
)
293 for (k
=0; k
<size
; k
++)
294 *p
++ = (GLfloat
) points
[k
];
302 /**********************************************************************/
303 /*** API entry points ***/
304 /**********************************************************************/
308 * This does the work of glMap1[fd].
311 map1(GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustride
,
312 GLint uorder
, const GLvoid
*points
, GLenum type
)
314 GET_CURRENT_CONTEXT(ctx
);
317 struct gl_1d_map
*map
= NULL
;
319 ASSERT_OUTSIDE_BEGIN_END(ctx
);
320 ASSERT(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
323 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(u1,u2)" );
326 if (uorder
< 1 || uorder
> MAX_EVAL_ORDER
) {
327 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(order)" );
331 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(points)" );
335 k
= _mesa_evaluator_components( target
);
337 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
341 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(stride)" );
345 map
= get_1d_map(ctx
, target
);
347 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
351 /* make copy of the control points */
352 if (type
== GL_FLOAT
)
353 pnts
= _mesa_copy_map_points1f(target
, ustride
, uorder
, (GLfloat
*) points
);
355 pnts
= _mesa_copy_map_points1d(target
, ustride
, uorder
, (GLdouble
*) points
);
358 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
362 map
->du
= 1.0F
/ (u2
- u1
);
370 static void GLAPIENTRY
371 _mesa_Map1f( GLenum target
, GLfloat u1
, GLfloat u2
, GLint stride
,
372 GLint order
, const GLfloat
*points
)
374 map1(target
, u1
, u2
, stride
, order
, points
, GL_FLOAT
);
378 static void GLAPIENTRY
379 _mesa_Map1d( GLenum target
, GLdouble u1
, GLdouble u2
, GLint stride
,
380 GLint order
, const GLdouble
*points
)
382 map1(target
, (GLfloat
) u1
, (GLfloat
) u2
, stride
, order
, points
, GL_DOUBLE
);
387 map2( GLenum target
, GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
388 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
389 const GLvoid
*points
, GLenum type
)
391 GET_CURRENT_CONTEXT(ctx
);
394 struct gl_2d_map
*map
= NULL
;
396 ASSERT_OUTSIDE_BEGIN_END(ctx
);
397 ASSERT(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
400 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(u1,u2)" );
405 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(v1,v2)" );
409 if (uorder
<1 || uorder
>MAX_EVAL_ORDER
) {
410 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(uorder)" );
414 if (vorder
<1 || vorder
>MAX_EVAL_ORDER
) {
415 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(vorder)" );
419 k
= _mesa_evaluator_components( target
);
421 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
425 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(ustride)" );
429 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(vstride)" );
433 map
= get_2d_map(ctx
, target
);
435 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
439 /* make copy of the control points */
440 if (type
== GL_FLOAT
)
441 pnts
= _mesa_copy_map_points2f(target
, ustride
, uorder
,
442 vstride
, vorder
, (GLfloat
*) points
);
444 pnts
= _mesa_copy_map_points2d(target
, ustride
, uorder
,
445 vstride
, vorder
, (GLdouble
*) points
);
448 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
449 map
->Uorder
= uorder
;
452 map
->du
= 1.0F
/ (u2
- u1
);
453 map
->Vorder
= vorder
;
456 map
->dv
= 1.0F
/ (v2
- v1
);
463 static void GLAPIENTRY
464 _mesa_Map2f( GLenum target
,
465 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
466 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
467 const GLfloat
*points
)
469 map2(target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
,
474 static void GLAPIENTRY
475 _mesa_Map2d( GLenum target
,
476 GLdouble u1
, GLdouble u2
, GLint ustride
, GLint uorder
,
477 GLdouble v1
, GLdouble v2
, GLint vstride
, GLint vorder
,
478 const GLdouble
*points
)
480 map2(target
, (GLfloat
) u1
, (GLfloat
) u2
, ustride
, uorder
,
481 (GLfloat
) v1
, (GLfloat
) v2
, vstride
, vorder
, points
, GL_DOUBLE
);
486 static void GLAPIENTRY
487 _mesa_GetMapdv( GLenum target
, GLenum query
, GLdouble
*v
)
489 GET_CURRENT_CONTEXT(ctx
);
490 struct gl_1d_map
*map1d
;
491 struct gl_2d_map
*map2d
;
496 ASSERT_OUTSIDE_BEGIN_END(ctx
);
498 comps
= _mesa_evaluator_components(target
);
500 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(target)" );
504 map1d
= get_1d_map(ctx
, target
);
505 map2d
= get_2d_map(ctx
, target
);
506 ASSERT(map1d
|| map2d
);
511 data
= map1d
->Points
;
512 n
= map1d
->Order
* comps
;
515 data
= map2d
->Points
;
516 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
526 v
[0] = (GLdouble
) map1d
->Order
;
529 v
[0] = (GLdouble
) map2d
->Uorder
;
530 v
[1] = (GLdouble
) map2d
->Vorder
;
535 v
[0] = (GLdouble
) map1d
->u1
;
536 v
[1] = (GLdouble
) map1d
->u2
;
539 v
[0] = (GLdouble
) map2d
->u1
;
540 v
[1] = (GLdouble
) map2d
->u2
;
541 v
[2] = (GLdouble
) map2d
->v1
;
542 v
[3] = (GLdouble
) map2d
->v2
;
546 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(query)" );
551 static void GLAPIENTRY
552 _mesa_GetMapfv( GLenum target
, GLenum query
, GLfloat
*v
)
554 GET_CURRENT_CONTEXT(ctx
);
555 struct gl_1d_map
*map1d
;
556 struct gl_2d_map
*map2d
;
561 ASSERT_OUTSIDE_BEGIN_END(ctx
);
563 comps
= _mesa_evaluator_components(target
);
565 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(target)" );
569 map1d
= get_1d_map(ctx
, target
);
570 map2d
= get_2d_map(ctx
, target
);
571 ASSERT(map1d
|| map2d
);
576 data
= map1d
->Points
;
577 n
= map1d
->Order
* comps
;
580 data
= map2d
->Points
;
581 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
591 v
[0] = (GLfloat
) map1d
->Order
;
594 v
[0] = (GLfloat
) map2d
->Uorder
;
595 v
[1] = (GLfloat
) map2d
->Vorder
;
611 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(query)" );
617 static void GLAPIENTRY
618 _mesa_GetMapiv( GLenum target
, GLenum query
, GLint
*v
)
620 GET_CURRENT_CONTEXT(ctx
);
621 struct gl_1d_map
*map1d
;
622 struct gl_2d_map
*map2d
;
627 ASSERT_OUTSIDE_BEGIN_END(ctx
);
629 comps
= _mesa_evaluator_components(target
);
631 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(target)" );
635 map1d
= get_1d_map(ctx
, target
);
636 map2d
= get_2d_map(ctx
, target
);
637 ASSERT(map1d
|| map2d
);
642 data
= map1d
->Points
;
643 n
= map1d
->Order
* comps
;
646 data
= map2d
->Points
;
647 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
651 v
[i
] = IROUND(data
[i
]);
660 v
[0] = map2d
->Uorder
;
661 v
[1] = map2d
->Vorder
;
666 v
[0] = IROUND(map1d
->u1
);
667 v
[1] = IROUND(map1d
->u2
);
670 v
[0] = IROUND(map2d
->u1
);
671 v
[1] = IROUND(map2d
->u2
);
672 v
[2] = IROUND(map2d
->v1
);
673 v
[3] = IROUND(map2d
->v2
);
677 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(query)" );
683 static void GLAPIENTRY
684 _mesa_MapGrid1f( GLint un
, GLfloat u1
, GLfloat u2
)
686 GET_CURRENT_CONTEXT(ctx
);
687 ASSERT_OUTSIDE_BEGIN_END(ctx
);
690 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid1f" );
693 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
694 ctx
->Eval
.MapGrid1un
= un
;
695 ctx
->Eval
.MapGrid1u1
= u1
;
696 ctx
->Eval
.MapGrid1u2
= u2
;
697 ctx
->Eval
.MapGrid1du
= (u2
- u1
) / (GLfloat
) un
;
701 static void GLAPIENTRY
702 _mesa_MapGrid1d( GLint un
, GLdouble u1
, GLdouble u2
)
704 _mesa_MapGrid1f( un
, (GLfloat
) u1
, (GLfloat
) u2
);
708 static void GLAPIENTRY
709 _mesa_MapGrid2f( GLint un
, GLfloat u1
, GLfloat u2
,
710 GLint vn
, GLfloat v1
, GLfloat v2
)
712 GET_CURRENT_CONTEXT(ctx
);
713 ASSERT_OUTSIDE_BEGIN_END(ctx
);
716 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(un)" );
720 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(vn)" );
724 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
725 ctx
->Eval
.MapGrid2un
= un
;
726 ctx
->Eval
.MapGrid2u1
= u1
;
727 ctx
->Eval
.MapGrid2u2
= u2
;
728 ctx
->Eval
.MapGrid2du
= (u2
- u1
) / (GLfloat
) un
;
729 ctx
->Eval
.MapGrid2vn
= vn
;
730 ctx
->Eval
.MapGrid2v1
= v1
;
731 ctx
->Eval
.MapGrid2v2
= v2
;
732 ctx
->Eval
.MapGrid2dv
= (v2
- v1
) / (GLfloat
) vn
;
736 static void GLAPIENTRY
737 _mesa_MapGrid2d( GLint un
, GLdouble u1
, GLdouble u2
,
738 GLint vn
, GLdouble v1
, GLdouble v2
)
740 _mesa_MapGrid2f( un
, (GLfloat
) u1
, (GLfloat
) u2
,
741 vn
, (GLfloat
) v1
, (GLfloat
) v2
);
746 _mesa_install_eval_vtxfmt(struct _glapi_table
*disp
,
747 const GLvertexformat
*vfmt
)
749 SET_EvalCoord1f(disp
, vfmt
->EvalCoord1f
);
750 SET_EvalCoord1fv(disp
, vfmt
->EvalCoord1fv
);
751 SET_EvalCoord2f(disp
, vfmt
->EvalCoord2f
);
752 SET_EvalCoord2fv(disp
, vfmt
->EvalCoord2fv
);
753 SET_EvalPoint1(disp
, vfmt
->EvalPoint1
);
754 SET_EvalPoint2(disp
, vfmt
->EvalPoint2
);
756 SET_EvalMesh1(disp
, vfmt
->EvalMesh1
);
757 SET_EvalMesh2(disp
, vfmt
->EvalMesh2
);
762 _mesa_init_eval_dispatch(struct _glapi_table
*disp
)
764 SET_GetMapdv(disp
, _mesa_GetMapdv
);
765 SET_GetMapfv(disp
, _mesa_GetMapfv
);
766 SET_GetMapiv(disp
, _mesa_GetMapiv
);
767 SET_Map1d(disp
, _mesa_Map1d
);
768 SET_Map1f(disp
, _mesa_Map1f
);
769 SET_Map2d(disp
, _mesa_Map2d
);
770 SET_Map2f(disp
, _mesa_Map2f
);
771 SET_MapGrid1d(disp
, _mesa_MapGrid1d
);
772 SET_MapGrid1f(disp
, _mesa_MapGrid1f
);
773 SET_MapGrid2d(disp
, _mesa_MapGrid2d
);
774 SET_MapGrid2f(disp
, _mesa_MapGrid2f
);
778 #endif /* FEATURE_evaluators */
781 /**********************************************************************/
782 /***** Initialization *****/
783 /**********************************************************************/
786 * Initialize a 1-D evaluator map.
789 init_1d_map( struct gl_1d_map
*map
, int n
, const float *initial
)
794 map
->Points
= (GLfloat
*) MALLOC(n
* sizeof(GLfloat
));
798 map
->Points
[i
] = initial
[i
];
804 * Initialize a 2-D evaluator map
807 init_2d_map( struct gl_2d_map
*map
, int n
, const float *initial
)
815 map
->Points
= (GLfloat
*) MALLOC(n
* sizeof(GLfloat
));
819 map
->Points
[i
] = initial
[i
];
824 void _mesa_init_eval( struct gl_context
*ctx
)
827 /* Evaluators group */
828 ctx
->Eval
.Map1Color4
= GL_FALSE
;
829 ctx
->Eval
.Map1Index
= GL_FALSE
;
830 ctx
->Eval
.Map1Normal
= GL_FALSE
;
831 ctx
->Eval
.Map1TextureCoord1
= GL_FALSE
;
832 ctx
->Eval
.Map1TextureCoord2
= GL_FALSE
;
833 ctx
->Eval
.Map1TextureCoord3
= GL_FALSE
;
834 ctx
->Eval
.Map1TextureCoord4
= GL_FALSE
;
835 ctx
->Eval
.Map1Vertex3
= GL_FALSE
;
836 ctx
->Eval
.Map1Vertex4
= GL_FALSE
;
837 ctx
->Eval
.Map2Color4
= GL_FALSE
;
838 ctx
->Eval
.Map2Index
= GL_FALSE
;
839 ctx
->Eval
.Map2Normal
= GL_FALSE
;
840 ctx
->Eval
.Map2TextureCoord1
= GL_FALSE
;
841 ctx
->Eval
.Map2TextureCoord2
= GL_FALSE
;
842 ctx
->Eval
.Map2TextureCoord3
= GL_FALSE
;
843 ctx
->Eval
.Map2TextureCoord4
= GL_FALSE
;
844 ctx
->Eval
.Map2Vertex3
= GL_FALSE
;
845 ctx
->Eval
.Map2Vertex4
= GL_FALSE
;
846 ctx
->Eval
.AutoNormal
= GL_FALSE
;
847 ctx
->Eval
.MapGrid1un
= 1;
848 ctx
->Eval
.MapGrid1u1
= 0.0;
849 ctx
->Eval
.MapGrid1u2
= 1.0;
850 ctx
->Eval
.MapGrid2un
= 1;
851 ctx
->Eval
.MapGrid2vn
= 1;
852 ctx
->Eval
.MapGrid2u1
= 0.0;
853 ctx
->Eval
.MapGrid2u2
= 1.0;
854 ctx
->Eval
.MapGrid2v1
= 0.0;
855 ctx
->Eval
.MapGrid2v2
= 1.0;
859 static GLfloat vertex
[4] = { 0.0, 0.0, 0.0, 1.0 };
860 static GLfloat normal
[3] = { 0.0, 0.0, 1.0 };
861 static GLfloat index
[1] = { 1.0 };
862 static GLfloat color
[4] = { 1.0, 1.0, 1.0, 1.0 };
863 static GLfloat texcoord
[4] = { 0.0, 0.0, 0.0, 1.0 };
865 init_1d_map( &ctx
->EvalMap
.Map1Vertex3
, 3, vertex
);
866 init_1d_map( &ctx
->EvalMap
.Map1Vertex4
, 4, vertex
);
867 init_1d_map( &ctx
->EvalMap
.Map1Index
, 1, index
);
868 init_1d_map( &ctx
->EvalMap
.Map1Color4
, 4, color
);
869 init_1d_map( &ctx
->EvalMap
.Map1Normal
, 3, normal
);
870 init_1d_map( &ctx
->EvalMap
.Map1Texture1
, 1, texcoord
);
871 init_1d_map( &ctx
->EvalMap
.Map1Texture2
, 2, texcoord
);
872 init_1d_map( &ctx
->EvalMap
.Map1Texture3
, 3, texcoord
);
873 init_1d_map( &ctx
->EvalMap
.Map1Texture4
, 4, texcoord
);
875 init_2d_map( &ctx
->EvalMap
.Map2Vertex3
, 3, vertex
);
876 init_2d_map( &ctx
->EvalMap
.Map2Vertex4
, 4, vertex
);
877 init_2d_map( &ctx
->EvalMap
.Map2Index
, 1, index
);
878 init_2d_map( &ctx
->EvalMap
.Map2Color4
, 4, color
);
879 init_2d_map( &ctx
->EvalMap
.Map2Normal
, 3, normal
);
880 init_2d_map( &ctx
->EvalMap
.Map2Texture1
, 1, texcoord
);
881 init_2d_map( &ctx
->EvalMap
.Map2Texture2
, 2, texcoord
);
882 init_2d_map( &ctx
->EvalMap
.Map2Texture3
, 3, texcoord
);
883 init_2d_map( &ctx
->EvalMap
.Map2Texture4
, 4, texcoord
);
888 void _mesa_free_eval_data( struct gl_context
*ctx
)
890 /* Free evaluator data */
891 if (ctx
->EvalMap
.Map1Vertex3
.Points
)
892 FREE( ctx
->EvalMap
.Map1Vertex3
.Points
);
893 if (ctx
->EvalMap
.Map1Vertex4
.Points
)
894 FREE( ctx
->EvalMap
.Map1Vertex4
.Points
);
895 if (ctx
->EvalMap
.Map1Index
.Points
)
896 FREE( ctx
->EvalMap
.Map1Index
.Points
);
897 if (ctx
->EvalMap
.Map1Color4
.Points
)
898 FREE( ctx
->EvalMap
.Map1Color4
.Points
);
899 if (ctx
->EvalMap
.Map1Normal
.Points
)
900 FREE( ctx
->EvalMap
.Map1Normal
.Points
);
901 if (ctx
->EvalMap
.Map1Texture1
.Points
)
902 FREE( ctx
->EvalMap
.Map1Texture1
.Points
);
903 if (ctx
->EvalMap
.Map1Texture2
.Points
)
904 FREE( ctx
->EvalMap
.Map1Texture2
.Points
);
905 if (ctx
->EvalMap
.Map1Texture3
.Points
)
906 FREE( ctx
->EvalMap
.Map1Texture3
.Points
);
907 if (ctx
->EvalMap
.Map1Texture4
.Points
)
908 FREE( ctx
->EvalMap
.Map1Texture4
.Points
);
910 if (ctx
->EvalMap
.Map2Vertex3
.Points
)
911 FREE( ctx
->EvalMap
.Map2Vertex3
.Points
);
912 if (ctx
->EvalMap
.Map2Vertex4
.Points
)
913 FREE( ctx
->EvalMap
.Map2Vertex4
.Points
);
914 if (ctx
->EvalMap
.Map2Index
.Points
)
915 FREE( ctx
->EvalMap
.Map2Index
.Points
);
916 if (ctx
->EvalMap
.Map2Color4
.Points
)
917 FREE( ctx
->EvalMap
.Map2Color4
.Points
);
918 if (ctx
->EvalMap
.Map2Normal
.Points
)
919 FREE( ctx
->EvalMap
.Map2Normal
.Points
);
920 if (ctx
->EvalMap
.Map2Texture1
.Points
)
921 FREE( ctx
->EvalMap
.Map2Texture1
.Points
);
922 if (ctx
->EvalMap
.Map2Texture2
.Points
)
923 FREE( ctx
->EvalMap
.Map2Texture2
.Points
);
924 if (ctx
->EvalMap
.Map2Texture3
.Points
)
925 FREE( ctx
->EvalMap
.Map2Texture3
.Points
);
926 if (ctx
->EvalMap
.Map2Texture4
.Points
)
927 FREE( ctx
->EvalMap
.Map2Texture4
.Points
);