1848b8605Smrg 2848b8605Smrg/* 3848b8605Smrg * Mesa 3-D graphics library 4848b8605Smrg * 5848b8605Smrg * Copyright (C) 1999-2003 Brian Paul All Rights Reserved. 6848b8605Smrg * 7848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 8848b8605Smrg * copy of this software and associated documentation files (the "Software"), 9848b8605Smrg * to deal in the Software without restriction, including without limitation 10848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 12848b8605Smrg * Software is furnished to do so, subject to the following conditions: 13848b8605Smrg * 14848b8605Smrg * The above copyright notice and this permission notice shall be included 15848b8605Smrg * in all copies or substantial portions of the Software. 16848b8605Smrg * 17848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 21848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE. 24848b8605Smrg */ 25848b8605Smrg 26848b8605Smrg 27848b8605Smrg/* 28848b8605Smrg * eval.c was written by 29848b8605Smrg * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and 30848b8605Smrg * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de). 31848b8605Smrg * 32848b8605Smrg * My original implementation of evaluators was simplistic and didn't 33848b8605Smrg * compute surface normal vectors properly. Bernd and Volker applied 34848b8605Smrg * used more sophisticated methods to get better results. 35848b8605Smrg * 36848b8605Smrg * Thanks guys! 37848b8605Smrg */ 38848b8605Smrg 39848b8605Smrg 40848b8605Smrg#include "glheader.h" 41848b8605Smrg#include "imports.h" 42848b8605Smrg#include "context.h" 43848b8605Smrg#include "eval.h" 44848b8605Smrg#include "macros.h" 45848b8605Smrg#include "mtypes.h" 46848b8605Smrg#include "main/dispatch.h" 47848b8605Smrg 48848b8605Smrg 49848b8605Smrg/* 50848b8605Smrg * Return the number of components per control point for any type of 51848b8605Smrg * evaluator. Return 0 if bad target. 52848b8605Smrg * See table 5.1 in the OpenGL 1.2 spec. 53848b8605Smrg */ 54848b8605SmrgGLuint _mesa_evaluator_components( GLenum target ) 55848b8605Smrg{ 56848b8605Smrg switch (target) { 57848b8605Smrg case GL_MAP1_VERTEX_3: return 3; 58848b8605Smrg case GL_MAP1_VERTEX_4: return 4; 59848b8605Smrg case GL_MAP1_INDEX: return 1; 60848b8605Smrg case GL_MAP1_COLOR_4: return 4; 61848b8605Smrg case GL_MAP1_NORMAL: return 3; 62848b8605Smrg case GL_MAP1_TEXTURE_COORD_1: return 1; 63848b8605Smrg case GL_MAP1_TEXTURE_COORD_2: return 2; 64848b8605Smrg case GL_MAP1_TEXTURE_COORD_3: return 3; 65848b8605Smrg case GL_MAP1_TEXTURE_COORD_4: return 4; 66848b8605Smrg case GL_MAP2_VERTEX_3: return 3; 67848b8605Smrg case GL_MAP2_VERTEX_4: return 4; 68848b8605Smrg case GL_MAP2_INDEX: return 1; 69848b8605Smrg case GL_MAP2_COLOR_4: return 4; 70848b8605Smrg case GL_MAP2_NORMAL: return 3; 71848b8605Smrg case GL_MAP2_TEXTURE_COORD_1: return 1; 72848b8605Smrg case GL_MAP2_TEXTURE_COORD_2: return 2; 73848b8605Smrg case GL_MAP2_TEXTURE_COORD_3: return 3; 74848b8605Smrg case GL_MAP2_TEXTURE_COORD_4: return 4; 75848b8605Smrg default: break; 76848b8605Smrg } 77848b8605Smrg 78848b8605Smrg return 0; 79848b8605Smrg} 80848b8605Smrg 81848b8605Smrg 82848b8605Smrg/* 83848b8605Smrg * Return pointer to the gl_1d_map struct for the named target. 84848b8605Smrg */ 85848b8605Smrgstatic struct gl_1d_map * 86848b8605Smrgget_1d_map( struct gl_context *ctx, GLenum target ) 87848b8605Smrg{ 88848b8605Smrg switch (target) { 89848b8605Smrg case GL_MAP1_VERTEX_3: 90848b8605Smrg return &ctx->EvalMap.Map1Vertex3; 91848b8605Smrg case GL_MAP1_VERTEX_4: 92848b8605Smrg return &ctx->EvalMap.Map1Vertex4; 93848b8605Smrg case GL_MAP1_INDEX: 94848b8605Smrg return &ctx->EvalMap.Map1Index; 95848b8605Smrg case GL_MAP1_COLOR_4: 96848b8605Smrg return &ctx->EvalMap.Map1Color4; 97848b8605Smrg case GL_MAP1_NORMAL: 98848b8605Smrg return &ctx->EvalMap.Map1Normal; 99848b8605Smrg case GL_MAP1_TEXTURE_COORD_1: 100848b8605Smrg return &ctx->EvalMap.Map1Texture1; 101848b8605Smrg case GL_MAP1_TEXTURE_COORD_2: 102848b8605Smrg return &ctx->EvalMap.Map1Texture2; 103848b8605Smrg case GL_MAP1_TEXTURE_COORD_3: 104848b8605Smrg return &ctx->EvalMap.Map1Texture3; 105848b8605Smrg case GL_MAP1_TEXTURE_COORD_4: 106848b8605Smrg return &ctx->EvalMap.Map1Texture4; 107848b8605Smrg default: 108848b8605Smrg return NULL; 109848b8605Smrg } 110848b8605Smrg} 111848b8605Smrg 112848b8605Smrg 113848b8605Smrg/* 114848b8605Smrg * Return pointer to the gl_2d_map struct for the named target. 115848b8605Smrg */ 116848b8605Smrgstatic struct gl_2d_map * 117848b8605Smrgget_2d_map( struct gl_context *ctx, GLenum target ) 118848b8605Smrg{ 119848b8605Smrg switch (target) { 120848b8605Smrg case GL_MAP2_VERTEX_3: 121848b8605Smrg return &ctx->EvalMap.Map2Vertex3; 122848b8605Smrg case GL_MAP2_VERTEX_4: 123848b8605Smrg return &ctx->EvalMap.Map2Vertex4; 124848b8605Smrg case GL_MAP2_INDEX: 125848b8605Smrg return &ctx->EvalMap.Map2Index; 126848b8605Smrg case GL_MAP2_COLOR_4: 127848b8605Smrg return &ctx->EvalMap.Map2Color4; 128848b8605Smrg case GL_MAP2_NORMAL: 129848b8605Smrg return &ctx->EvalMap.Map2Normal; 130848b8605Smrg case GL_MAP2_TEXTURE_COORD_1: 131848b8605Smrg return &ctx->EvalMap.Map2Texture1; 132848b8605Smrg case GL_MAP2_TEXTURE_COORD_2: 133848b8605Smrg return &ctx->EvalMap.Map2Texture2; 134848b8605Smrg case GL_MAP2_TEXTURE_COORD_3: 135848b8605Smrg return &ctx->EvalMap.Map2Texture3; 136848b8605Smrg case GL_MAP2_TEXTURE_COORD_4: 137848b8605Smrg return &ctx->EvalMap.Map2Texture4; 138848b8605Smrg default: 139848b8605Smrg return NULL; 140848b8605Smrg } 141848b8605Smrg} 142848b8605Smrg 143848b8605Smrg 144848b8605Smrg/**********************************************************************/ 145848b8605Smrg/*** Copy and deallocate control points ***/ 146848b8605Smrg/**********************************************************************/ 147848b8605Smrg 148848b8605Smrg 149848b8605Smrg/* 150848b8605Smrg * Copy 1-parametric evaluator control points from user-specified 151848b8605Smrg * memory space to a buffer of contiguous control points. 152848b8605Smrg * \param see glMap1f for details 153848b8605Smrg * \return pointer to buffer of contiguous control points or NULL if out 154848b8605Smrg * of memory. 155848b8605Smrg */ 156848b8605SmrgGLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, 157848b8605Smrg const GLfloat *points ) 158848b8605Smrg{ 159848b8605Smrg GLfloat *buffer, *p; 160848b8605Smrg GLint i, k, size = _mesa_evaluator_components(target); 161848b8605Smrg 162848b8605Smrg if (!points || !size) 163848b8605Smrg return NULL; 164848b8605Smrg 165848b8605Smrg buffer = malloc(uorder * size * sizeof(GLfloat)); 166848b8605Smrg 167848b8605Smrg if (buffer) 168848b8605Smrg for (i = 0, p = buffer; i < uorder; i++, points += ustride) 169848b8605Smrg for (k = 0; k < size; k++) 170848b8605Smrg *p++ = points[k]; 171848b8605Smrg 172848b8605Smrg return buffer; 173848b8605Smrg} 174848b8605Smrg 175848b8605Smrg 176848b8605Smrg 177848b8605Smrg/* 178848b8605Smrg * Same as above but convert doubles to floats. 179848b8605Smrg */ 180848b8605SmrgGLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder, 181848b8605Smrg const GLdouble *points ) 182848b8605Smrg{ 183848b8605Smrg GLfloat *buffer, *p; 184848b8605Smrg GLint i, k, size = _mesa_evaluator_components(target); 185848b8605Smrg 186848b8605Smrg if (!points || !size) 187848b8605Smrg return NULL; 188848b8605Smrg 189848b8605Smrg buffer = malloc(uorder * size * sizeof(GLfloat)); 190848b8605Smrg 191848b8605Smrg if (buffer) 192848b8605Smrg for (i = 0, p = buffer; i < uorder; i++, points += ustride) 193848b8605Smrg for (k = 0; k < size; k++) 194848b8605Smrg *p++ = (GLfloat) points[k]; 195848b8605Smrg 196848b8605Smrg return buffer; 197848b8605Smrg} 198848b8605Smrg 199848b8605Smrg 200848b8605Smrg 201848b8605Smrg/* 202848b8605Smrg * Copy 2-parametric evaluator control points from user-specified 203848b8605Smrg * memory space to a buffer of contiguous control points. 204848b8605Smrg * Additional memory is allocated to be used by the horner and 205848b8605Smrg * de Casteljau evaluation schemes. 206848b8605Smrg * 207848b8605Smrg * \param see glMap2f for details 208848b8605Smrg * \return pointer to buffer of contiguous control points or NULL if out 209848b8605Smrg * of memory. 210848b8605Smrg */ 211848b8605SmrgGLfloat *_mesa_copy_map_points2f( GLenum target, 212848b8605Smrg GLint ustride, GLint uorder, 213848b8605Smrg GLint vstride, GLint vorder, 214848b8605Smrg const GLfloat *points ) 215848b8605Smrg{ 216848b8605Smrg GLfloat *buffer, *p; 217848b8605Smrg GLint i, j, k, size, dsize, hsize; 218848b8605Smrg GLint uinc; 219848b8605Smrg 220848b8605Smrg size = _mesa_evaluator_components(target); 221848b8605Smrg 222848b8605Smrg if (!points || size==0) { 223848b8605Smrg return NULL; 224848b8605Smrg } 225848b8605Smrg 226848b8605Smrg /* max(uorder, vorder) additional points are used in */ 227848b8605Smrg /* horner evaluation and uorder*vorder additional */ 228848b8605Smrg /* values are needed for de Casteljau */ 229848b8605Smrg dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; 230848b8605Smrg hsize = (uorder > vorder ? uorder : vorder)*size; 231848b8605Smrg 232848b8605Smrg if(hsize>dsize) 233848b8605Smrg buffer = malloc((uorder*vorder*size+hsize)*sizeof(GLfloat)); 234848b8605Smrg else 235848b8605Smrg buffer = malloc((uorder*vorder*size+dsize)*sizeof(GLfloat)); 236848b8605Smrg 237848b8605Smrg /* compute the increment value for the u-loop */ 238848b8605Smrg uinc = ustride - vorder*vstride; 239848b8605Smrg 240848b8605Smrg if (buffer) 241848b8605Smrg for (i=0, p=buffer; i<uorder; i++, points += uinc) 242848b8605Smrg for (j=0; j<vorder; j++, points += vstride) 243848b8605Smrg for (k=0; k<size; k++) 244848b8605Smrg *p++ = points[k]; 245848b8605Smrg 246848b8605Smrg return buffer; 247848b8605Smrg} 248848b8605Smrg 249848b8605Smrg 250848b8605Smrg 251848b8605Smrg/* 252848b8605Smrg * Same as above but convert doubles to floats. 253848b8605Smrg */ 254848b8605SmrgGLfloat *_mesa_copy_map_points2d(GLenum target, 255848b8605Smrg GLint ustride, GLint uorder, 256848b8605Smrg GLint vstride, GLint vorder, 257848b8605Smrg const GLdouble *points ) 258848b8605Smrg{ 259848b8605Smrg GLfloat *buffer, *p; 260848b8605Smrg GLint i, j, k, size, hsize, dsize; 261848b8605Smrg GLint uinc; 262848b8605Smrg 263848b8605Smrg size = _mesa_evaluator_components(target); 264848b8605Smrg 265848b8605Smrg if (!points || size==0) { 266848b8605Smrg return NULL; 267848b8605Smrg } 268848b8605Smrg 269848b8605Smrg /* max(uorder, vorder) additional points are used in */ 270848b8605Smrg /* horner evaluation and uorder*vorder additional */ 271848b8605Smrg /* values are needed for de Casteljau */ 272848b8605Smrg dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder; 273848b8605Smrg hsize = (uorder > vorder ? uorder : vorder)*size; 274848b8605Smrg 275848b8605Smrg if(hsize>dsize) 276848b8605Smrg buffer = malloc((uorder*vorder*size+hsize)*sizeof(GLfloat)); 277848b8605Smrg else 278848b8605Smrg buffer = malloc((uorder*vorder*size+dsize)*sizeof(GLfloat)); 279848b8605Smrg 280848b8605Smrg /* compute the increment value for the u-loop */ 281848b8605Smrg uinc = ustride - vorder*vstride; 282848b8605Smrg 283848b8605Smrg if (buffer) 284848b8605Smrg for (i=0, p=buffer; i<uorder; i++, points += uinc) 285848b8605Smrg for (j=0; j<vorder; j++, points += vstride) 286848b8605Smrg for (k=0; k<size; k++) 287848b8605Smrg *p++ = (GLfloat) points[k]; 288848b8605Smrg 289848b8605Smrg return buffer; 290848b8605Smrg} 291848b8605Smrg 292848b8605Smrg 293848b8605Smrg 294848b8605Smrg 295848b8605Smrg/**********************************************************************/ 296848b8605Smrg/*** API entry points ***/ 297848b8605Smrg/**********************************************************************/ 298848b8605Smrg 299848b8605Smrg 300848b8605Smrg/* 301848b8605Smrg * This does the work of glMap1[fd]. 302848b8605Smrg */ 303848b8605Smrgstatic void 304848b8605Smrgmap1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, 305848b8605Smrg GLint uorder, const GLvoid *points, GLenum type ) 306848b8605Smrg{ 307848b8605Smrg GET_CURRENT_CONTEXT(ctx); 308848b8605Smrg GLint k; 309848b8605Smrg GLfloat *pnts; 310848b8605Smrg struct gl_1d_map *map = NULL; 311848b8605Smrg 312b8e80941Smrg assert(type == GL_FLOAT || type == GL_DOUBLE); 313848b8605Smrg 314848b8605Smrg if (u1 == u2) { 315848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" ); 316848b8605Smrg return; 317848b8605Smrg } 318848b8605Smrg if (uorder < 1 || uorder > MAX_EVAL_ORDER) { 319848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); 320848b8605Smrg return; 321848b8605Smrg } 322848b8605Smrg if (!points) { 323848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); 324848b8605Smrg return; 325848b8605Smrg } 326848b8605Smrg 327848b8605Smrg k = _mesa_evaluator_components( target ); 328848b8605Smrg if (k == 0) { 329848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); 330848b8605Smrg return; 331848b8605Smrg } 332848b8605Smrg 333848b8605Smrg if (ustride < k) { 334848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); 335848b8605Smrg return; 336848b8605Smrg } 337848b8605Smrg 338848b8605Smrg if (ctx->Texture.CurrentUnit != 0) { 339848b8605Smrg /* See OpenGL 1.2.1 spec, section F.2.13 */ 340848b8605Smrg _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); 341848b8605Smrg return; 342848b8605Smrg } 343848b8605Smrg 344848b8605Smrg map = get_1d_map(ctx, target); 345848b8605Smrg if (!map) { 346848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); 347848b8605Smrg return; 348848b8605Smrg } 349848b8605Smrg 350848b8605Smrg /* make copy of the control points */ 351848b8605Smrg if (type == GL_FLOAT) 352848b8605Smrg pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); 353848b8605Smrg else 354848b8605Smrg pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); 355848b8605Smrg 356848b8605Smrg 357848b8605Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 358848b8605Smrg map->Order = uorder; 359848b8605Smrg map->u1 = u1; 360848b8605Smrg map->u2 = u2; 361848b8605Smrg map->du = 1.0F / (u2 - u1); 362848b8605Smrg free(map->Points); 363848b8605Smrg map->Points = pnts; 364848b8605Smrg} 365848b8605Smrg 366848b8605Smrg 367848b8605Smrg 368848b8605Smrgvoid GLAPIENTRY 369848b8605Smrg_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, 370848b8605Smrg GLint order, const GLfloat *points ) 371848b8605Smrg{ 372848b8605Smrg map1(target, u1, u2, stride, order, points, GL_FLOAT); 373848b8605Smrg} 374848b8605Smrg 375848b8605Smrg 376848b8605Smrgvoid GLAPIENTRY 377848b8605Smrg_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, 378848b8605Smrg GLint order, const GLdouble *points ) 379848b8605Smrg{ 380848b8605Smrg map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); 381848b8605Smrg} 382848b8605Smrg 383848b8605Smrg 384848b8605Smrgstatic void 385848b8605Smrgmap2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, 386848b8605Smrg GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, 387848b8605Smrg const GLvoid *points, GLenum type ) 388848b8605Smrg{ 389848b8605Smrg GET_CURRENT_CONTEXT(ctx); 390848b8605Smrg GLint k; 391848b8605Smrg GLfloat *pnts; 392848b8605Smrg struct gl_2d_map *map = NULL; 393848b8605Smrg 394b8e80941Smrg assert(type == GL_FLOAT || type == GL_DOUBLE); 395848b8605Smrg 396848b8605Smrg if (u1==u2) { 397848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" ); 398848b8605Smrg return; 399848b8605Smrg } 400848b8605Smrg 401848b8605Smrg if (v1==v2) { 402848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" ); 403848b8605Smrg return; 404848b8605Smrg } 405848b8605Smrg 406848b8605Smrg if (uorder<1 || uorder>MAX_EVAL_ORDER) { 407848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" ); 408848b8605Smrg return; 409848b8605Smrg } 410848b8605Smrg 411848b8605Smrg if (vorder<1 || vorder>MAX_EVAL_ORDER) { 412848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" ); 413848b8605Smrg return; 414848b8605Smrg } 415848b8605Smrg 416848b8605Smrg k = _mesa_evaluator_components( target ); 417848b8605Smrg if (k==0) { 418848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); 419848b8605Smrg return; 420848b8605Smrg } 421848b8605Smrg 422848b8605Smrg if (ustride < k) { 423848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" ); 424848b8605Smrg return; 425848b8605Smrg } 426848b8605Smrg if (vstride < k) { 427848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" ); 428848b8605Smrg return; 429848b8605Smrg } 430848b8605Smrg 431848b8605Smrg if (ctx->Texture.CurrentUnit != 0) { 432848b8605Smrg /* See OpenGL 1.2.1 spec, section F.2.13 */ 433848b8605Smrg _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); 434848b8605Smrg return; 435848b8605Smrg } 436848b8605Smrg 437848b8605Smrg map = get_2d_map(ctx, target); 438848b8605Smrg if (!map) { 439848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); 440848b8605Smrg return; 441848b8605Smrg } 442848b8605Smrg 443848b8605Smrg /* make copy of the control points */ 444848b8605Smrg if (type == GL_FLOAT) 445848b8605Smrg pnts = _mesa_copy_map_points2f(target, ustride, uorder, 446848b8605Smrg vstride, vorder, (GLfloat*) points); 447848b8605Smrg else 448848b8605Smrg pnts = _mesa_copy_map_points2d(target, ustride, uorder, 449848b8605Smrg vstride, vorder, (GLdouble*) points); 450848b8605Smrg 451848b8605Smrg 452848b8605Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 453848b8605Smrg map->Uorder = uorder; 454848b8605Smrg map->u1 = u1; 455848b8605Smrg map->u2 = u2; 456848b8605Smrg map->du = 1.0F / (u2 - u1); 457848b8605Smrg map->Vorder = vorder; 458848b8605Smrg map->v1 = v1; 459848b8605Smrg map->v2 = v2; 460848b8605Smrg map->dv = 1.0F / (v2 - v1); 461848b8605Smrg free(map->Points); 462848b8605Smrg map->Points = pnts; 463848b8605Smrg} 464848b8605Smrg 465848b8605Smrg 466848b8605Smrgvoid GLAPIENTRY 467848b8605Smrg_mesa_Map2f( GLenum target, 468848b8605Smrg GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, 469848b8605Smrg GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, 470848b8605Smrg const GLfloat *points) 471848b8605Smrg{ 472848b8605Smrg map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, 473848b8605Smrg points, GL_FLOAT); 474848b8605Smrg} 475848b8605Smrg 476848b8605Smrg 477848b8605Smrgvoid GLAPIENTRY 478848b8605Smrg_mesa_Map2d( GLenum target, 479848b8605Smrg GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, 480848b8605Smrg GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, 481848b8605Smrg const GLdouble *points ) 482848b8605Smrg{ 483848b8605Smrg map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, 484848b8605Smrg (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); 485848b8605Smrg} 486848b8605Smrg 487848b8605Smrg 488848b8605Smrg 489848b8605Smrgvoid GLAPIENTRY 490848b8605Smrg_mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v ) 491848b8605Smrg{ 492848b8605Smrg GET_CURRENT_CONTEXT(ctx); 493848b8605Smrg struct gl_1d_map *map1d; 494848b8605Smrg struct gl_2d_map *map2d; 495848b8605Smrg GLint i, n; 496848b8605Smrg GLfloat *data; 497848b8605Smrg GLuint comps; 498848b8605Smrg GLsizei numBytes; 499848b8605Smrg 500848b8605Smrg comps = _mesa_evaluator_components(target); 501848b8605Smrg if (!comps) { 502848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); 503848b8605Smrg return; 504848b8605Smrg } 505848b8605Smrg 506848b8605Smrg map1d = get_1d_map(ctx, target); 507848b8605Smrg map2d = get_2d_map(ctx, target); 508b8e80941Smrg assert(map1d || map2d); 509848b8605Smrg 510848b8605Smrg switch (query) { 511848b8605Smrg case GL_COEFF: 512848b8605Smrg if (map1d) { 513848b8605Smrg data = map1d->Points; 514848b8605Smrg n = map1d->Order * comps; 515848b8605Smrg } 516848b8605Smrg else { 517848b8605Smrg data = map2d->Points; 518848b8605Smrg n = map2d->Uorder * map2d->Vorder * comps; 519848b8605Smrg } 520848b8605Smrg if (data) { 521848b8605Smrg numBytes = n * sizeof *v; 522848b8605Smrg if (bufSize < numBytes) 523848b8605Smrg goto overflow; 524848b8605Smrg for (i=0;i<n;i++) { 525848b8605Smrg v[i] = data[i]; 526848b8605Smrg } 527848b8605Smrg } 528848b8605Smrg break; 529848b8605Smrg case GL_ORDER: 530848b8605Smrg if (map1d) { 531848b8605Smrg numBytes = 1 * sizeof *v; 532848b8605Smrg if (bufSize < numBytes) 533848b8605Smrg goto overflow; 534848b8605Smrg v[0] = (GLdouble) map1d->Order; 535848b8605Smrg } 536848b8605Smrg else { 537848b8605Smrg numBytes = 2 * sizeof *v; 538848b8605Smrg if (bufSize < numBytes) 539848b8605Smrg goto overflow; 540848b8605Smrg v[0] = (GLdouble) map2d->Uorder; 541848b8605Smrg v[1] = (GLdouble) map2d->Vorder; 542848b8605Smrg } 543848b8605Smrg break; 544848b8605Smrg case GL_DOMAIN: 545848b8605Smrg if (map1d) { 546848b8605Smrg numBytes = 2 * sizeof *v; 547848b8605Smrg if (bufSize < numBytes) 548848b8605Smrg goto overflow; 549848b8605Smrg v[0] = (GLdouble) map1d->u1; 550848b8605Smrg v[1] = (GLdouble) map1d->u2; 551848b8605Smrg } 552848b8605Smrg else { 553848b8605Smrg numBytes = 4 * sizeof *v; 554848b8605Smrg if (bufSize < numBytes) 555848b8605Smrg goto overflow; 556848b8605Smrg v[0] = (GLdouble) map2d->u1; 557848b8605Smrg v[1] = (GLdouble) map2d->u2; 558848b8605Smrg v[2] = (GLdouble) map2d->v1; 559848b8605Smrg v[3] = (GLdouble) map2d->v2; 560848b8605Smrg } 561848b8605Smrg break; 562848b8605Smrg default: 563848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); 564848b8605Smrg } 565848b8605Smrg return; 566848b8605Smrg 567848b8605Smrgoverflow: 568848b8605Smrg _mesa_error( ctx, GL_INVALID_OPERATION, 569848b8605Smrg "glGetnMapdvARB(out of bounds: bufSize is %d," 570848b8605Smrg " but %d bytes are required)", bufSize, numBytes ); 571848b8605Smrg} 572848b8605Smrg 573848b8605Smrgvoid GLAPIENTRY 574848b8605Smrg_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) 575848b8605Smrg{ 576848b8605Smrg _mesa_GetnMapdvARB(target, query, INT_MAX, v); 577848b8605Smrg} 578848b8605Smrg 579848b8605Smrgvoid GLAPIENTRY 580848b8605Smrg_mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v ) 581848b8605Smrg{ 582848b8605Smrg GET_CURRENT_CONTEXT(ctx); 583848b8605Smrg struct gl_1d_map *map1d; 584848b8605Smrg struct gl_2d_map *map2d; 585848b8605Smrg GLint i, n; 586848b8605Smrg GLfloat *data; 587848b8605Smrg GLuint comps; 588848b8605Smrg GLsizei numBytes; 589848b8605Smrg 590848b8605Smrg comps = _mesa_evaluator_components(target); 591848b8605Smrg if (!comps) { 592848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); 593848b8605Smrg return; 594848b8605Smrg } 595848b8605Smrg 596848b8605Smrg map1d = get_1d_map(ctx, target); 597848b8605Smrg map2d = get_2d_map(ctx, target); 598b8e80941Smrg assert(map1d || map2d); 599848b8605Smrg 600848b8605Smrg switch (query) { 601848b8605Smrg case GL_COEFF: 602848b8605Smrg if (map1d) { 603848b8605Smrg data = map1d->Points; 604848b8605Smrg n = map1d->Order * comps; 605848b8605Smrg } 606848b8605Smrg else { 607848b8605Smrg data = map2d->Points; 608848b8605Smrg n = map2d->Uorder * map2d->Vorder * comps; 609848b8605Smrg } 610848b8605Smrg if (data) { 611848b8605Smrg numBytes = n * sizeof *v; 612848b8605Smrg if (bufSize < numBytes) 613848b8605Smrg goto overflow; 614848b8605Smrg for (i=0;i<n;i++) { 615848b8605Smrg v[i] = data[i]; 616848b8605Smrg } 617848b8605Smrg } 618848b8605Smrg break; 619848b8605Smrg case GL_ORDER: 620848b8605Smrg if (map1d) { 621848b8605Smrg numBytes = 1 * sizeof *v; 622848b8605Smrg if (bufSize < numBytes) 623848b8605Smrg goto overflow; 624848b8605Smrg v[0] = (GLfloat) map1d->Order; 625848b8605Smrg } 626848b8605Smrg else { 627848b8605Smrg numBytes = 2 * sizeof *v; 628848b8605Smrg if (bufSize < numBytes) 629848b8605Smrg goto overflow; 630848b8605Smrg v[0] = (GLfloat) map2d->Uorder; 631848b8605Smrg v[1] = (GLfloat) map2d->Vorder; 632848b8605Smrg } 633848b8605Smrg break; 634848b8605Smrg case GL_DOMAIN: 635848b8605Smrg if (map1d) { 636848b8605Smrg numBytes = 2 * sizeof *v; 637848b8605Smrg if (bufSize < numBytes) 638848b8605Smrg goto overflow; 639848b8605Smrg v[0] = map1d->u1; 640848b8605Smrg v[1] = map1d->u2; 641848b8605Smrg } 642848b8605Smrg else { 643848b8605Smrg numBytes = 4 * sizeof *v; 644848b8605Smrg if (bufSize < numBytes) 645848b8605Smrg goto overflow; 646848b8605Smrg v[0] = map2d->u1; 647848b8605Smrg v[1] = map2d->u2; 648848b8605Smrg v[2] = map2d->v1; 649848b8605Smrg v[3] = map2d->v2; 650848b8605Smrg } 651848b8605Smrg break; 652848b8605Smrg default: 653848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); 654848b8605Smrg } 655848b8605Smrg return; 656848b8605Smrg 657848b8605Smrgoverflow: 658848b8605Smrg _mesa_error( ctx, GL_INVALID_OPERATION, 659848b8605Smrg "glGetnMapfvARB(out of bounds: bufSize is %d," 660848b8605Smrg " but %d bytes are required)", bufSize, numBytes ); 661848b8605Smrg} 662848b8605Smrg 663848b8605Smrg 664848b8605Smrgvoid GLAPIENTRY 665848b8605Smrg_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) 666848b8605Smrg{ 667848b8605Smrg _mesa_GetnMapfvARB(target, query, INT_MAX, v); 668848b8605Smrg} 669848b8605Smrg 670848b8605Smrg 671848b8605Smrgvoid GLAPIENTRY 672848b8605Smrg_mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v ) 673848b8605Smrg{ 674848b8605Smrg GET_CURRENT_CONTEXT(ctx); 675848b8605Smrg struct gl_1d_map *map1d; 676848b8605Smrg struct gl_2d_map *map2d; 677848b8605Smrg GLuint i, n; 678848b8605Smrg GLfloat *data; 679848b8605Smrg GLuint comps; 680848b8605Smrg GLsizei numBytes; 681848b8605Smrg 682848b8605Smrg comps = _mesa_evaluator_components(target); 683848b8605Smrg if (!comps) { 684848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); 685848b8605Smrg return; 686848b8605Smrg } 687848b8605Smrg 688848b8605Smrg map1d = get_1d_map(ctx, target); 689848b8605Smrg map2d = get_2d_map(ctx, target); 690b8e80941Smrg assert(map1d || map2d); 691848b8605Smrg 692848b8605Smrg switch (query) { 693848b8605Smrg case GL_COEFF: 694848b8605Smrg if (map1d) { 695848b8605Smrg data = map1d->Points; 696848b8605Smrg n = map1d->Order * comps; 697848b8605Smrg } 698848b8605Smrg else { 699848b8605Smrg data = map2d->Points; 700848b8605Smrg n = map2d->Uorder * map2d->Vorder * comps; 701848b8605Smrg } 702848b8605Smrg if (data) { 703848b8605Smrg numBytes = n * sizeof *v; 704848b8605Smrg if (bufSize < numBytes) 705848b8605Smrg goto overflow; 706848b8605Smrg for (i=0;i<n;i++) { 707848b8605Smrg v[i] = IROUND(data[i]); 708848b8605Smrg } 709848b8605Smrg } 710848b8605Smrg break; 711848b8605Smrg case GL_ORDER: 712848b8605Smrg if (map1d) { 713848b8605Smrg numBytes = 1 * sizeof *v; 714848b8605Smrg if (bufSize < numBytes) 715848b8605Smrg goto overflow; 716848b8605Smrg v[0] = map1d->Order; 717848b8605Smrg } 718848b8605Smrg else { 719848b8605Smrg numBytes = 2 * sizeof *v; 720848b8605Smrg if (bufSize < numBytes) 721848b8605Smrg goto overflow; 722848b8605Smrg v[0] = map2d->Uorder; 723848b8605Smrg v[1] = map2d->Vorder; 724848b8605Smrg } 725848b8605Smrg break; 726848b8605Smrg case GL_DOMAIN: 727848b8605Smrg if (map1d) { 728848b8605Smrg numBytes = 2 * sizeof *v; 729848b8605Smrg if (bufSize < numBytes) 730848b8605Smrg goto overflow; 731848b8605Smrg v[0] = IROUND(map1d->u1); 732848b8605Smrg v[1] = IROUND(map1d->u2); 733848b8605Smrg } 734848b8605Smrg else { 735848b8605Smrg numBytes = 4 * sizeof *v; 736848b8605Smrg if (bufSize < numBytes) 737848b8605Smrg goto overflow; 738848b8605Smrg v[0] = IROUND(map2d->u1); 739848b8605Smrg v[1] = IROUND(map2d->u2); 740848b8605Smrg v[2] = IROUND(map2d->v1); 741848b8605Smrg v[3] = IROUND(map2d->v2); 742848b8605Smrg } 743848b8605Smrg break; 744848b8605Smrg default: 745848b8605Smrg _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); 746848b8605Smrg } 747848b8605Smrg return; 748848b8605Smrg 749848b8605Smrgoverflow: 750848b8605Smrg _mesa_error( ctx, GL_INVALID_OPERATION, 751848b8605Smrg "glGetnMapivARB(out of bounds: bufSize is %d," 752848b8605Smrg " but %d bytes are required)", bufSize, numBytes ); 753848b8605Smrg} 754848b8605Smrg 755848b8605Smrg 756848b8605Smrgvoid GLAPIENTRY 757848b8605Smrg_mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) 758848b8605Smrg{ 759848b8605Smrg _mesa_GetnMapivARB(target, query, INT_MAX, v); 760848b8605Smrg} 761848b8605Smrg 762848b8605Smrg 763848b8605Smrgvoid GLAPIENTRY 764848b8605Smrg_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) 765848b8605Smrg{ 766848b8605Smrg GET_CURRENT_CONTEXT(ctx); 767848b8605Smrg 768848b8605Smrg if (un<1) { 769848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); 770848b8605Smrg return; 771848b8605Smrg } 772848b8605Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 773848b8605Smrg ctx->Eval.MapGrid1un = un; 774848b8605Smrg ctx->Eval.MapGrid1u1 = u1; 775848b8605Smrg ctx->Eval.MapGrid1u2 = u2; 776848b8605Smrg ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un; 777848b8605Smrg} 778848b8605Smrg 779848b8605Smrg 780848b8605Smrgvoid GLAPIENTRY 781848b8605Smrg_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) 782848b8605Smrg{ 783848b8605Smrg _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 ); 784848b8605Smrg} 785848b8605Smrg 786848b8605Smrg 787848b8605Smrgvoid GLAPIENTRY 788848b8605Smrg_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, 789848b8605Smrg GLint vn, GLfloat v1, GLfloat v2 ) 790848b8605Smrg{ 791848b8605Smrg GET_CURRENT_CONTEXT(ctx); 792848b8605Smrg 793848b8605Smrg if (un<1) { 794848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); 795848b8605Smrg return; 796848b8605Smrg } 797848b8605Smrg if (vn<1) { 798848b8605Smrg _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); 799848b8605Smrg return; 800848b8605Smrg } 801848b8605Smrg 802848b8605Smrg FLUSH_VERTICES(ctx, _NEW_EVAL); 803848b8605Smrg ctx->Eval.MapGrid2un = un; 804848b8605Smrg ctx->Eval.MapGrid2u1 = u1; 805848b8605Smrg ctx->Eval.MapGrid2u2 = u2; 806848b8605Smrg ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; 807848b8605Smrg ctx->Eval.MapGrid2vn = vn; 808848b8605Smrg ctx->Eval.MapGrid2v1 = v1; 809848b8605Smrg ctx->Eval.MapGrid2v2 = v2; 810848b8605Smrg ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn; 811848b8605Smrg} 812848b8605Smrg 813848b8605Smrg 814848b8605Smrgvoid GLAPIENTRY 815848b8605Smrg_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, 816848b8605Smrg GLint vn, GLdouble v1, GLdouble v2 ) 817848b8605Smrg{ 818848b8605Smrg _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, 819848b8605Smrg vn, (GLfloat) v1, (GLfloat) v2 ); 820848b8605Smrg} 821848b8605Smrg 822848b8605Smrg 823848b8605Smrgvoid 824848b8605Smrg_mesa_install_eval_vtxfmt(struct _glapi_table *disp, 825848b8605Smrg const GLvertexformat *vfmt) 826848b8605Smrg{ 827848b8605Smrg SET_EvalCoord1f(disp, vfmt->EvalCoord1f); 828848b8605Smrg SET_EvalCoord1fv(disp, vfmt->EvalCoord1fv); 829848b8605Smrg SET_EvalCoord2f(disp, vfmt->EvalCoord2f); 830848b8605Smrg SET_EvalCoord2fv(disp, vfmt->EvalCoord2fv); 831848b8605Smrg SET_EvalPoint1(disp, vfmt->EvalPoint1); 832848b8605Smrg SET_EvalPoint2(disp, vfmt->EvalPoint2); 833848b8605Smrg} 834848b8605Smrg 835848b8605Smrg 836848b8605Smrg/**********************************************************************/ 837848b8605Smrg/***** Initialization *****/ 838848b8605Smrg/**********************************************************************/ 839848b8605Smrg 840848b8605Smrg/** 841848b8605Smrg * Initialize a 1-D evaluator map. 842848b8605Smrg */ 843848b8605Smrgstatic void 844848b8605Smrginit_1d_map( struct gl_1d_map *map, int n, const float *initial ) 845848b8605Smrg{ 846848b8605Smrg map->Order = 1; 847848b8605Smrg map->u1 = 0.0; 848848b8605Smrg map->u2 = 1.0; 849848b8605Smrg map->Points = malloc(n * sizeof(GLfloat)); 850848b8605Smrg if (map->Points) { 851848b8605Smrg GLint i; 852848b8605Smrg for (i=0;i<n;i++) 853848b8605Smrg map->Points[i] = initial[i]; 854848b8605Smrg } 855848b8605Smrg} 856848b8605Smrg 857848b8605Smrg 858848b8605Smrg/** 859848b8605Smrg * Initialize a 2-D evaluator map 860848b8605Smrg */ 861848b8605Smrgstatic void 862848b8605Smrginit_2d_map( struct gl_2d_map *map, int n, const float *initial ) 863848b8605Smrg{ 864848b8605Smrg map->Uorder = 1; 865848b8605Smrg map->Vorder = 1; 866848b8605Smrg map->u1 = 0.0; 867848b8605Smrg map->u2 = 1.0; 868848b8605Smrg map->v1 = 0.0; 869848b8605Smrg map->v2 = 1.0; 870848b8605Smrg map->Points = malloc(n * sizeof(GLfloat)); 871848b8605Smrg if (map->Points) { 872848b8605Smrg GLint i; 873848b8605Smrg for (i=0;i<n;i++) 874848b8605Smrg map->Points[i] = initial[i]; 875848b8605Smrg } 876848b8605Smrg} 877848b8605Smrg 878848b8605Smrg 879848b8605Smrgvoid _mesa_init_eval( struct gl_context *ctx ) 880848b8605Smrg{ 881848b8605Smrg /* Evaluators group */ 882848b8605Smrg ctx->Eval.Map1Color4 = GL_FALSE; 883848b8605Smrg ctx->Eval.Map1Index = GL_FALSE; 884848b8605Smrg ctx->Eval.Map1Normal = GL_FALSE; 885848b8605Smrg ctx->Eval.Map1TextureCoord1 = GL_FALSE; 886848b8605Smrg ctx->Eval.Map1TextureCoord2 = GL_FALSE; 887848b8605Smrg ctx->Eval.Map1TextureCoord3 = GL_FALSE; 888848b8605Smrg ctx->Eval.Map1TextureCoord4 = GL_FALSE; 889848b8605Smrg ctx->Eval.Map1Vertex3 = GL_FALSE; 890848b8605Smrg ctx->Eval.Map1Vertex4 = GL_FALSE; 891848b8605Smrg ctx->Eval.Map2Color4 = GL_FALSE; 892848b8605Smrg ctx->Eval.Map2Index = GL_FALSE; 893848b8605Smrg ctx->Eval.Map2Normal = GL_FALSE; 894848b8605Smrg ctx->Eval.Map2TextureCoord1 = GL_FALSE; 895848b8605Smrg ctx->Eval.Map2TextureCoord2 = GL_FALSE; 896848b8605Smrg ctx->Eval.Map2TextureCoord3 = GL_FALSE; 897848b8605Smrg ctx->Eval.Map2TextureCoord4 = GL_FALSE; 898848b8605Smrg ctx->Eval.Map2Vertex3 = GL_FALSE; 899848b8605Smrg ctx->Eval.Map2Vertex4 = GL_FALSE; 900848b8605Smrg ctx->Eval.AutoNormal = GL_FALSE; 901848b8605Smrg ctx->Eval.MapGrid1un = 1; 902848b8605Smrg ctx->Eval.MapGrid1u1 = 0.0; 903848b8605Smrg ctx->Eval.MapGrid1u2 = 1.0; 904848b8605Smrg ctx->Eval.MapGrid2un = 1; 905848b8605Smrg ctx->Eval.MapGrid2vn = 1; 906848b8605Smrg ctx->Eval.MapGrid2u1 = 0.0; 907848b8605Smrg ctx->Eval.MapGrid2u2 = 1.0; 908848b8605Smrg ctx->Eval.MapGrid2v1 = 0.0; 909848b8605Smrg ctx->Eval.MapGrid2v2 = 1.0; 910848b8605Smrg 911848b8605Smrg /* Evaluator data */ 912848b8605Smrg { 913848b8605Smrg static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; 914848b8605Smrg static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; 915848b8605Smrg static GLfloat index[1] = { 1.0 }; 916848b8605Smrg static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; 917848b8605Smrg static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; 918848b8605Smrg 919848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); 920848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); 921848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); 922848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); 923848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); 924848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); 925848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); 926848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); 927848b8605Smrg init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); 928848b8605Smrg 929848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); 930848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); 931848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); 932848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); 933848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); 934848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); 935848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); 936848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); 937848b8605Smrg init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); 938848b8605Smrg } 939848b8605Smrg} 940848b8605Smrg 941848b8605Smrg 942848b8605Smrgvoid _mesa_free_eval_data( struct gl_context *ctx ) 943848b8605Smrg{ 944848b8605Smrg /* Free evaluator data */ 945848b8605Smrg free(ctx->EvalMap.Map1Vertex3.Points); 946848b8605Smrg free(ctx->EvalMap.Map1Vertex4.Points); 947848b8605Smrg free(ctx->EvalMap.Map1Index.Points); 948848b8605Smrg free(ctx->EvalMap.Map1Color4.Points); 949848b8605Smrg free(ctx->EvalMap.Map1Normal.Points); 950848b8605Smrg free(ctx->EvalMap.Map1Texture1.Points); 951848b8605Smrg free(ctx->EvalMap.Map1Texture2.Points); 952848b8605Smrg free(ctx->EvalMap.Map1Texture3.Points); 953848b8605Smrg free(ctx->EvalMap.Map1Texture4.Points); 954848b8605Smrg 955848b8605Smrg free(ctx->EvalMap.Map2Vertex3.Points); 956848b8605Smrg free(ctx->EvalMap.Map2Vertex4.Points); 957848b8605Smrg free(ctx->EvalMap.Map2Index.Points); 958848b8605Smrg free(ctx->EvalMap.Map2Color4.Points); 959848b8605Smrg free(ctx->EvalMap.Map2Normal.Points); 960848b8605Smrg free(ctx->EvalMap.Map2Texture1.Points); 961848b8605Smrg free(ctx->EvalMap.Map2Texture2.Points); 962848b8605Smrg free(ctx->EvalMap.Map2Texture3.Points); 963848b8605Smrg free(ctx->EvalMap.Map2Texture4.Points); 964848b8605Smrg} 965