/* * This does the work of glMap1[fd]. */ static void map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, const GLvoid *points, GLenum type ) { GET_CURRENT_CONTEXT(ctx); GLint k; GLfloat *pnts; struct gl_1d_map *map = NULL; ASSERT_OUTSIDE_BEGIN_END(ctx); ASSERT(type == GL_FLOAT || type == GL_DOUBLE); if (u1 == u2) { _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" ); return; } if (uorder < 1 || uorder > MAX_EVAL_ORDER) { _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" ); return; } if (!points) { _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" ); return; } k = _mesa_evaluator_components( target ); if (k == 0) { _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); } if (ustride < k) { _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" ); return; } map = get_1d_map(ctx, target); if (!map) { _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" ); return; } /* make copy of the control points */ if (type == GL_FLOAT) pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points); else pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points); FLUSH_VERTICES(ctx, _NEW_EVAL); map->Order = uorder; map->u1 = u1; map->u2 = u2; map->du = 1.0F / (u2 - u1); if (map->Points) FREE( map->Points ); map->Points = pnts; }
static void GLAPIENTRY _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v ) { GET_CURRENT_CONTEXT(ctx); struct gl_1d_map *map1d; struct gl_2d_map *map2d; GLuint i, n; GLfloat *data; GLuint comps; GLsizei numBytes; ASSERT_OUTSIDE_BEGIN_END(ctx); comps = _mesa_evaluator_components(target); if (!comps) { _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" ); return; } map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); ASSERT(map1d || map2d); switch (query) { case GL_COEFF: if (map1d) { data = map1d->Points; n = map1d->Order * comps; } else { data = map2d->Points; n = map2d->Uorder * map2d->Vorder * comps; } if (data) { numBytes = n * sizeof *v; if (bufSize < numBytes) goto overflow; for (i=0;i<n;i++) { v[i] = IROUND(data[i]); } } break; case GL_ORDER: if (map1d) { numBytes = 1 * sizeof *v; if (bufSize < numBytes) goto overflow; v[0] = map1d->Order; } else { numBytes = 2 * sizeof *v; if (bufSize < numBytes) goto overflow; v[0] = map2d->Uorder; v[1] = map2d->Vorder; } break; case GL_DOMAIN: if (map1d) { numBytes = 2 * sizeof *v; if (bufSize < numBytes) goto overflow; v[0] = IROUND(map1d->u1); v[1] = IROUND(map1d->u2); } else { numBytes = 4 * sizeof *v; if (bufSize < numBytes) goto overflow; v[0] = IROUND(map2d->u1); v[1] = IROUND(map2d->u2); v[2] = IROUND(map2d->v1); v[3] = IROUND(map2d->v2); } break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); } return; overflow: _mesa_error( ctx, GL_INVALID_OPERATION, "glGetnMapivARB(out of bounds: bufSize is %d," " but %d bytes are required)", bufSize, numBytes ); }
static void GLAPIENTRY _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, "glGetMapiv(target)" ); return; } map1d = get_1d_map(ctx, target); map2d = get_2d_map(ctx, target); ASSERT(map1d || map2d); switch (query) { case GL_COEFF: if (map1d) { data = map1d->Points; n = map1d->Order * comps; } else { data = map2d->Points; n = map2d->Uorder * map2d->Vorder * comps; } if (data) { for (i=0;i<n;i++) { v[i] = IROUND(data[i]); } } break; case GL_ORDER: if (map1d) { v[0] = map1d->Order; } else { v[0] = map2d->Uorder; v[1] = map2d->Vorder; } break; case GL_DOMAIN: if (map1d) { v[0] = IROUND(map1d->u1); v[1] = IROUND(map1d->u2); } else { v[0] = IROUND(map2d->u1); v[1] = IROUND(map2d->u2); v[2] = IROUND(map2d->v1); v[3] = IROUND(map2d->v2); } break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" ); } return; }