From bc42c19f22c3b719712529d86faea818f34150a2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 5 Jan 2002 21:53:20 +0000 Subject: infrastructure for vertex program attribute evaluators --- src/mesa/main/attrib.c | 15 +- src/mesa/main/context.c | 11 +- src/mesa/main/enable.c | 25 +- src/mesa/main/eval.c | 1078 +++++++++++------------------------------------ src/mesa/main/mtypes.h | 8 +- 5 files changed, 304 insertions(+), 833 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 8b49cd4e96f..81365a6153e 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,4 +1,4 @@ -/* $Id: attrib.c,v 1.58 2001/12/14 02:50:01 brianp Exp $ */ +/* $Id: attrib.c,v 1.59 2002/01/05 21:53:20 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -210,6 +210,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4; attr->Map1Vertex3 = ctx->Eval.Map1Vertex3; attr->Map1Vertex4 = ctx->Eval.Map1Vertex4; + MEMCPY(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib)); attr->Map2Color4 = ctx->Eval.Map2Color4; attr->Map2Index = ctx->Eval.Map2Index; attr->Map2Normal = ctx->Eval.Map2Normal; @@ -219,6 +220,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4; attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; + MEMCPY(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib)); attr->Normalize = ctx->Transform.Normalize; attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped; attr->PixelTexture = ctx->Pixel.PixelTextureEnabled; @@ -474,6 +476,7 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) GL_INDEX_LOGIC_OP); TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp, GL_COLOR_LOGIC_OP); + TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4); TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX); TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL); @@ -489,6 +492,11 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) GL_MAP1_VERTEX_3); TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4, GL_MAP1_VERTEX_4); + for (i = 0; i < 16; i++) { + TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i], + GL_MAP1_VERTEX_ATTRIB0_4_NV + i); + } + TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4); TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX); TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL); @@ -504,6 +512,11 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) GL_MAP2_VERTEX_3); TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, GL_MAP2_VERTEX_4); + for (i = 0; i < 16; i++) { + TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i], + GL_MAP2_VERTEX_ATTRIB0_4_NV + i); + } + TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL); TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index cb5674c0a7f..7ccf4db4702 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,10 +1,10 @@ -/* $Id: context.c,v 1.152 2001/12/18 04:06:45 brianp Exp $ */ +/* $Id: context.c,v 1.153 2002/01/05 21:53:20 brianp Exp $ */ /* * Mesa 3-D graphics library * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -890,6 +890,7 @@ init_attrib_groups( GLcontext *ctx ) ctx->Eval.Map1TextureCoord4 = GL_FALSE; ctx->Eval.Map1Vertex3 = GL_FALSE; ctx->Eval.Map1Vertex4 = GL_FALSE; + MEMSET(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib)); ctx->Eval.Map2Color4 = GL_FALSE; ctx->Eval.Map2Index = GL_FALSE; ctx->Eval.Map2Normal = GL_FALSE; @@ -899,6 +900,7 @@ init_attrib_groups( GLcontext *ctx ) ctx->Eval.Map2TextureCoord4 = GL_FALSE; ctx->Eval.Map2Vertex3 = GL_FALSE; ctx->Eval.Map2Vertex4 = GL_FALSE; + MEMSET(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib)); ctx->Eval.AutoNormal = GL_FALSE; ctx->Eval.MapGrid1un = 1; ctx->Eval.MapGrid1u1 = 0.0; @@ -917,6 +919,7 @@ init_attrib_groups( GLcontext *ctx ) static GLfloat index[1] = { 1.0 }; static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 }; init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex ); init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex ); @@ -927,6 +930,8 @@ init_attrib_groups( GLcontext *ctx ) init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord ); init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord ); init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord ); + for (i = 0; i < 16; i++) + init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib ); init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex ); init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex ); @@ -937,6 +942,8 @@ init_attrib_groups( GLcontext *ctx ) init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord ); init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord ); init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord ); + for (i = 0; i < 16; i++) + init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib ); } /* Fog group */ diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 6f0b1bde00e..f82897fa463 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -1,4 +1,4 @@ -/* $Id: enable.c,v 1.52 2001/12/18 04:06:45 brianp Exp $ */ +/* $Id: enable.c,v 1.53 2002/01/05 21:53:20 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -836,6 +836,11 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) case GL_MAP1_VERTEX_ATTRIB14_4_NV: case GL_MAP1_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program); + { + const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map1Attrib[map] = state; + } break; case GL_MAP2_VERTEX_ATTRIB0_4_NV: case GL_MAP2_VERTEX_ATTRIB1_4_NV: @@ -854,6 +859,11 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) case GL_MAP2_VERTEX_ATTRIB14_4_NV: case GL_MAP2_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program); + { + const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); + FLUSH_VERTICES(ctx, _NEW_EVAL); + ctx->Eval.Map2Attrib[map] = state; + } break; default: @@ -867,8 +877,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) } - - void _mesa_Enable( GLenum cap ) { @@ -879,7 +887,6 @@ _mesa_Enable( GLenum cap ) } - void _mesa_Disable( GLenum cap ) { @@ -1191,7 +1198,10 @@ _mesa_IsEnabled( GLenum cap ) case GL_MAP1_VERTEX_ATTRIB14_4_NV: case GL_MAP1_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program); - return GL_FALSE; + { + const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); + return ctx->Eval.Map1Attrib[map]; + } case GL_MAP2_VERTEX_ATTRIB0_4_NV: case GL_MAP2_VERTEX_ATTRIB1_4_NV: case GL_MAP2_VERTEX_ATTRIB2_4_NV: @@ -1209,7 +1219,10 @@ _mesa_IsEnabled( GLenum cap ) case GL_MAP2_VERTEX_ATTRIB14_4_NV: case GL_MAP2_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program); - return GL_FALSE; + { + const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); + return ctx->Eval.Map2Attrib[map]; + } default: _mesa_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c index 732aec6720f..f3b97283928 100644 --- a/src/mesa/main/eval.c +++ b/src/mesa/main/eval.c @@ -1,10 +1,10 @@ -/* $Id: eval.c,v 1.21 2001/09/18 16:16:21 kschultz Exp $ */ +/* $Id: eval.c,v 1.22 2002/01/05 21:53:20 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -78,7 +78,122 @@ GLuint _mesa_evaluator_components( GLenum target ) case GL_MAP2_TEXTURE_COORD_2: return 2; case GL_MAP2_TEXTURE_COORD_3: return 3; case GL_MAP2_TEXTURE_COORD_4: return 4; - default: return 0; + default: break; + } + + /* XXX need to check for the vertex program extension + if (!ctx->Extensions.NV_vertex_program) + return 0; + */ + + if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV && + target <= GL_MAP1_VERTEX_ATTRIB15_4_NV) + return 4; + + if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV && + target <= GL_MAP2_VERTEX_ATTRIB15_4_NV) + return 4; + + return 0; +} + + +/* + * Return pointer to the gl_1d_map struct for the named target. + */ +static struct gl_1d_map * +get_1d_map( GLcontext *ctx, GLenum target ) +{ + switch (target) { + case GL_MAP1_VERTEX_3: + return &ctx->EvalMap.Map1Vertex3; + case GL_MAP1_VERTEX_4: + return &ctx->EvalMap.Map1Vertex4; + case GL_MAP1_INDEX: + return &ctx->EvalMap.Map1Index; + case GL_MAP1_COLOR_4: + return &ctx->EvalMap.Map1Color4; + case GL_MAP1_NORMAL: + return &ctx->EvalMap.Map1Normal; + case GL_MAP1_TEXTURE_COORD_1: + return &ctx->EvalMap.Map1Texture1; + case GL_MAP1_TEXTURE_COORD_2: + return &ctx->EvalMap.Map1Texture2; + case GL_MAP1_TEXTURE_COORD_3: + return &ctx->EvalMap.Map1Texture3; + case GL_MAP1_TEXTURE_COORD_4: + return &ctx->EvalMap.Map1Texture4; + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + if (!ctx->Extensions.NV_vertex_program) + return NULL; + return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV]; + default: + return NULL; + } +} + + +/* + * Return pointer to the gl_2d_map struct for the named target. + */ +static struct gl_2d_map * +get_2d_map( GLcontext *ctx, GLenum target ) +{ + switch (target) { + case GL_MAP2_VERTEX_3: + return &ctx->EvalMap.Map2Vertex3; + case GL_MAP2_VERTEX_4: + return &ctx->EvalMap.Map2Vertex4; + case GL_MAP2_INDEX: + return &ctx->EvalMap.Map2Index; + case GL_MAP2_COLOR_4: + return &ctx->EvalMap.Map2Color4; + case GL_MAP2_NORMAL: + return &ctx->EvalMap.Map2Normal; + case GL_MAP2_TEXTURE_COORD_1: + return &ctx->EvalMap.Map2Texture1; + case GL_MAP2_TEXTURE_COORD_2: + return &ctx->EvalMap.Map2Texture2; + case GL_MAP2_TEXTURE_COORD_3: + return &ctx->EvalMap.Map2Texture3; + case GL_MAP2_TEXTURE_COORD_4: + return &ctx->EvalMap.Map2Texture4; + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + if (!ctx->Extensions.NV_vertex_program) + return NULL; + return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV]; + default: + return NULL; } } @@ -96,20 +211,19 @@ GLuint _mesa_evaluator_components( GLenum target ) * of memory. */ GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, - const GLfloat *points ) + const GLfloat *points ) { GLfloat *buffer, *p; GLint i, k, size = _mesa_evaluator_components(target); - if (!points || size==0) { + if (!points || !size) return NULL; - } buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat)); - if(buffer) - for(i=0, p=buffer; iEvalMap.Map1Vertex3; - break; - case GL_MAP1_VERTEX_4: - map = &ctx->EvalMap.Map1Vertex4; - break; - case GL_MAP1_INDEX: - map = &ctx->EvalMap.Map1Index; - break; - case GL_MAP1_COLOR_4: - map = &ctx->EvalMap.Map1Color4; - break; - case GL_MAP1_NORMAL: - map = &ctx->EvalMap.Map1Normal; - break; - case GL_MAP1_TEXTURE_COORD_1: - map = &ctx->EvalMap.Map1Texture1; - break; - case GL_MAP1_TEXTURE_COORD_2: - map = &ctx->EvalMap.Map1Texture2; - break; - case GL_MAP1_TEXTURE_COORD_3: - map = &ctx->EvalMap.Map1Texture3; - break; - case GL_MAP1_TEXTURE_COORD_4: - map = &ctx->EvalMap.Map1Texture4; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); - return; + map = get_1d_map(ctx, target); + if (!map) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); + return; } /* make copy of the control points */ @@ -404,37 +490,10 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, return; } - switch (target) { - case GL_MAP2_VERTEX_3: - map = &ctx->EvalMap.Map2Vertex3; - break; - case GL_MAP2_VERTEX_4: - map = &ctx->EvalMap.Map2Vertex4; - break; - case GL_MAP2_INDEX: - map = &ctx->EvalMap.Map2Index; - break; - case GL_MAP2_COLOR_4: - map = &ctx->EvalMap.Map2Color4; - break; - case GL_MAP2_NORMAL: - map = &ctx->EvalMap.Map2Normal; - break; - case GL_MAP2_TEXTURE_COORD_1: - map = &ctx->EvalMap.Map2Texture1; - break; - case GL_MAP2_TEXTURE_COORD_2: - map = &ctx->EvalMap.Map2Texture2; - break; - case GL_MAP2_TEXTURE_COORD_3: - map = &ctx->EvalMap.Map2Texture3; - break; - case GL_MAP2_TEXTURE_COORD_4: - map = &ctx->EvalMap.Map2Texture4; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); - return; + map = get_2d_map(ctx, target); + if (!map) { + _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); + return; } /* make copy of the control points */ @@ -488,98 +547,34 @@ void _mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v ) { GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; GLint i, n; GLfloat *data; + GLuint comps; + ASSERT_OUTSIDE_BEGIN_END(ctx); + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + switch (query) { case GL_COEFF: - switch (target) { - case GL_MAP1_COLOR_4: - data = ctx->EvalMap.Map1Color4.Points; - n = ctx->EvalMap.Map1Color4.Order * 4; - break; - case GL_MAP1_INDEX: - data = ctx->EvalMap.Map1Index.Points; - n = ctx->EvalMap.Map1Index.Order; - break; - case GL_MAP1_NORMAL: - data = ctx->EvalMap.Map1Normal.Points; - n = ctx->EvalMap.Map1Normal.Order * 3; - break; - case GL_MAP1_TEXTURE_COORD_1: - data = ctx->EvalMap.Map1Texture1.Points; - n = ctx->EvalMap.Map1Texture1.Order * 1; - break; - case GL_MAP1_TEXTURE_COORD_2: - data = ctx->EvalMap.Map1Texture2.Points; - n = ctx->EvalMap.Map1Texture2.Order * 2; - break; - case GL_MAP1_TEXTURE_COORD_3: - data = ctx->EvalMap.Map1Texture3.Points; - n = ctx->EvalMap.Map1Texture3.Order * 3; - break; - case GL_MAP1_TEXTURE_COORD_4: - data = ctx->EvalMap.Map1Texture4.Points; - n = ctx->EvalMap.Map1Texture4.Order * 4; - break; - case GL_MAP1_VERTEX_3: - data = ctx->EvalMap.Map1Vertex3.Points; - n = ctx->EvalMap.Map1Vertex3.Order * 3; - break; - case GL_MAP1_VERTEX_4: - data = ctx->EvalMap.Map1Vertex4.Points; - n = ctx->EvalMap.Map1Vertex4.Order * 4; - break; - case GL_MAP2_COLOR_4: - data = ctx->EvalMap.Map2Color4.Points; - n = ctx->EvalMap.Map2Color4.Uorder - * ctx->EvalMap.Map2Color4.Vorder * 4; - break; - case GL_MAP2_INDEX: - data = ctx->EvalMap.Map2Index.Points; - n = ctx->EvalMap.Map2Index.Uorder - * ctx->EvalMap.Map2Index.Vorder; - break; - case GL_MAP2_NORMAL: - data = ctx->EvalMap.Map2Normal.Points; - n = ctx->EvalMap.Map2Normal.Uorder - * ctx->EvalMap.Map2Normal.Vorder * 3; - break; - case GL_MAP2_TEXTURE_COORD_1: - data = ctx->EvalMap.Map2Texture1.Points; - n = ctx->EvalMap.Map2Texture1.Uorder - * ctx->EvalMap.Map2Texture1.Vorder * 1; - break; - case GL_MAP2_TEXTURE_COORD_2: - data = ctx->EvalMap.Map2Texture2.Points; - n = ctx->EvalMap.Map2Texture2.Uorder - * ctx->EvalMap.Map2Texture2.Vorder * 2; - break; - case GL_MAP2_TEXTURE_COORD_3: - data = ctx->EvalMap.Map2Texture3.Points; - n = ctx->EvalMap.Map2Texture3.Uorder - * ctx->EvalMap.Map2Texture3.Vorder * 3; - break; - case GL_MAP2_TEXTURE_COORD_4: - data = ctx->EvalMap.Map2Texture4.Points; - n = ctx->EvalMap.Map2Texture4.Uorder - * ctx->EvalMap.Map2Texture4.Vorder * 4; - break; - case GL_MAP2_VERTEX_3: - data = ctx->EvalMap.Map2Vertex3.Points; - n = ctx->EvalMap.Map2Vertex3.Uorder - * ctx->EvalMap.Map2Vertex3.Vorder * 3; - break; - case GL_MAP2_VERTEX_4: - data = ctx->EvalMap.Map2Vertex4.Points; - n = ctx->EvalMap.Map2Vertex4.Uorder - * ctx->EvalMap.Map2Vertex4.Vorder * 4; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); - return; - } + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } if (data) { for (i=0;iEvalMap.Map1Color4.Order; - break; - case GL_MAP1_INDEX: - *v = ctx->EvalMap.Map1Index.Order; - break; - case GL_MAP1_NORMAL: - *v = ctx->EvalMap.Map1Normal.Order; - break; - case GL_MAP1_TEXTURE_COORD_1: - *v = ctx->EvalMap.Map1Texture1.Order; - break; - case GL_MAP1_TEXTURE_COORD_2: - *v = ctx->EvalMap.Map1Texture2.Order; - break; - case GL_MAP1_TEXTURE_COORD_3: - *v = ctx->EvalMap.Map1Texture3.Order; - break; - case GL_MAP1_TEXTURE_COORD_4: - *v = ctx->EvalMap.Map1Texture4.Order; - break; - case GL_MAP1_VERTEX_3: - *v = ctx->EvalMap.Map1Vertex3.Order; - break; - case GL_MAP1_VERTEX_4: - *v = ctx->EvalMap.Map1Vertex4.Order; - break; - case GL_MAP2_COLOR_4: - v[0] = ctx->EvalMap.Map2Color4.Uorder; - v[1] = ctx->EvalMap.Map2Color4.Vorder; - break; - case GL_MAP2_INDEX: - v[0] = ctx->EvalMap.Map2Index.Uorder; - v[1] = ctx->EvalMap.Map2Index.Vorder; - break; - case GL_MAP2_NORMAL: - v[0] = ctx->EvalMap.Map2Normal.Uorder; - v[1] = ctx->EvalMap.Map2Normal.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_1: - v[0] = ctx->EvalMap.Map2Texture1.Uorder; - v[1] = ctx->EvalMap.Map2Texture1.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_2: - v[0] = ctx->EvalMap.Map2Texture2.Uorder; - v[1] = ctx->EvalMap.Map2Texture2.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_3: - v[0] = ctx->EvalMap.Map2Texture3.Uorder; - v[1] = ctx->EvalMap.Map2Texture3.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_4: - v[0] = ctx->EvalMap.Map2Texture4.Uorder; - v[1] = ctx->EvalMap.Map2Texture4.Vorder; - break; - case GL_MAP2_VERTEX_3: - v[0] = ctx->EvalMap.Map2Vertex3.Uorder; - v[1] = ctx->EvalMap.Map2Vertex3.Vorder; - break; - case GL_MAP2_VERTEX_4: - v[0] = ctx->EvalMap.Map2Vertex4.Uorder; - v[1] = ctx->EvalMap.Map2Vertex4.Vorder; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); - return; - } + if (map1d) { + v[0] = (GLdouble) map1d->Order; + } + else { + v[0] = (GLdouble) map2d->Uorder; + v[1] = (GLdouble) map2d->Vorder; + } break; case GL_DOMAIN: - switch (target) { - case GL_MAP1_COLOR_4: - v[0] = ctx->EvalMap.Map1Color4.u1; - v[1] = ctx->EvalMap.Map1Color4.u2; - break; - case GL_MAP1_INDEX: - v[0] = ctx->EvalMap.Map1Index.u1; - v[1] = ctx->EvalMap.Map1Index.u2; - break; - case GL_MAP1_NORMAL: - v[0] = ctx->EvalMap.Map1Normal.u1; - v[1] = ctx->EvalMap.Map1Normal.u2; - break; - case GL_MAP1_TEXTURE_COORD_1: - v[0] = ctx->EvalMap.Map1Texture1.u1; - v[1] = ctx->EvalMap.Map1Texture1.u2; - break; - case GL_MAP1_TEXTURE_COORD_2: - v[0] = ctx->EvalMap.Map1Texture2.u1; - v[1] = ctx->EvalMap.Map1Texture2.u2; - break; - case GL_MAP1_TEXTURE_COORD_3: - v[0] = ctx->EvalMap.Map1Texture3.u1; - v[1] = ctx->EvalMap.Map1Texture3.u2; - break; - case GL_MAP1_TEXTURE_COORD_4: - v[0] = ctx->EvalMap.Map1Texture4.u1; - v[1] = ctx->EvalMap.Map1Texture4.u2; - break; - case GL_MAP1_VERTEX_3: - v[0] = ctx->EvalMap.Map1Vertex3.u1; - v[1] = ctx->EvalMap.Map1Vertex3.u2; - break; - case GL_MAP1_VERTEX_4: - v[0] = ctx->EvalMap.Map1Vertex4.u1; - v[1] = ctx->EvalMap.Map1Vertex4.u2; - break; - case GL_MAP2_COLOR_4: - v[0] = ctx->EvalMap.Map2Color4.u1; - v[1] = ctx->EvalMap.Map2Color4.u2; - v[2] = ctx->EvalMap.Map2Color4.v1; - v[3] = ctx->EvalMap.Map2Color4.v2; - break; - case GL_MAP2_INDEX: - v[0] = ctx->EvalMap.Map2Index.u1; - v[1] = ctx->EvalMap.Map2Index.u2; - v[2] = ctx->EvalMap.Map2Index.v1; - v[3] = ctx->EvalMap.Map2Index.v2; - break; - case GL_MAP2_NORMAL: - v[0] = ctx->EvalMap.Map2Normal.u1; - v[1] = ctx->EvalMap.Map2Normal.u2; - v[2] = ctx->EvalMap.Map2Normal.v1; - v[3] = ctx->EvalMap.Map2Normal.v2; - break; - case GL_MAP2_TEXTURE_COORD_1: - v[0] = ctx->EvalMap.Map2Texture1.u1; - v[1] = ctx->EvalMap.Map2Texture1.u2; - v[2] = ctx->EvalMap.Map2Texture1.v1; - v[3] = ctx->EvalMap.Map2Texture1.v2; - break; - case GL_MAP2_TEXTURE_COORD_2: - v[0] = ctx->EvalMap.Map2Texture2.u1; - v[1] = ctx->EvalMap.Map2Texture2.u2; - v[2] = ctx->EvalMap.Map2Texture2.v1; - v[3] = ctx->EvalMap.Map2Texture2.v2; - break; - case GL_MAP2_TEXTURE_COORD_3: - v[0] = ctx->EvalMap.Map2Texture3.u1; - v[1] = ctx->EvalMap.Map2Texture3.u2; - v[2] = ctx->EvalMap.Map2Texture3.v1; - v[3] = ctx->EvalMap.Map2Texture3.v2; - break; - case GL_MAP2_TEXTURE_COORD_4: - v[0] = ctx->EvalMap.Map2Texture4.u1; - v[1] = ctx->EvalMap.Map2Texture4.u2; - v[2] = ctx->EvalMap.Map2Texture4.v1; - v[3] = ctx->EvalMap.Map2Texture4.v2; - break; - case GL_MAP2_VERTEX_3: - v[0] = ctx->EvalMap.Map2Vertex3.u1; - v[1] = ctx->EvalMap.Map2Vertex3.u2; - v[2] = ctx->EvalMap.Map2Vertex3.v1; - v[3] = ctx->EvalMap.Map2Vertex3.v2; - break; - case GL_MAP2_VERTEX_4: - v[0] = ctx->EvalMap.Map2Vertex4.u1; - v[1] = ctx->EvalMap.Map2Vertex4.u2; - v[2] = ctx->EvalMap.Map2Vertex4.v1; - v[3] = ctx->EvalMap.Map2Vertex4.v2; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); - } + if (map1d) { + v[0] = (GLdouble) map1d->u1; + v[1] = (GLdouble) map1d->u2; + } + else { + v[0] = (GLdouble) map2d->u1; + v[1] = (GLdouble) map2d->u2; + v[2] = (GLdouble) map2d->v1; + v[3] = (GLdouble) map2d->v2; + } break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" ); @@ -762,98 +612,34 @@ void _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v ) { GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; GLint i, n; GLfloat *data; + GLuint comps; + ASSERT_OUTSIDE_BEGIN_END(ctx); + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + switch (query) { case GL_COEFF: - switch (target) { - case GL_MAP1_COLOR_4: - data = ctx->EvalMap.Map1Color4.Points; - n = ctx->EvalMap.Map1Color4.Order * 4; - break; - case GL_MAP1_INDEX: - data = ctx->EvalMap.Map1Index.Points; - n = ctx->EvalMap.Map1Index.Order; - break; - case GL_MAP1_NORMAL: - data = ctx->EvalMap.Map1Normal.Points; - n = ctx->EvalMap.Map1Normal.Order * 3; - break; - case GL_MAP1_TEXTURE_COORD_1: - data = ctx->EvalMap.Map1Texture1.Points; - n = ctx->EvalMap.Map1Texture1.Order * 1; - break; - case GL_MAP1_TEXTURE_COORD_2: - data = ctx->EvalMap.Map1Texture2.Points; - n = ctx->EvalMap.Map1Texture2.Order * 2; - break; - case GL_MAP1_TEXTURE_COORD_3: - data = ctx->EvalMap.Map1Texture3.Points; - n = ctx->EvalMap.Map1Texture3.Order * 3; - break; - case GL_MAP1_TEXTURE_COORD_4: - data = ctx->EvalMap.Map1Texture4.Points; - n = ctx->EvalMap.Map1Texture4.Order * 4; - break; - case GL_MAP1_VERTEX_3: - data = ctx->EvalMap.Map1Vertex3.Points; - n = ctx->EvalMap.Map1Vertex3.Order * 3; - break; - case GL_MAP1_VERTEX_4: - data = ctx->EvalMap.Map1Vertex4.Points; - n = ctx->EvalMap.Map1Vertex4.Order * 4; - break; - case GL_MAP2_COLOR_4: - data = ctx->EvalMap.Map2Color4.Points; - n = ctx->EvalMap.Map2Color4.Uorder - * ctx->EvalMap.Map2Color4.Vorder * 4; - break; - case GL_MAP2_INDEX: - data = ctx->EvalMap.Map2Index.Points; - n = ctx->EvalMap.Map2Index.Uorder - * ctx->EvalMap.Map2Index.Vorder; - break; - case GL_MAP2_NORMAL: - data = ctx->EvalMap.Map2Normal.Points; - n = ctx->EvalMap.Map2Normal.Uorder - * ctx->EvalMap.Map2Normal.Vorder * 3; - break; - case GL_MAP2_TEXTURE_COORD_1: - data = ctx->EvalMap.Map2Texture1.Points; - n = ctx->EvalMap.Map2Texture1.Uorder - * ctx->EvalMap.Map2Texture1.Vorder * 1; - break; - case GL_MAP2_TEXTURE_COORD_2: - data = ctx->EvalMap.Map2Texture2.Points; - n = ctx->EvalMap.Map2Texture2.Uorder - * ctx->EvalMap.Map2Texture2.Vorder * 2; - break; - case GL_MAP2_TEXTURE_COORD_3: - data = ctx->EvalMap.Map2Texture3.Points; - n = ctx->EvalMap.Map2Texture3.Uorder - * ctx->EvalMap.Map2Texture3.Vorder * 3; - break; - case GL_MAP2_TEXTURE_COORD_4: - data = ctx->EvalMap.Map2Texture4.Points; - n = ctx->EvalMap.Map2Texture4.Uorder - * ctx->EvalMap.Map2Texture4.Vorder * 4; - break; - case GL_MAP2_VERTEX_3: - data = ctx->EvalMap.Map2Vertex3.Points; - n = ctx->EvalMap.Map2Vertex3.Uorder - * ctx->EvalMap.Map2Vertex3.Vorder * 3; - break; - case GL_MAP2_VERTEX_4: - data = ctx->EvalMap.Map2Vertex4.Points; - n = ctx->EvalMap.Map2Vertex4.Uorder - * ctx->EvalMap.Map2Vertex4.Vorder * 4; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); - return; - } + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } if (data) { for (i=0;iEvalMap.Map1Color4.Order; - break; - case GL_MAP1_INDEX: - *v = (GLfloat) ctx->EvalMap.Map1Index.Order; - break; - case GL_MAP1_NORMAL: - *v = (GLfloat) ctx->EvalMap.Map1Normal.Order; - break; - case GL_MAP1_TEXTURE_COORD_1: - *v = (GLfloat) ctx->EvalMap.Map1Texture1.Order; - break; - case GL_MAP1_TEXTURE_COORD_2: - *v = (GLfloat) ctx->EvalMap.Map1Texture2.Order; - break; - case GL_MAP1_TEXTURE_COORD_3: - *v = (GLfloat) ctx->EvalMap.Map1Texture3.Order; - break; - case GL_MAP1_TEXTURE_COORD_4: - *v = (GLfloat) ctx->EvalMap.Map1Texture4.Order; - break; - case GL_MAP1_VERTEX_3: - *v = (GLfloat) ctx->EvalMap.Map1Vertex3.Order; - break; - case GL_MAP1_VERTEX_4: - *v = (GLfloat) ctx->EvalMap.Map1Vertex4.Order; - break; - case GL_MAP2_COLOR_4: - v[0] = (GLfloat) ctx->EvalMap.Map2Color4.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Color4.Vorder; - break; - case GL_MAP2_INDEX: - v[0] = (GLfloat) ctx->EvalMap.Map2Index.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Index.Vorder; - break; - case GL_MAP2_NORMAL: - v[0] = (GLfloat) ctx->EvalMap.Map2Normal.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Normal.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_1: - v[0] = (GLfloat) ctx->EvalMap.Map2Texture1.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Texture1.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_2: - v[0] = (GLfloat) ctx->EvalMap.Map2Texture2.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Texture2.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_3: - v[0] = (GLfloat) ctx->EvalMap.Map2Texture3.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Texture3.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_4: - v[0] = (GLfloat) ctx->EvalMap.Map2Texture4.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Texture4.Vorder; - break; - case GL_MAP2_VERTEX_3: - v[0] = (GLfloat) ctx->EvalMap.Map2Vertex3.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Vertex3.Vorder; - break; - case GL_MAP2_VERTEX_4: - v[0] = (GLfloat) ctx->EvalMap.Map2Vertex4.Uorder; - v[1] = (GLfloat) ctx->EvalMap.Map2Vertex4.Vorder; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); - return; - } + if (map1d) { + v[0] = (GLfloat) map1d->Order; + } + else { + v[0] = (GLfloat) map2d->Uorder; + v[1] = (GLfloat) map2d->Vorder; + } break; case GL_DOMAIN: - switch (target) { - case GL_MAP1_COLOR_4: - v[0] = ctx->EvalMap.Map1Color4.u1; - v[1] = ctx->EvalMap.Map1Color4.u2; - break; - case GL_MAP1_INDEX: - v[0] = ctx->EvalMap.Map1Index.u1; - v[1] = ctx->EvalMap.Map1Index.u2; - break; - case GL_MAP1_NORMAL: - v[0] = ctx->EvalMap.Map1Normal.u1; - v[1] = ctx->EvalMap.Map1Normal.u2; - break; - case GL_MAP1_TEXTURE_COORD_1: - v[0] = ctx->EvalMap.Map1Texture1.u1; - v[1] = ctx->EvalMap.Map1Texture1.u2; - break; - case GL_MAP1_TEXTURE_COORD_2: - v[0] = ctx->EvalMap.Map1Texture2.u1; - v[1] = ctx->EvalMap.Map1Texture2.u2; - break; - case GL_MAP1_TEXTURE_COORD_3: - v[0] = ctx->EvalMap.Map1Texture3.u1; - v[1] = ctx->EvalMap.Map1Texture3.u2; - break; - case GL_MAP1_TEXTURE_COORD_4: - v[0] = ctx->EvalMap.Map1Texture4.u1; - v[1] = ctx->EvalMap.Map1Texture4.u2; - break; - case GL_MAP1_VERTEX_3: - v[0] = ctx->EvalMap.Map1Vertex3.u1; - v[1] = ctx->EvalMap.Map1Vertex3.u2; - break; - case GL_MAP1_VERTEX_4: - v[0] = ctx->EvalMap.Map1Vertex4.u1; - v[1] = ctx->EvalMap.Map1Vertex4.u2; - break; - case GL_MAP2_COLOR_4: - v[0] = ctx->EvalMap.Map2Color4.u1; - v[1] = ctx->EvalMap.Map2Color4.u2; - v[2] = ctx->EvalMap.Map2Color4.v1; - v[3] = ctx->EvalMap.Map2Color4.v2; - break; - case GL_MAP2_INDEX: - v[0] = ctx->EvalMap.Map2Index.u1; - v[1] = ctx->EvalMap.Map2Index.u2; - v[2] = ctx->EvalMap.Map2Index.v1; - v[3] = ctx->EvalMap.Map2Index.v2; - break; - case GL_MAP2_NORMAL: - v[0] = ctx->EvalMap.Map2Normal.u1; - v[1] = ctx->EvalMap.Map2Normal.u2; - v[2] = ctx->EvalMap.Map2Normal.v1; - v[3] = ctx->EvalMap.Map2Normal.v2; - break; - case GL_MAP2_TEXTURE_COORD_1: - v[0] = ctx->EvalMap.Map2Texture1.u1; - v[1] = ctx->EvalMap.Map2Texture1.u2; - v[2] = ctx->EvalMap.Map2Texture1.v1; - v[3] = ctx->EvalMap.Map2Texture1.v2; - break; - case GL_MAP2_TEXTURE_COORD_2: - v[0] = ctx->EvalMap.Map2Texture2.u1; - v[1] = ctx->EvalMap.Map2Texture2.u2; - v[2] = ctx->EvalMap.Map2Texture2.v1; - v[3] = ctx->EvalMap.Map2Texture2.v2; - break; - case GL_MAP2_TEXTURE_COORD_3: - v[0] = ctx->EvalMap.Map2Texture3.u1; - v[1] = ctx->EvalMap.Map2Texture3.u2; - v[2] = ctx->EvalMap.Map2Texture3.v1; - v[3] = ctx->EvalMap.Map2Texture3.v2; - break; - case GL_MAP2_TEXTURE_COORD_4: - v[0] = ctx->EvalMap.Map2Texture4.u1; - v[1] = ctx->EvalMap.Map2Texture4.u2; - v[2] = ctx->EvalMap.Map2Texture4.v1; - v[3] = ctx->EvalMap.Map2Texture4.v2; - break; - case GL_MAP2_VERTEX_3: - v[0] = ctx->EvalMap.Map2Vertex3.u1; - v[1] = ctx->EvalMap.Map2Vertex3.u2; - v[2] = ctx->EvalMap.Map2Vertex3.v1; - v[3] = ctx->EvalMap.Map2Vertex3.v2; - break; - case GL_MAP2_VERTEX_4: - v[0] = ctx->EvalMap.Map2Vertex4.u1; - v[1] = ctx->EvalMap.Map2Vertex4.u2; - v[2] = ctx->EvalMap.Map2Vertex4.v1; - v[3] = ctx->EvalMap.Map2Vertex4.v2; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" ); - } + if (map1d) { + v[0] = map1d->u1; + v[1] = map1d->u2; + } + else { + v[0] = map2d->u1; + v[1] = map2d->u2; + v[2] = map2d->v1; + v[3] = map2d->v2; + } break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" ); @@ -1036,98 +677,34 @@ void _mesa_GetMapiv( GLenum target, GLenum query, GLint *v ) { GET_CURRENT_CONTEXT(ctx); + struct gl_1d_map *map1d; + struct gl_2d_map *map2d; GLuint i, n; GLfloat *data; + GLuint comps; + ASSERT_OUTSIDE_BEGIN_END(ctx); + comps = _mesa_evaluator_components(target); + if (!comps) { + _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" ); + return; + } + + map1d = get_1d_map(ctx, target); + map2d = get_2d_map(ctx, target); + ASSERT(map1d || map2d); + switch (query) { case GL_COEFF: - switch (target) { - case GL_MAP1_COLOR_4: - data = ctx->EvalMap.Map1Color4.Points; - n = ctx->EvalMap.Map1Color4.Order * 4; - break; - case GL_MAP1_INDEX: - data = ctx->EvalMap.Map1Index.Points; - n = ctx->EvalMap.Map1Index.Order; - break; - case GL_MAP1_NORMAL: - data = ctx->EvalMap.Map1Normal.Points; - n = ctx->EvalMap.Map1Normal.Order * 3; - break; - case GL_MAP1_TEXTURE_COORD_1: - data = ctx->EvalMap.Map1Texture1.Points; - n = ctx->EvalMap.Map1Texture1.Order * 1; - break; - case GL_MAP1_TEXTURE_COORD_2: - data = ctx->EvalMap.Map1Texture2.Points; - n = ctx->EvalMap.Map1Texture2.Order * 2; - break; - case GL_MAP1_TEXTURE_COORD_3: - data = ctx->EvalMap.Map1Texture3.Points; - n = ctx->EvalMap.Map1Texture3.Order * 3; - break; - case GL_MAP1_TEXTURE_COORD_4: - data = ctx->EvalMap.Map1Texture4.Points; - n = ctx->EvalMap.Map1Texture4.Order * 4; - break; - case GL_MAP1_VERTEX_3: - data = ctx->EvalMap.Map1Vertex3.Points; - n = ctx->EvalMap.Map1Vertex3.Order * 3; - break; - case GL_MAP1_VERTEX_4: - data = ctx->EvalMap.Map1Vertex4.Points; - n = ctx->EvalMap.Map1Vertex4.Order * 4; - break; - case GL_MAP2_COLOR_4: - data = ctx->EvalMap.Map2Color4.Points; - n = ctx->EvalMap.Map2Color4.Uorder - * ctx->EvalMap.Map2Color4.Vorder * 4; - break; - case GL_MAP2_INDEX: - data = ctx->EvalMap.Map2Index.Points; - n = ctx->EvalMap.Map2Index.Uorder - * ctx->EvalMap.Map2Index.Vorder; - break; - case GL_MAP2_NORMAL: - data = ctx->EvalMap.Map2Normal.Points; - n = ctx->EvalMap.Map2Normal.Uorder - * ctx->EvalMap.Map2Normal.Vorder * 3; - break; - case GL_MAP2_TEXTURE_COORD_1: - data = ctx->EvalMap.Map2Texture1.Points; - n = ctx->EvalMap.Map2Texture1.Uorder - * ctx->EvalMap.Map2Texture1.Vorder * 1; - break; - case GL_MAP2_TEXTURE_COORD_2: - data = ctx->EvalMap.Map2Texture2.Points; - n = ctx->EvalMap.Map2Texture2.Uorder - * ctx->EvalMap.Map2Texture2.Vorder * 2; - break; - case GL_MAP2_TEXTURE_COORD_3: - data = ctx->EvalMap.Map2Texture3.Points; - n = ctx->EvalMap.Map2Texture3.Uorder - * ctx->EvalMap.Map2Texture3.Vorder * 3; - break; - case GL_MAP2_TEXTURE_COORD_4: - data = ctx->EvalMap.Map2Texture4.Points; - n = ctx->EvalMap.Map2Texture4.Uorder - * ctx->EvalMap.Map2Texture4.Vorder * 4; - break; - case GL_MAP2_VERTEX_3: - data = ctx->EvalMap.Map2Vertex3.Points; - n = ctx->EvalMap.Map2Vertex3.Uorder - * ctx->EvalMap.Map2Vertex3.Vorder * 3; - break; - case GL_MAP2_VERTEX_4: - data = ctx->EvalMap.Map2Vertex4.Points; - n = ctx->EvalMap.Map2Vertex4.Uorder - * ctx->EvalMap.Map2Vertex4.Vorder * 4; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); - return; - } + if (map1d) { + data = map1d->Points; + n = map1d->Order * comps; + } + else { + data = map2d->Points; + n = map2d->Uorder * map2d->Vorder * comps; + } if (data) { for (i=0;iEvalMap.Map1Color4.Order; - break; - case GL_MAP1_INDEX: - *v = ctx->EvalMap.Map1Index.Order; - break; - case GL_MAP1_NORMAL: - *v = ctx->EvalMap.Map1Normal.Order; - break; - case GL_MAP1_TEXTURE_COORD_1: - *v = ctx->EvalMap.Map1Texture1.Order; - break; - case GL_MAP1_TEXTURE_COORD_2: - *v = ctx->EvalMap.Map1Texture2.Order; - break; - case GL_MAP1_TEXTURE_COORD_3: - *v = ctx->EvalMap.Map1Texture3.Order; - break; - case GL_MAP1_TEXTURE_COORD_4: - *v = ctx->EvalMap.Map1Texture4.Order; - break; - case GL_MAP1_VERTEX_3: - *v = ctx->EvalMap.Map1Vertex3.Order; - break; - case GL_MAP1_VERTEX_4: - *v = ctx->EvalMap.Map1Vertex4.Order; - break; - case GL_MAP2_COLOR_4: - v[0] = ctx->EvalMap.Map2Color4.Uorder; - v[1] = ctx->EvalMap.Map2Color4.Vorder; - break; - case GL_MAP2_INDEX: - v[0] = ctx->EvalMap.Map2Index.Uorder; - v[1] = ctx->EvalMap.Map2Index.Vorder; - break; - case GL_MAP2_NORMAL: - v[0] = ctx->EvalMap.Map2Normal.Uorder; - v[1] = ctx->EvalMap.Map2Normal.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_1: - v[0] = ctx->EvalMap.Map2Texture1.Uorder; - v[1] = ctx->EvalMap.Map2Texture1.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_2: - v[0] = ctx->EvalMap.Map2Texture2.Uorder; - v[1] = ctx->EvalMap.Map2Texture2.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_3: - v[0] = ctx->EvalMap.Map2Texture3.Uorder; - v[1] = ctx->EvalMap.Map2Texture3.Vorder; - break; - case GL_MAP2_TEXTURE_COORD_4: - v[0] = ctx->EvalMap.Map2Texture4.Uorder; - v[1] = ctx->EvalMap.Map2Texture4.Vorder; - break; - case GL_MAP2_VERTEX_3: - v[0] = ctx->EvalMap.Map2Vertex3.Uorder; - v[1] = ctx->EvalMap.Map2Vertex3.Vorder; - break; - case GL_MAP2_VERTEX_4: - v[0] = ctx->EvalMap.Map2Vertex4.Uorder; - v[1] = ctx->EvalMap.Map2Vertex4.Vorder; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); - return; - } + if (map1d) { + v[0] = map1d->Order; + } + else { + v[0] = map2d->Uorder; + v[1] = map2d->Vorder; + } break; case GL_DOMAIN: - switch (target) { - case GL_MAP1_COLOR_4: - v[0] = ROUNDF(ctx->EvalMap.Map1Color4.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Color4.u2); - break; - case GL_MAP1_INDEX: - v[0] = ROUNDF(ctx->EvalMap.Map1Index.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Index.u2); - break; - case GL_MAP1_NORMAL: - v[0] = ROUNDF(ctx->EvalMap.Map1Normal.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Normal.u2); - break; - case GL_MAP1_TEXTURE_COORD_1: - v[0] = ROUNDF(ctx->EvalMap.Map1Texture1.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Texture1.u2); - break; - case GL_MAP1_TEXTURE_COORD_2: - v[0] = ROUNDF(ctx->EvalMap.Map1Texture2.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Texture2.u2); - break; - case GL_MAP1_TEXTURE_COORD_3: - v[0] = ROUNDF(ctx->EvalMap.Map1Texture3.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Texture3.u2); - break; - case GL_MAP1_TEXTURE_COORD_4: - v[0] = ROUNDF(ctx->EvalMap.Map1Texture4.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Texture4.u2); - break; - case GL_MAP1_VERTEX_3: - v[0] = ROUNDF(ctx->EvalMap.Map1Vertex3.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Vertex3.u2); - break; - case GL_MAP1_VERTEX_4: - v[0] = ROUNDF(ctx->EvalMap.Map1Vertex4.u1); - v[1] = ROUNDF(ctx->EvalMap.Map1Vertex4.u2); - break; - case GL_MAP2_COLOR_4: - v[0] = ROUNDF(ctx->EvalMap.Map2Color4.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Color4.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Color4.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Color4.v2); - break; - case GL_MAP2_INDEX: - v[0] = ROUNDF(ctx->EvalMap.Map2Index.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Index.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Index.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Index.v2); - break; - case GL_MAP2_NORMAL: - v[0] = ROUNDF(ctx->EvalMap.Map2Normal.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Normal.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Normal.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Normal.v2); - break; - case GL_MAP2_TEXTURE_COORD_1: - v[0] = ROUNDF(ctx->EvalMap.Map2Texture1.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Texture1.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Texture1.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Texture1.v2); - break; - case GL_MAP2_TEXTURE_COORD_2: - v[0] = ROUNDF(ctx->EvalMap.Map2Texture2.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Texture2.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Texture2.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Texture2.v2); - break; - case GL_MAP2_TEXTURE_COORD_3: - v[0] = ROUNDF(ctx->EvalMap.Map2Texture3.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Texture3.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Texture3.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Texture3.v2); - break; - case GL_MAP2_TEXTURE_COORD_4: - v[0] = ROUNDF(ctx->EvalMap.Map2Texture4.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Texture4.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Texture4.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Texture4.v2); - break; - case GL_MAP2_VERTEX_3: - v[0] = ROUNDF(ctx->EvalMap.Map2Vertex3.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Vertex3.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Vertex3.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Vertex3.v2); - break; - case GL_MAP2_VERTEX_4: - v[0] = ROUNDF(ctx->EvalMap.Map2Vertex4.u1); - v[1] = ROUNDF(ctx->EvalMap.Map2Vertex4.u2); - v[2] = ROUNDF(ctx->EvalMap.Map2Vertex4.v1); - v[3] = ROUNDF(ctx->EvalMap.Map2Vertex4.v2); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); - } + if (map1d) { + v[0] = ROUNDF(map1d->u1); + v[1] = ROUNDF(map1d->u2); + } + else { + v[0] = ROUNDF(map2d->u1); + v[1] = ROUNDF(map2d->u2); + v[2] = ROUNDF(map2d->v1); + v[3] = ROUNDF(map2d->v2); + } break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e97ba8c8ce1..f6a3391215e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.57 2002/01/05 20:51:12 brianp Exp $ */ +/* $Id: mtypes.h,v 1.58 2002/01/05 21:53:20 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -377,6 +377,7 @@ struct gl_enable_attrib { GLboolean Map1TextureCoord4; GLboolean Map1Vertex3; GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ GLboolean Map2Color4; GLboolean Map2Index; GLboolean Map2Normal; @@ -386,6 +387,7 @@ struct gl_enable_attrib { GLboolean Map2TextureCoord4; GLboolean Map2Vertex3; GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ GLboolean MinMax; GLboolean Normalize; GLboolean PixelTexture; @@ -424,6 +426,7 @@ struct gl_eval_attrib { GLboolean Map1TextureCoord4; GLboolean Map1Vertex3; GLboolean Map1Vertex4; + GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */ GLboolean Map2Color4; GLboolean Map2Index; GLboolean Map2Normal; @@ -433,6 +436,7 @@ struct gl_eval_attrib { GLboolean Map2TextureCoord4; GLboolean Map2Vertex3; GLboolean Map2Vertex4; + GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */ GLboolean AutoNormal; /* Map Grid endpoints and divisions and calculated du values */ GLint MapGrid1un; @@ -1113,6 +1117,7 @@ struct gl_evaluators { struct gl_1d_map Map1Texture2; struct gl_1d_map Map1Texture3; struct gl_1d_map Map1Texture4; + struct gl_1d_map Map1Attrib[16]; /* GL_NV_vertex_program */ /* 2-D maps */ struct gl_2d_map Map2Vertex3; @@ -1124,6 +1129,7 @@ struct gl_evaluators { struct gl_2d_map Map2Texture2; struct gl_2d_map Map2Texture3; struct gl_2d_map Map2Texture4; + struct gl_2d_map Map2Attrib[16]; /* GL_NV_vertex_program */ }; -- cgit v1.2.3