1afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
3afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Mesa 3-D graphics library
427558a160a9fe91745728d7626995cd88f8fe339Brian Paul * Version:  5.1
55e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
627558a160a9fe91745728d7626995cd88f8fe339Brian Paul * Copyright (C) 1999-2003  Brian Paul   All Rights Reserved.
75e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
8afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Permission is hereby granted, free of charge, to any person obtaining a
9afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * copy of this software and associated documentation files (the "Software"),
10afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * to deal in the Software without restriction, including without limitation
11afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * and/or sell copies of the Software, and to permit persons to whom the
13afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Software is furnished to do so, subject to the following conditions:
145e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
15afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * The above copyright notice and this permission notice shall be included
16afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * in all copies or substantial portions of the Software.
175e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen *
18afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
25afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
26afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
27afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
28afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * eval.c was written by
29afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
30afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
31afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
32afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * My original implementation of evaluators was simplistic and didn't
33afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * compute surface normal vectors properly.  Bernd and Volker applied
34afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * used more sophisticated methods to get better results.
35afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
36afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Thanks guys!
37afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
38afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
39afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
40fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul#include "glheader.h"
413c63452e64df7e10aa073c6c3b9492b1d7dabbb8Brian Paul#include "imports.h"
42c893a015d8a50a38cd3f727d99835e7e7e2ccea9Brian Paul#include "colormac.h"
43afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "context.h"
44afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "eval.h"
45afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg#include "macros.h"
46db61b9ce39bccc43140357652ceb78baaf2aea44Vinson Lee#include "mfeatures.h"
475e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen#include "mtypes.h"
482cf44390d1e819f23e1d7ceb3199276c9148c647Chia-I Wu#include "main/dispatch.h"
49aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
50aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
51aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu#if FEATURE_evaluators
52afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
53afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
54afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
55afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Return the number of components per control point for any type of
56afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * evaluator.  Return 0 if bad target.
57fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul * See table 5.1 in the OpenGL 1.2 spec.
58afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
59fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian PaulGLuint _mesa_evaluator_components( GLenum target )
60afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
61afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (target) {
62afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_VERTEX_3:		return 3;
63afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_VERTEX_4:		return 4;
64afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_INDEX:		return 1;
65afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_COLOR_4:		return 4;
66afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_NORMAL:		return 3;
67afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_TEXTURE_COORD_1:	return 1;
68afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_TEXTURE_COORD_2:	return 2;
69afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_TEXTURE_COORD_3:	return 3;
70afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP1_TEXTURE_COORD_4:	return 4;
71afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_VERTEX_3:		return 3;
72afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_VERTEX_4:		return 4;
73afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_INDEX:		return 1;
74afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_COLOR_4:		return 4;
75afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_NORMAL:		return 3;
76afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_TEXTURE_COORD_1:	return 1;
77afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_TEXTURE_COORD_2:	return 2;
78afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_TEXTURE_COORD_3:	return 3;
79afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_MAP2_TEXTURE_COORD_4:	return 4;
80bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      default:				break;
81bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   }
82bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
83bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   /* XXX need to check for the vertex program extension
84bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!ctx->Extensions.NV_vertex_program)
85bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return 0;
86bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   */
87bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
88bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV &&
89bc42c19f22c3b719712529d86faea818f34150a2Brian Paul       target <= GL_MAP1_VERTEX_ATTRIB15_4_NV)
90bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return 4;
91bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
92bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV &&
93bc42c19f22c3b719712529d86faea818f34150a2Brian Paul       target <= GL_MAP2_VERTEX_ATTRIB15_4_NV)
94bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return 4;
95bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
96bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   return 0;
97bc42c19f22c3b719712529d86faea818f34150a2Brian Paul}
98bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
99bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
100bc42c19f22c3b719712529d86faea818f34150a2Brian Paul/*
101bc42c19f22c3b719712529d86faea818f34150a2Brian Paul * Return pointer to the gl_1d_map struct for the named target.
102bc42c19f22c3b719712529d86faea818f34150a2Brian Paul */
103bc42c19f22c3b719712529d86faea818f34150a2Brian Paulstatic struct gl_1d_map *
104f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergget_1d_map( struct gl_context *ctx, GLenum target )
105bc42c19f22c3b719712529d86faea818f34150a2Brian Paul{
106bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   switch (target) {
107bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_3:
108bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Vertex3;
109bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_4:
110bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Vertex4;
111bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_INDEX:
112bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Index;
113bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_COLOR_4:
114bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Color4;
115bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_NORMAL:
116bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Normal;
117bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_TEXTURE_COORD_1:
118bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Texture1;
119bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_TEXTURE_COORD_2:
120bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Texture2;
121bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_TEXTURE_COORD_3:
122bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Texture3;
123bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_TEXTURE_COORD_4:
124bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Texture4;
125bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB0_4_NV:
126bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB1_4_NV:
127bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB2_4_NV:
128bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB3_4_NV:
129bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB4_4_NV:
130bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB5_4_NV:
131bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB6_4_NV:
132bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB7_4_NV:
133bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB8_4_NV:
134bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB9_4_NV:
135bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB10_4_NV:
136bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB11_4_NV:
137bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB12_4_NV:
138bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB13_4_NV:
139bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB14_4_NV:
140bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP1_VERTEX_ATTRIB15_4_NV:
141bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (!ctx->Extensions.NV_vertex_program)
142bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            return NULL;
143bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV];
144bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      default:
145bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return NULL;
146bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   }
147bc42c19f22c3b719712529d86faea818f34150a2Brian Paul}
148bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
149bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
150bc42c19f22c3b719712529d86faea818f34150a2Brian Paul/*
151bc42c19f22c3b719712529d86faea818f34150a2Brian Paul * Return pointer to the gl_2d_map struct for the named target.
152bc42c19f22c3b719712529d86faea818f34150a2Brian Paul */
153bc42c19f22c3b719712529d86faea818f34150a2Brian Paulstatic struct gl_2d_map *
154f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergget_2d_map( struct gl_context *ctx, GLenum target )
155bc42c19f22c3b719712529d86faea818f34150a2Brian Paul{
156bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   switch (target) {
157bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_3:
158bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Vertex3;
159bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_4:
160bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Vertex4;
161bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_INDEX:
162bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Index;
163bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_COLOR_4:
164bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Color4;
165bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_NORMAL:
166bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Normal;
167bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_TEXTURE_COORD_1:
168bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Texture1;
169bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_TEXTURE_COORD_2:
170bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Texture2;
171bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_TEXTURE_COORD_3:
172bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Texture3;
173bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_TEXTURE_COORD_4:
174bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Texture4;
175bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB0_4_NV:
176bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB1_4_NV:
177bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB2_4_NV:
178bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB3_4_NV:
179bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB4_4_NV:
180bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB5_4_NV:
181bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB6_4_NV:
182bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB7_4_NV:
183bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB8_4_NV:
184bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB9_4_NV:
185bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB10_4_NV:
186bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB11_4_NV:
187bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB12_4_NV:
188bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB13_4_NV:
189bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB14_4_NV:
190bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      case GL_MAP2_VERTEX_ATTRIB15_4_NV:
191bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (!ctx->Extensions.NV_vertex_program)
192bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            return NULL;
193bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV];
194bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      default:
195bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         return NULL;
196afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
197afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
198afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
199afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
200afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/**********************************************************************/
201afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/***            Copy and deallocate control points                  ***/
202afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/**********************************************************************/
203afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
204afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
205afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2065e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * Copy 1-parametric evaluator control points from user-specified
207afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * memory space to a buffer of contiguous control points.
2086dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell * \param see glMap1f for details
2096dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell * \return pointer to buffer of contiguous control points or NULL if out
210afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *          of memory.
211afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
21208836341788a9f9d638d9dc8328510ccd18ddeb5Brian PaulGLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
213bc42c19f22c3b719712529d86faea818f34150a2Brian Paul                                  const GLfloat *points )
214afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
215afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *buffer, *p;
216fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GLint i, k, size = _mesa_evaluator_components(target);
217afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
218bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!points || !size)
219afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
220afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
221bd5cdaf4442872d3cd2ff94eeafadd481d27fcfbBrian Paul   buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
222afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
223bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (buffer)
224bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      for (i = 0, p = buffer; i < uorder; i++, points += ustride)
225bc42c19f22c3b719712529d86faea818f34150a2Brian Paul	for (k = 0; k < size; k++)
226afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	  *p++ = points[k];
227afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
228afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return buffer;
229afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
230afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
231afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
232afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
233afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
234afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Same as above but convert doubles to floats.
235afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
23608836341788a9f9d638d9dc8328510ccd18ddeb5Brian PaulGLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
237bc42c19f22c3b719712529d86faea818f34150a2Brian Paul                                  const GLdouble *points )
238afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
239afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *buffer, *p;
240fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GLint i, k, size = _mesa_evaluator_components(target);
241afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
242bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!points || !size)
243afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
244afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
245bd5cdaf4442872d3cd2ff94eeafadd481d27fcfbBrian Paul   buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
246afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
247bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (buffer)
248bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      for (i = 0, p = buffer; i < uorder; i++, points += ustride)
249bc42c19f22c3b719712529d86faea818f34150a2Brian Paul	for (k = 0; k < size; k++)
250afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	  *p++ = (GLfloat) points[k];
251afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
252afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return buffer;
253afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
254afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
255afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
256afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
257afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
2585e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * Copy 2-parametric evaluator control points from user-specified
259afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * memory space to a buffer of contiguous control points.
260afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Additional memory is allocated to be used by the horner and
261afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * de Casteljau evaluation schemes.
262afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *
2636dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell * \param see glMap2f for details
2646dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell * \return pointer to buffer of contiguous control points or NULL if out
265afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg *          of memory.
266afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
26708836341788a9f9d638d9dc8328510ccd18ddeb5Brian PaulGLfloat *_mesa_copy_map_points2f( GLenum target,
268e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul                                  GLint ustride, GLint uorder,
269e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul                                  GLint vstride, GLint vorder,
270e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul                                  const GLfloat *points )
271afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
272afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *buffer, *p;
273afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i, j, k, size, dsize, hsize;
274afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint uinc;
275afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
276fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   size = _mesa_evaluator_components(target);
277afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
278afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!points || size==0) {
279afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
280afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
281afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
282afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* max(uorder, vorder) additional points are used in      */
283afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* horner evaluation and uorder*vorder additional */
284afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* values are needed for de Casteljau                     */
285afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder;
286afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   hsize = (uorder > vorder ? uorder : vorder)*size;
287afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
288afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if(hsize>dsize)
289bd5cdaf4442872d3cd2ff94eeafadd481d27fcfbBrian Paul     buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
290afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
291bd5cdaf4442872d3cd2ff94eeafadd481d27fcfbBrian Paul     buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
292afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
293afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* compute the increment value for the u-loop */
294afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   uinc = ustride - vorder*vstride;
295afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
2965e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen   if (buffer)
297afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      for (i=0, p=buffer; i<uorder; i++, points += uinc)
298afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 for (j=0; j<vorder; j++, points += vstride)
299afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    for (k=0; k<size; k++)
300afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	       *p++ = points[k];
301afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
302afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return buffer;
303afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
304afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
305afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
306afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
307afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
308afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg * Same as above but convert doubles to floats.
309afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
31008836341788a9f9d638d9dc8328510ccd18ddeb5Brian PaulGLfloat *_mesa_copy_map_points2d(GLenum target,
311e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul                                 GLint ustride, GLint uorder,
312e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul                                 GLint vstride, GLint vorder,
313e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul                                 const GLdouble *points )
314afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
315afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *buffer, *p;
316afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i, j, k, size, hsize, dsize;
317afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint uinc;
318afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
319fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   size = _mesa_evaluator_components(target);
320afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
321afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (!points || size==0) {
322afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return NULL;
323afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
324afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
325afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* max(uorder, vorder) additional points are used in      */
326afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* horner evaluation and uorder*vorder additional */
327afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* values are needed for de Casteljau                     */
328afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder;
329afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   hsize = (uorder > vorder ? uorder : vorder)*size;
330afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
331afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if(hsize>dsize)
332bd5cdaf4442872d3cd2ff94eeafadd481d27fcfbBrian Paul     buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
333afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   else
334bd5cdaf4442872d3cd2ff94eeafadd481d27fcfbBrian Paul     buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
335afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
336afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   /* compute the increment value for the u-loop */
337afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   uinc = ustride - vorder*vstride;
338afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
3395e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen   if (buffer)
340afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      for (i=0, p=buffer; i<uorder; i++, points += uinc)
341afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 for (j=0; j<vorder; j++, points += vstride)
342afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    for (k=0; k<size; k++)
343afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	       *p++ = (GLfloat) points[k];
344afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
345afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   return buffer;
346afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
347afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
348afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
349afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
350afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
351afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/**********************************************************************/
352afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/***                      API entry points                          ***/
353afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/**********************************************************************/
354afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
355afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
356afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg/*
357fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul * This does the work of glMap1[fd].
358afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg */
359fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paulstatic void
360fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paulmap1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
361fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul     GLint uorder, const GLvoid *points, GLenum type )
362afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
363fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
364afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint k;
365fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GLfloat *pnts;
366e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul   struct gl_1d_map *map = NULL;
367afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
368bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   ASSERT_OUTSIDE_BEGIN_END(ctx);
369e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul   ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
370fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
371fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   if (u1 == u2) {
37208836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" );
373afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
374afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
375fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   if (uorder < 1 || uorder > MAX_EVAL_ORDER) {
37608836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" );
377afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
378afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
379fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   if (!points) {
38008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" );
381fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul      return;
382fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   }
383afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
384fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   k = _mesa_evaluator_components( target );
385fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   if (k == 0) {
38608836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
387afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
388afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
389fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   if (ustride < k) {
39008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" );
391afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
392afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
393afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
394441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul   if (ctx->Texture.CurrentUnit != 0) {
395441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul      /* See OpenGL 1.2.1 spec, section F.2.13 */
396441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul      _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" );
397441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul      return;
398441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul   }
399441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul
400bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map = get_1d_map(ctx, target);
401bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!map) {
402bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
403bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return;
404afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
405a96308c37db0bc0086a017d318bc3504aa5f0b1aKeith Whitwell
406cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   /* make copy of the control points */
407cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (type == GL_FLOAT)
40808836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points);
409cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   else
41008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points);
411cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
412cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
413cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   FLUSH_VERTICES(ctx, _NEW_EVAL);
414cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->Order = uorder;
415cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->u1 = u1;
416cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->u2 = u2;
41794a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   map->du = 1.0F / (u2 - u1);
418cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (map->Points)
419cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      FREE( map->Points );
420cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->Points = pnts;
421afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
422afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
423afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
424afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
425aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
426fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
427fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             GLint order, const GLfloat *points )
428fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul{
429fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   map1(target, u1, u2, stride, order, points, GL_FLOAT);
430fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul}
431afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
432fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
433aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
434fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
435fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             GLint order, const GLdouble *points )
436afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
43794a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE);
438fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul}
439fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
440fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
441fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paulstatic void
442fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paulmap2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
443fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul      GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
444fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul      const GLvoid *points, GLenum type )
445fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul{
446fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
447afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint k;
448fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GLfloat *pnts;
449e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul   struct gl_2d_map *map = NULL;
450e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul
451cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ASSERT_OUTSIDE_BEGIN_END(ctx);
452e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul   ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
453afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
454afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (u1==u2) {
45508836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" );
456afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
457afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
458afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
459afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (v1==v2) {
46008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" );
461afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
462afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
463afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
464afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (uorder<1 || uorder>MAX_EVAL_ORDER) {
46508836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" );
466afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
467afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
468afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
469afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vorder<1 || vorder>MAX_EVAL_ORDER) {
47008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" );
471afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
472afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
473afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
474fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   k = _mesa_evaluator_components( target );
475afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (k==0) {
47608836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
477afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
478afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
479afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (ustride < k) {
48008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" );
481afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
482afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
483afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vstride < k) {
48408836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" );
485afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
486afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
487afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
488441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul   if (ctx->Texture.CurrentUnit != 0) {
489441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul      /* See OpenGL 1.2.1 spec, section F.2.13 */
490441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul      _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" );
491441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul      return;
492441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul   }
493441a4af435b46e1b475318fbaf4e80b774390cb0Brian Paul
494bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map = get_2d_map(ctx, target);
495bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!map) {
496bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
497bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return;
498afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
499a96308c37db0bc0086a017d318bc3504aa5f0b1aKeith Whitwell
500cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   /* make copy of the control points */
501cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (type == GL_FLOAT)
50208836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      pnts = _mesa_copy_map_points2f(target, ustride, uorder,
503cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell                                  vstride, vorder, (GLfloat*) points);
504cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   else
50508836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      pnts = _mesa_copy_map_points2d(target, ustride, uorder,
506cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell                                  vstride, vorder, (GLdouble*) points);
50722144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
50822144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes
509cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   FLUSH_VERTICES(ctx, _NEW_EVAL);
510cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->Uorder = uorder;
511cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->u1 = u1;
512cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->u2 = u2;
51394a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   map->du = 1.0F / (u2 - u1);
514cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->Vorder = vorder;
515cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->v1 = v1;
516cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->v2 = v2;
51794a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   map->dv = 1.0F / (v2 - v1);
518cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   if (map->Points)
519cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell      FREE( map->Points );
520cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   map->Points = pnts;
521afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
522afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
523afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
524aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
525fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_Map2f( GLenum target,
526fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
527fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
528fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             const GLfloat *points)
529fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul{
530fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
531fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul        points, GL_FLOAT);
532fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul}
533afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
534afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
535aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
536fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_Map2d( GLenum target,
537fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
538fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
539fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul             const GLdouble *points )
540afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
54194a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder,
54294a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz	(GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE);
543fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul}
544fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
545fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
5465e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen
547aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
5486b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul_mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v )
549fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul{
550fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
551bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   struct gl_1d_map *map1d;
552bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   struct gl_2d_map *map2d;
553afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i, n;
554afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *data;
555bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   GLuint comps;
5566b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   GLsizei numBytes;
557bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
558cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ASSERT_OUTSIDE_BEGIN_END(ctx);
559afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
560bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   comps = _mesa_evaluator_components(target);
561bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!comps) {
562bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
563bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return;
564bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   }
565bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
566bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map1d = get_1d_map(ctx, target);
567bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map2d = get_2d_map(ctx, target);
568bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   ASSERT(map1d || map2d);
569bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
570afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (query) {
571afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_COEFF:
572bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
573bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            data = map1d->Points;
574bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            n = map1d->Order * comps;
575bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
576bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
577bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            data = map2d->Points;
578bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            n = map2d->Uorder * map2d->Vorder * comps;
579bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
580afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (data) {
5816b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = n * sizeof *v;
5826b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
5836b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
584afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    for (i=0;i<n;i++) {
585afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	       v[i] = data[i];
586afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    }
587afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
588afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
589afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_ORDER:
590bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
5916b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 1 * sizeof *v;
5926b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
5936b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
594bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = (GLdouble) map1d->Order;
595bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
596bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
5976b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 2 * sizeof *v;
5986b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
5996b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
600bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = (GLdouble) map2d->Uorder;
601bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = (GLdouble) map2d->Vorder;
602bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
603afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
604afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_DOMAIN:
605bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
6066b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 2 * sizeof *v;
6076b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
6086b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul              goto overflow;
609bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = (GLdouble) map1d->u1;
610bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = (GLdouble) map1d->u2;
611bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
612bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
6136b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 4 * sizeof *v;
6146b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
6156b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
616bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = (GLdouble) map2d->u1;
617bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = (GLdouble) map2d->u2;
618bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[2] = (GLdouble) map2d->v1;
619bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[3] = (GLdouble) map2d->v2;
620bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
621afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
622afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
62308836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul         _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" );
624afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
6256b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   return;
6266b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
6276b329b9274b18c50f4177eef7ee087d50ebc1525Brian Pauloverflow:
6286b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   _mesa_error( ctx, GL_INVALID_OPERATION,
6296b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               "glGetnMapdvARB(out of bounds: bufSize is %d,"
6306b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               " but %d bytes are required)", bufSize, numBytes );
631afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
632afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
6336b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paulstatic void GLAPIENTRY
6346b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
6356b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul{
6366b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   _mesa_GetnMapdvARB(target, query, INT_MAX, v);
6376b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul}
638afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
639aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
6406b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul_mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v )
641afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
642fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
643bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   struct gl_1d_map *map1d;
644bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   struct gl_2d_map *map2d;
645afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLint i, n;
646afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *data;
647bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   GLuint comps;
6486b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   GLsizei numBytes;
649bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
650cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ASSERT_OUTSIDE_BEGIN_END(ctx);
651afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
652bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   comps = _mesa_evaluator_components(target);
653bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!comps) {
654e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
655bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return;
656bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   }
657bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
658bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map1d = get_1d_map(ctx, target);
659bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map2d = get_2d_map(ctx, target);
660bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   ASSERT(map1d || map2d);
661bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
662afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (query) {
663afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_COEFF:
664bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
665bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            data = map1d->Points;
666bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            n = map1d->Order * comps;
667bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
668bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
669bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            data = map2d->Points;
670bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            n = map2d->Uorder * map2d->Vorder * comps;
671bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
672afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (data) {
6736b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = n * sizeof *v;
6746b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
6756b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
676afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    for (i=0;i<n;i++) {
677afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	       v[i] = data[i];
678afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    }
679afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
680afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
681afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_ORDER:
682bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
6836b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 1 * sizeof *v;
6846b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
6856b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
686bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = (GLfloat) map1d->Order;
687bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
688bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
6896b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 2 * sizeof *v;
6906b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
6916b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
692bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = (GLfloat) map2d->Uorder;
693bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = (GLfloat) map2d->Vorder;
694bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
695afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
696afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_DOMAIN:
697bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
6986b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 2 * sizeof *v;
6996b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
7006b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
701bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = map1d->u1;
702bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = map1d->u2;
703bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
704bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
7056b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 4 * sizeof *v;
7066b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
7076b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
708bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = map2d->u1;
709bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = map2d->u2;
710bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[2] = map2d->v1;
711bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[3] = map2d->v2;
712bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
713afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
714afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
71508836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul         _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" );
716afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
7176b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   return;
7186b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
7196b329b9274b18c50f4177eef7ee087d50ebc1525Brian Pauloverflow:
7206b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   _mesa_error( ctx, GL_INVALID_OPERATION,
7216b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               "glGetnMapfvARB(out of bounds: bufSize is %d,"
7226b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               " but %d bytes are required)", bufSize, numBytes );
723afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
724afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
725afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
726aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
7276b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
7286b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul{
7296b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   _mesa_GetnMapfvARB(target, query, INT_MAX, v);
7306b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul}
7316b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
7326b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
7336b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paulstatic void GLAPIENTRY
7346b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul_mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v )
735afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
736fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
737bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   struct gl_1d_map *map1d;
738bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   struct gl_2d_map *map2d;
739afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLuint i, n;
740afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   GLfloat *data;
741bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   GLuint comps;
7426b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   GLsizei numBytes;
743bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
744cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ASSERT_OUTSIDE_BEGIN_END(ctx);
745afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
746bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   comps = _mesa_evaluator_components(target);
747bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   if (!comps) {
748e2053d16901732f4947c702cdc5ef72993d8d130Brian Paul      _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
749bc42c19f22c3b719712529d86faea818f34150a2Brian Paul      return;
750bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   }
751bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
752bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map1d = get_1d_map(ctx, target);
753bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   map2d = get_2d_map(ctx, target);
754bc42c19f22c3b719712529d86faea818f34150a2Brian Paul   ASSERT(map1d || map2d);
755bc42c19f22c3b719712529d86faea818f34150a2Brian Paul
756afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   switch (query) {
757afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_COEFF:
758bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
759bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            data = map1d->Points;
760bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            n = map1d->Order * comps;
761bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
762bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
763bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            data = map2d->Points;
764bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            n = map2d->Uorder * map2d->Vorder * comps;
765bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
766afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 if (data) {
7676b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = n * sizeof *v;
7686b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
7696b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
770afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    for (i=0;i<n;i++) {
77127558a160a9fe91745728d7626995cd88f8fe339Brian Paul	       v[i] = IROUND(data[i]);
772afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	    }
773afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg	 }
774afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
775afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_ORDER:
776bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
7776b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 1 * sizeof *v;
7786b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
7796b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
780bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = map1d->Order;
781bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
782bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
7836b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 2 * sizeof *v;
7846b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
7856b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
786bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[0] = map2d->Uorder;
787bc42c19f22c3b719712529d86faea818f34150a2Brian Paul            v[1] = map2d->Vorder;
788bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
789afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
790afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      case GL_DOMAIN:
791bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         if (map1d) {
7926b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 2 * sizeof *v;
7936b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
7946b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
79527558a160a9fe91745728d7626995cd88f8fe339Brian Paul            v[0] = IROUND(map1d->u1);
79627558a160a9fe91745728d7626995cd88f8fe339Brian Paul            v[1] = IROUND(map1d->u2);
797bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
798bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         else {
7996b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            numBytes = 4 * sizeof *v;
8006b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul            if (bufSize < numBytes)
8016b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               goto overflow;
80227558a160a9fe91745728d7626995cd88f8fe339Brian Paul            v[0] = IROUND(map2d->u1);
80327558a160a9fe91745728d7626995cd88f8fe339Brian Paul            v[1] = IROUND(map2d->u2);
80427558a160a9fe91745728d7626995cd88f8fe339Brian Paul            v[2] = IROUND(map2d->v1);
80527558a160a9fe91745728d7626995cd88f8fe339Brian Paul            v[3] = IROUND(map2d->v2);
806bc42c19f22c3b719712529d86faea818f34150a2Brian Paul         }
807afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg         break;
808afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      default:
80908836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul         _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" );
810afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
8116b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   return;
8126b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
8136b329b9274b18c50f4177eef7ee087d50ebc1525Brian Pauloverflow:
8146b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   _mesa_error( ctx, GL_INVALID_OPERATION,
8156b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               "glGetnMapivARB(out of bounds: bufSize is %d,"
8166b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul               " but %d bytes are required)", bufSize, numBytes );
817afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
818afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
819afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
8206b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paulstatic void GLAPIENTRY
8216b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul_mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
8226b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul{
8236b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   _mesa_GetnMapivARB(target, query, INT_MAX, v);
8246b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul}
8256b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
826afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
827aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
828fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
829afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
830fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
831cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ASSERT_OUTSIDE_BEGIN_END(ctx);
832afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
833afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (un<1) {
83408836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" );
835afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
836afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
837cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   FLUSH_VERTICES(ctx, _NEW_EVAL);
838afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid1un = un;
839afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid1u1 = u1;
840afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid1u2 = u2;
841afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un;
842afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
843afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
844afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
845aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
846fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
847fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul{
84894a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 );
849fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul}
850fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
851fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul
852aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
853fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
854fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul                 GLint vn, GLfloat v1, GLfloat v2 )
855afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg{
856fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul   GET_CURRENT_CONTEXT(ctx);
857cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   ASSERT_OUTSIDE_BEGIN_END(ctx);
858cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
859afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (un<1) {
86008836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" );
861afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
862afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
863afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   if (vn<1) {
86408836341788a9f9d638d9dc8328510ccd18ddeb5Brian Paul      _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" );
865afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg      return;
866afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   }
867cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell
868cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell   FLUSH_VERTICES(ctx, _NEW_EVAL);
869afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2un = un;
870afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2u1 = u1;
871afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2u2 = u2;
872afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un;
873afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2vn = vn;
874afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2v1 = v1;
875afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2v2 = v2;
876afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg   ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn;
877afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg}
878afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
879afb833d4e89c312460a4ab9ed6a7a8ca4ebbfe1cjtg
880aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wustatic void GLAPIENTRY
881fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
882fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul                 GLint vn, GLdouble v1, GLdouble v2 )
883fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul{
88494a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz   _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2,
88594a6ec8f0c8a25aeeb5880e2285ae6042cfb99dbKarl Schultz		    vn, (GLfloat) v1, (GLfloat) v2 );
886fbd8f212c3866ec98c1d8c9d3db3ddb7e7c479a5Brian Paul}
8876dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
8886dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
889aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wuvoid
890aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu_mesa_install_eval_vtxfmt(struct _glapi_table *disp,
891aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu                          const GLvertexformat *vfmt)
892aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu{
893aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalCoord1f(disp, vfmt->EvalCoord1f);
894aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv);
895aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalCoord2f(disp, vfmt->EvalCoord2f);
896aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv);
897aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalPoint1(disp, vfmt->EvalPoint1);
898aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalPoint2(disp, vfmt->EvalPoint2);
899aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
900aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalMesh1(disp, vfmt->EvalMesh1);
901aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_EvalMesh2(disp, vfmt->EvalMesh2);
902aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu}
903aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
904aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
905aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wuvoid
906aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu_mesa_init_eval_dispatch(struct _glapi_table *disp)
907aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu{
908aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_GetMapdv(disp, _mesa_GetMapdv);
909aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_GetMapfv(disp, _mesa_GetMapfv);
910aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_GetMapiv(disp, _mesa_GetMapiv);
911aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_Map1d(disp, _mesa_Map1d);
912aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_Map1f(disp, _mesa_Map1f);
913aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_Map2d(disp, _mesa_Map2d);
914aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_Map2f(disp, _mesa_Map2f);
915aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_MapGrid1d(disp, _mesa_MapGrid1d);
916aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_MapGrid1f(disp, _mesa_MapGrid1f);
917aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_MapGrid2d(disp, _mesa_MapGrid2d);
918aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu   SET_MapGrid2f(disp, _mesa_MapGrid2f);
9196b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul
9206b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   /* GL_ARB_robustness */
9216b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   SET_GetnMapdvARB(disp, _mesa_GetnMapdvARB);
9226b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   SET_GetnMapfvARB(disp, _mesa_GetnMapfvARB);
9236b329b9274b18c50f4177eef7ee087d50ebc1525Brian Paul   SET_GetnMapivARB(disp, _mesa_GetnMapivARB);
924aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu}
925aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
926aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
927aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu#endif /* FEATURE_evaluators */
928aefa1f6ab1d9267b223b06ae205ab34c8e0d7c02Chia-I Wu
9296dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
9306dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/**********************************************************************/
9316dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/*****                      Initialization                        *****/
9326dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/**********************************************************************/
9336dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
9346dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/**
9356dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell * Initialize a 1-D evaluator map.
9366dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell */
9376dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwellstatic void
9386dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwellinit_1d_map( struct gl_1d_map *map, int n, const float *initial )
9396dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell{
9406dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->Order = 1;
9416dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->u1 = 0.0;
9426dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->u2 = 1.0;
9436dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
9446dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (map->Points) {
9456dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      GLint i;
9466dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      for (i=0;i<n;i++)
9476dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell         map->Points[i] = initial[i];
9486dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   }
9496dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell}
9506dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
9516dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
9526dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell/**
9536dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell * Initialize a 2-D evaluator map
9546dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell */
9556dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwellstatic void
9566dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwellinit_2d_map( struct gl_2d_map *map, int n, const float *initial )
9576dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell{
9586dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->Uorder = 1;
9596dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->Vorder = 1;
9606dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->u1 = 0.0;
9616dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->u2 = 1.0;
9626dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->v1 = 0.0;
9636dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->v2 = 1.0;
9646dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
9656dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (map->Points) {
9666dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      GLint i;
9676dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      for (i=0;i<n;i++)
9686dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell         map->Points[i] = initial[i];
9696dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   }
9706dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell}
9716dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
9726dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
973f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergvoid _mesa_init_eval( struct gl_context *ctx )
9746dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell{
9756dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   int i;
9766dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
9776dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   /* Evaluators group */
9786dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1Color4 = GL_FALSE;
9796dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1Index = GL_FALSE;
9806dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1Normal = GL_FALSE;
9816dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1TextureCoord1 = GL_FALSE;
9826dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1TextureCoord2 = GL_FALSE;
9836dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1TextureCoord3 = GL_FALSE;
9846dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1TextureCoord4 = GL_FALSE;
9856dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1Vertex3 = GL_FALSE;
9866dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map1Vertex4 = GL_FALSE;
9872240ba10f30315410bcff77e372ee71664ac4453Brian Paul   memset(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib));
9886dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2Color4 = GL_FALSE;
9896dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2Index = GL_FALSE;
9906dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2Normal = GL_FALSE;
9916dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2TextureCoord1 = GL_FALSE;
9926dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2TextureCoord2 = GL_FALSE;
9936dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2TextureCoord3 = GL_FALSE;
9946dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2TextureCoord4 = GL_FALSE;
9956dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2Vertex3 = GL_FALSE;
9966dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.Map2Vertex4 = GL_FALSE;
9972240ba10f30315410bcff77e372ee71664ac4453Brian Paul   memset(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib));
9986dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.AutoNormal = GL_FALSE;
9996dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid1un = 1;
10006dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid1u1 = 0.0;
10016dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid1u2 = 1.0;
10026dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid2un = 1;
10036dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid2vn = 1;
10046dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid2u1 = 0.0;
10056dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid2u2 = 1.0;
10066dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid2v1 = 0.0;
10076dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   ctx->Eval.MapGrid2v2 = 1.0;
10086dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
10096dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   /* Evaluator data */
10106dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   {
10116dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 };
10126dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      static GLfloat normal[3] = { 0.0, 0.0, 1.0 };
10136dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      static GLfloat index[1] = { 1.0 };
10146dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
10156dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 };
10166dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 };
10176dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
10186dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex );
10196dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex );
10206dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Index, 1, index );
10216dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Color4, 4, color );
10226dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal );
10236dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord );
10246dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord );
10256dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord );
10266dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord );
10276dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      for (i = 0; i < 16; i++)
10286dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell         init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib );
10296dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
10306dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex );
10316dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex );
10326dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Index, 1, index );
10336dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Color4, 4, color );
10346dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal );
10356dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord );
10366dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord );
10376dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord );
10386dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord );
10396dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      for (i = 0; i < 16; i++)
10406dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell         init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib );
10416dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   }
10426dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell}
10436dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
10446dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
1045f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergvoid _mesa_free_eval_data( struct gl_context *ctx )
10466dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell{
10476dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   int i;
10486dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
10496dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   /* Free evaluator data */
10506dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Vertex3.Points)
10516dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Vertex3.Points );
10526dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Vertex4.Points)
10536dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Vertex4.Points );
10546dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Index.Points)
10556dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Index.Points );
10566dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Color4.Points)
10576dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Color4.Points );
10586dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Normal.Points)
10596dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Normal.Points );
10606dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Texture1.Points)
10616dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Texture1.Points );
10626dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Texture2.Points)
10636dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Texture2.Points );
10646dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Texture3.Points)
10656dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Texture3.Points );
10666dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map1Texture4.Points)
10676dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map1Texture4.Points );
10686dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   for (i = 0; i < 16; i++)
10696dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE((ctx->EvalMap.Map1Attrib[i].Points));
10706dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell
10716dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Vertex3.Points)
10726dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Vertex3.Points );
10736dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Vertex4.Points)
10746dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Vertex4.Points );
10756dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Index.Points)
10766dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Index.Points );
10776dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Color4.Points)
10786dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Color4.Points );
10796dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Normal.Points)
10806dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Normal.Points );
10816dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Texture1.Points)
10826dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Texture1.Points );
10836dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Texture2.Points)
10846dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Texture2.Points );
10856dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Texture3.Points)
10866dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Texture3.Points );
10876dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   if (ctx->EvalMap.Map2Texture4.Points)
10886dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE( ctx->EvalMap.Map2Texture4.Points );
10896dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell   for (i = 0; i < 16; i++)
10906dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell      FREE((ctx->EvalMap.Map2Attrib[i].Points));
10916dc85575000127630489b407c50a4b3ea87c9acbKeith Whitwell}
1092