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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * 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.
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(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
317 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(u1,u2)" );
320 if (uorder
< 1 || uorder
> MAX_EVAL_ORDER
) {
321 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(order)" );
325 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(points)" );
329 k
= _mesa_evaluator_components( target
);
331 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
336 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap1(stride)" );
340 if (ctx
->Texture
.CurrentUnit
!= 0) {
341 /* See OpenGL 1.2.1 spec, section F.2.13 */
342 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glMap2(ACTIVE_TEXTURE != 0)" );
346 map
= get_1d_map(ctx
, target
);
348 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap1(target)" );
352 /* make copy of the control points */
353 if (type
== GL_FLOAT
)
354 pnts
= _mesa_copy_map_points1f(target
, ustride
, uorder
, (GLfloat
*) points
);
356 pnts
= _mesa_copy_map_points1d(target
, ustride
, uorder
, (GLdouble
*) points
);
359 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
363 map
->du
= 1.0F
/ (u2
- u1
);
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
);
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(type
== GL_FLOAT
|| type
== GL_DOUBLE
);
399 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(u1,u2)" );
404 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(v1,v2)" );
408 if (uorder
<1 || uorder
>MAX_EVAL_ORDER
) {
409 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(uorder)" );
413 if (vorder
<1 || vorder
>MAX_EVAL_ORDER
) {
414 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMap2(vorder)" );
418 k
= _mesa_evaluator_components( target
);
420 _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 if (ctx
->Texture
.CurrentUnit
!= 0) {
434 /* See OpenGL 1.2.1 spec, section F.2.13 */
435 _mesa_error( ctx
, GL_INVALID_OPERATION
, "glMap2(ACTIVE_TEXTURE != 0)" );
439 map
= get_2d_map(ctx
, target
);
441 _mesa_error( ctx
, GL_INVALID_ENUM
, "glMap2(target)" );
445 /* make copy of the control points */
446 if (type
== GL_FLOAT
)
447 pnts
= _mesa_copy_map_points2f(target
, ustride
, uorder
,
448 vstride
, vorder
, (GLfloat
*) points
);
450 pnts
= _mesa_copy_map_points2d(target
, ustride
, uorder
,
451 vstride
, vorder
, (GLdouble
*) points
);
454 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
455 map
->Uorder
= uorder
;
458 map
->du
= 1.0F
/ (u2
- u1
);
459 map
->Vorder
= vorder
;
462 map
->dv
= 1.0F
/ (v2
- v1
);
469 _mesa_Map2f( GLenum target
,
470 GLfloat u1
, GLfloat u2
, GLint ustride
, GLint uorder
,
471 GLfloat v1
, GLfloat v2
, GLint vstride
, GLint vorder
,
472 const GLfloat
*points
)
474 map2(target
, u1
, u2
, ustride
, uorder
, v1
, v2
, vstride
, vorder
,
480 _mesa_Map2d( GLenum target
,
481 GLdouble u1
, GLdouble u2
, GLint ustride
, GLint uorder
,
482 GLdouble v1
, GLdouble v2
, GLint vstride
, GLint vorder
,
483 const GLdouble
*points
)
485 map2(target
, (GLfloat
) u1
, (GLfloat
) u2
, ustride
, uorder
,
486 (GLfloat
) v1
, (GLfloat
) v2
, vstride
, vorder
, points
, GL_DOUBLE
);
492 _mesa_GetnMapdvARB( GLenum target
, GLenum query
, GLsizei bufSize
, GLdouble
*v
)
494 GET_CURRENT_CONTEXT(ctx
);
495 struct gl_1d_map
*map1d
;
496 struct gl_2d_map
*map2d
;
502 comps
= _mesa_evaluator_components(target
);
504 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(target)" );
508 map1d
= get_1d_map(ctx
, target
);
509 map2d
= get_2d_map(ctx
, target
);
510 ASSERT(map1d
|| map2d
);
515 data
= map1d
->Points
;
516 n
= map1d
->Order
* comps
;
519 data
= map2d
->Points
;
520 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
523 numBytes
= n
* sizeof *v
;
524 if (bufSize
< numBytes
)
533 numBytes
= 1 * sizeof *v
;
534 if (bufSize
< numBytes
)
536 v
[0] = (GLdouble
) map1d
->Order
;
539 numBytes
= 2 * sizeof *v
;
540 if (bufSize
< numBytes
)
542 v
[0] = (GLdouble
) map2d
->Uorder
;
543 v
[1] = (GLdouble
) map2d
->Vorder
;
548 numBytes
= 2 * sizeof *v
;
549 if (bufSize
< numBytes
)
551 v
[0] = (GLdouble
) map1d
->u1
;
552 v
[1] = (GLdouble
) map1d
->u2
;
555 numBytes
= 4 * sizeof *v
;
556 if (bufSize
< numBytes
)
558 v
[0] = (GLdouble
) map2d
->u1
;
559 v
[1] = (GLdouble
) map2d
->u2
;
560 v
[2] = (GLdouble
) map2d
->v1
;
561 v
[3] = (GLdouble
) map2d
->v2
;
565 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapdv(query)" );
570 _mesa_error( ctx
, GL_INVALID_OPERATION
,
571 "glGetnMapdvARB(out of bounds: bufSize is %d,"
572 " but %d bytes are required)", bufSize
, numBytes
);
576 _mesa_GetMapdv( GLenum target
, GLenum query
, GLdouble
*v
)
578 _mesa_GetnMapdvARB(target
, query
, INT_MAX
, v
);
582 _mesa_GetnMapfvARB( GLenum target
, GLenum query
, GLsizei bufSize
, GLfloat
*v
)
584 GET_CURRENT_CONTEXT(ctx
);
585 struct gl_1d_map
*map1d
;
586 struct gl_2d_map
*map2d
;
592 comps
= _mesa_evaluator_components(target
);
594 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(target)" );
598 map1d
= get_1d_map(ctx
, target
);
599 map2d
= get_2d_map(ctx
, target
);
600 ASSERT(map1d
|| map2d
);
605 data
= map1d
->Points
;
606 n
= map1d
->Order
* comps
;
609 data
= map2d
->Points
;
610 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
613 numBytes
= n
* sizeof *v
;
614 if (bufSize
< numBytes
)
623 numBytes
= 1 * sizeof *v
;
624 if (bufSize
< numBytes
)
626 v
[0] = (GLfloat
) map1d
->Order
;
629 numBytes
= 2 * sizeof *v
;
630 if (bufSize
< numBytes
)
632 v
[0] = (GLfloat
) map2d
->Uorder
;
633 v
[1] = (GLfloat
) map2d
->Vorder
;
638 numBytes
= 2 * sizeof *v
;
639 if (bufSize
< numBytes
)
645 numBytes
= 4 * sizeof *v
;
646 if (bufSize
< numBytes
)
655 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapfv(query)" );
660 _mesa_error( ctx
, GL_INVALID_OPERATION
,
661 "glGetnMapfvARB(out of bounds: bufSize is %d,"
662 " but %d bytes are required)", bufSize
, numBytes
);
667 _mesa_GetMapfv( GLenum target
, GLenum query
, GLfloat
*v
)
669 _mesa_GetnMapfvARB(target
, query
, INT_MAX
, v
);
674 _mesa_GetnMapivARB( GLenum target
, GLenum query
, GLsizei bufSize
, GLint
*v
)
676 GET_CURRENT_CONTEXT(ctx
);
677 struct gl_1d_map
*map1d
;
678 struct gl_2d_map
*map2d
;
684 comps
= _mesa_evaluator_components(target
);
686 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(target)" );
690 map1d
= get_1d_map(ctx
, target
);
691 map2d
= get_2d_map(ctx
, target
);
692 ASSERT(map1d
|| map2d
);
697 data
= map1d
->Points
;
698 n
= map1d
->Order
* comps
;
701 data
= map2d
->Points
;
702 n
= map2d
->Uorder
* map2d
->Vorder
* comps
;
705 numBytes
= n
* sizeof *v
;
706 if (bufSize
< numBytes
)
709 v
[i
] = IROUND(data
[i
]);
715 numBytes
= 1 * sizeof *v
;
716 if (bufSize
< numBytes
)
721 numBytes
= 2 * sizeof *v
;
722 if (bufSize
< numBytes
)
724 v
[0] = map2d
->Uorder
;
725 v
[1] = map2d
->Vorder
;
730 numBytes
= 2 * sizeof *v
;
731 if (bufSize
< numBytes
)
733 v
[0] = IROUND(map1d
->u1
);
734 v
[1] = IROUND(map1d
->u2
);
737 numBytes
= 4 * sizeof *v
;
738 if (bufSize
< numBytes
)
740 v
[0] = IROUND(map2d
->u1
);
741 v
[1] = IROUND(map2d
->u2
);
742 v
[2] = IROUND(map2d
->v1
);
743 v
[3] = IROUND(map2d
->v2
);
747 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetMapiv(query)" );
752 _mesa_error( ctx
, GL_INVALID_OPERATION
,
753 "glGetnMapivARB(out of bounds: bufSize is %d,"
754 " but %d bytes are required)", bufSize
, numBytes
);
759 _mesa_GetMapiv( GLenum target
, GLenum query
, GLint
*v
)
761 _mesa_GetnMapivARB(target
, query
, INT_MAX
, v
);
766 _mesa_MapGrid1f( GLint un
, GLfloat u1
, GLfloat u2
)
768 GET_CURRENT_CONTEXT(ctx
);
771 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid1f" );
774 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
775 ctx
->Eval
.MapGrid1un
= un
;
776 ctx
->Eval
.MapGrid1u1
= u1
;
777 ctx
->Eval
.MapGrid1u2
= u2
;
778 ctx
->Eval
.MapGrid1du
= (u2
- u1
) / (GLfloat
) un
;
783 _mesa_MapGrid1d( GLint un
, GLdouble u1
, GLdouble u2
)
785 _mesa_MapGrid1f( un
, (GLfloat
) u1
, (GLfloat
) u2
);
790 _mesa_MapGrid2f( GLint un
, GLfloat u1
, GLfloat u2
,
791 GLint vn
, GLfloat v1
, GLfloat v2
)
793 GET_CURRENT_CONTEXT(ctx
);
796 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(un)" );
800 _mesa_error( ctx
, GL_INVALID_VALUE
, "glMapGrid2f(vn)" );
804 FLUSH_VERTICES(ctx
, _NEW_EVAL
);
805 ctx
->Eval
.MapGrid2un
= un
;
806 ctx
->Eval
.MapGrid2u1
= u1
;
807 ctx
->Eval
.MapGrid2u2
= u2
;
808 ctx
->Eval
.MapGrid2du
= (u2
- u1
) / (GLfloat
) un
;
809 ctx
->Eval
.MapGrid2vn
= vn
;
810 ctx
->Eval
.MapGrid2v1
= v1
;
811 ctx
->Eval
.MapGrid2v2
= v2
;
812 ctx
->Eval
.MapGrid2dv
= (v2
- v1
) / (GLfloat
) vn
;
817 _mesa_MapGrid2d( GLint un
, GLdouble u1
, GLdouble u2
,
818 GLint vn
, GLdouble v1
, GLdouble v2
)
820 _mesa_MapGrid2f( un
, (GLfloat
) u1
, (GLfloat
) u2
,
821 vn
, (GLfloat
) v1
, (GLfloat
) v2
);
826 _mesa_install_eval_vtxfmt(struct _glapi_table
*disp
,
827 const GLvertexformat
*vfmt
)
829 SET_EvalCoord1f(disp
, vfmt
->EvalCoord1f
);
830 SET_EvalCoord1fv(disp
, vfmt
->EvalCoord1fv
);
831 SET_EvalCoord2f(disp
, vfmt
->EvalCoord2f
);
832 SET_EvalCoord2fv(disp
, vfmt
->EvalCoord2fv
);
833 SET_EvalPoint1(disp
, vfmt
->EvalPoint1
);
834 SET_EvalPoint2(disp
, vfmt
->EvalPoint2
);
838 /**********************************************************************/
839 /***** Initialization *****/
840 /**********************************************************************/
843 * Initialize a 1-D evaluator map.
846 init_1d_map( struct gl_1d_map
*map
, int n
, const float *initial
)
851 map
->Points
= malloc(n
* sizeof(GLfloat
));
855 map
->Points
[i
] = initial
[i
];
861 * Initialize a 2-D evaluator map
864 init_2d_map( struct gl_2d_map
*map
, int n
, const float *initial
)
872 map
->Points
= malloc(n
* sizeof(GLfloat
));
876 map
->Points
[i
] = initial
[i
];
881 void _mesa_init_eval( struct gl_context
*ctx
)
883 /* Evaluators group */
884 ctx
->Eval
.Map1Color4
= GL_FALSE
;
885 ctx
->Eval
.Map1Index
= GL_FALSE
;
886 ctx
->Eval
.Map1Normal
= GL_FALSE
;
887 ctx
->Eval
.Map1TextureCoord1
= GL_FALSE
;
888 ctx
->Eval
.Map1TextureCoord2
= GL_FALSE
;
889 ctx
->Eval
.Map1TextureCoord3
= GL_FALSE
;
890 ctx
->Eval
.Map1TextureCoord4
= GL_FALSE
;
891 ctx
->Eval
.Map1Vertex3
= GL_FALSE
;
892 ctx
->Eval
.Map1Vertex4
= GL_FALSE
;
893 ctx
->Eval
.Map2Color4
= GL_FALSE
;
894 ctx
->Eval
.Map2Index
= GL_FALSE
;
895 ctx
->Eval
.Map2Normal
= GL_FALSE
;
896 ctx
->Eval
.Map2TextureCoord1
= GL_FALSE
;
897 ctx
->Eval
.Map2TextureCoord2
= GL_FALSE
;
898 ctx
->Eval
.Map2TextureCoord3
= GL_FALSE
;
899 ctx
->Eval
.Map2TextureCoord4
= GL_FALSE
;
900 ctx
->Eval
.Map2Vertex3
= GL_FALSE
;
901 ctx
->Eval
.Map2Vertex4
= GL_FALSE
;
902 ctx
->Eval
.AutoNormal
= GL_FALSE
;
903 ctx
->Eval
.MapGrid1un
= 1;
904 ctx
->Eval
.MapGrid1u1
= 0.0;
905 ctx
->Eval
.MapGrid1u2
= 1.0;
906 ctx
->Eval
.MapGrid2un
= 1;
907 ctx
->Eval
.MapGrid2vn
= 1;
908 ctx
->Eval
.MapGrid2u1
= 0.0;
909 ctx
->Eval
.MapGrid2u2
= 1.0;
910 ctx
->Eval
.MapGrid2v1
= 0.0;
911 ctx
->Eval
.MapGrid2v2
= 1.0;
915 static GLfloat vertex
[4] = { 0.0, 0.0, 0.0, 1.0 };
916 static GLfloat normal
[3] = { 0.0, 0.0, 1.0 };
917 static GLfloat index
[1] = { 1.0 };
918 static GLfloat color
[4] = { 1.0, 1.0, 1.0, 1.0 };
919 static GLfloat texcoord
[4] = { 0.0, 0.0, 0.0, 1.0 };
921 init_1d_map( &ctx
->EvalMap
.Map1Vertex3
, 3, vertex
);
922 init_1d_map( &ctx
->EvalMap
.Map1Vertex4
, 4, vertex
);
923 init_1d_map( &ctx
->EvalMap
.Map1Index
, 1, index
);
924 init_1d_map( &ctx
->EvalMap
.Map1Color4
, 4, color
);
925 init_1d_map( &ctx
->EvalMap
.Map1Normal
, 3, normal
);
926 init_1d_map( &ctx
->EvalMap
.Map1Texture1
, 1, texcoord
);
927 init_1d_map( &ctx
->EvalMap
.Map1Texture2
, 2, texcoord
);
928 init_1d_map( &ctx
->EvalMap
.Map1Texture3
, 3, texcoord
);
929 init_1d_map( &ctx
->EvalMap
.Map1Texture4
, 4, texcoord
);
931 init_2d_map( &ctx
->EvalMap
.Map2Vertex3
, 3, vertex
);
932 init_2d_map( &ctx
->EvalMap
.Map2Vertex4
, 4, vertex
);
933 init_2d_map( &ctx
->EvalMap
.Map2Index
, 1, index
);
934 init_2d_map( &ctx
->EvalMap
.Map2Color4
, 4, color
);
935 init_2d_map( &ctx
->EvalMap
.Map2Normal
, 3, normal
);
936 init_2d_map( &ctx
->EvalMap
.Map2Texture1
, 1, texcoord
);
937 init_2d_map( &ctx
->EvalMap
.Map2Texture2
, 2, texcoord
);
938 init_2d_map( &ctx
->EvalMap
.Map2Texture3
, 3, texcoord
);
939 init_2d_map( &ctx
->EvalMap
.Map2Texture4
, 4, texcoord
);
944 void _mesa_free_eval_data( struct gl_context
*ctx
)
946 /* Free evaluator data */
947 free(ctx
->EvalMap
.Map1Vertex3
.Points
);
948 free(ctx
->EvalMap
.Map1Vertex4
.Points
);
949 free(ctx
->EvalMap
.Map1Index
.Points
);
950 free(ctx
->EvalMap
.Map1Color4
.Points
);
951 free(ctx
->EvalMap
.Map1Normal
.Points
);
952 free(ctx
->EvalMap
.Map1Texture1
.Points
);
953 free(ctx
->EvalMap
.Map1Texture2
.Points
);
954 free(ctx
->EvalMap
.Map1Texture3
.Points
);
955 free(ctx
->EvalMap
.Map1Texture4
.Points
);
957 free(ctx
->EvalMap
.Map2Vertex3
.Points
);
958 free(ctx
->EvalMap
.Map2Vertex4
.Points
);
959 free(ctx
->EvalMap
.Map2Index
.Points
);
960 free(ctx
->EvalMap
.Map2Color4
.Points
);
961 free(ctx
->EvalMap
.Map2Normal
.Points
);
962 free(ctx
->EvalMap
.Map2Texture1
.Points
);
963 free(ctx
->EvalMap
.Map2Texture2
.Points
);
964 free(ctx
->EvalMap
.Map2Texture3
.Points
);
965 free(ctx
->EvalMap
.Map2Texture4
.Points
);