📄 eval.c
字号:
if (ctx->Texture.CurrentUnit != 0) { /* See OpenGL 1.2.1 spec, section F.2.13 */ _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" ); return; } map = get_2d_map(ctx, target); if (!map) { _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" ); return; } /* make copy of the control points */ if (type == GL_FLOAT) pnts = _mesa_copy_map_points2f(target, ustride, uorder, vstride, vorder, (GLfloat*) points); else pnts = _mesa_copy_map_points2d(target, ustride, uorder, vstride, vorder, (GLdouble*) points); FLUSH_VERTICES(ctx, _NEW_EVAL); map->Uorder = uorder; map->u1 = u1; map->u2 = u2; map->du = 1.0F / (u2 - u1); map->Vorder = vorder; map->v1 = v1; map->v2 = v2; map->dv = 1.0F / (v2 - v1); if (map->Points) FREE( map->Points ); map->Points = pnts;}void GLAPIENTRY_mesa_Map2f( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points){ map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points, GL_FLOAT);}void GLAPIENTRY_mesa_Map2d( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ){ map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE);}void GLAPIENTRY_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: 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] = data[i]; } } break; case GL_ORDER: if (map1d) { v[0] = (GLdouble) map1d->Order; } else { v[0] = (GLdouble) map2d->Uorder; v[1] = (GLdouble) map2d->Vorder; } break; case GL_DOMAIN: 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)" ); }}void GLAPIENTRY_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, "glGetMapfv(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] = data[i]; } } break; case GL_ORDER: if (map1d) { v[0] = (GLfloat) map1d->Order; } else { v[0] = (GLfloat) map2d->Uorder; v[1] = (GLfloat) map2d->Vorder; } break; case GL_DOMAIN: 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)" ); }}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)" ); }}void GLAPIENTRY_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 ){ GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (un<1) { _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" ); return; } FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.MapGrid1un = un; ctx->Eval.MapGrid1u1 = u1; ctx->Eval.MapGrid1u2 = u2; ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un;}void GLAPIENTRY_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 ){ _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 );}void GLAPIENTRY_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ){ GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); if (un<1) { _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" ); return; } if (vn<1) { _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" ); return; } FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.MapGrid2un = un; ctx->Eval.MapGrid2u1 = u1; ctx->Eval.MapGrid2u2 = u2; ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un; ctx->Eval.MapGrid2vn = vn; ctx->Eval.MapGrid2v1 = v1; ctx->Eval.MapGrid2v2 = v2; ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn;}void GLAPIENTRY_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ){ _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2, vn, (GLfloat) v1, (GLfloat) v2 );}/**********************************************************************//***** Initialization *****//**********************************************************************//** * Initialize a 1-D evaluator map. */static voidinit_1d_map( struct gl_1d_map *map, int n, const float *initial ){ map->Order = 1; map->u1 = 0.0; map->u2 = 1.0; map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); if (map->Points) { GLint i; for (i=0;i<n;i++) map->Points[i] = initial[i]; }}/** * Initialize a 2-D evaluator map */static voidinit_2d_map( struct gl_2d_map *map, int n, const float *initial ){ map->Uorder = 1; map->Vorder = 1; map->u1 = 0.0; map->u2 = 1.0; map->v1 = 0.0; map->v2 = 1.0; map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat)); if (map->Points) { GLint i; for (i=0;i<n;i++) map->Points[i] = initial[i]; }}void _mesa_init_eval( GLcontext *ctx ){ int i; /* Evaluators group */ ctx->Eval.Map1Color4 = GL_FALSE; ctx->Eval.Map1Index = GL_FALSE; ctx->Eval.Map1Normal = GL_FALSE; ctx->Eval.Map1TextureCoord1 = GL_FALSE; ctx->Eval.Map1TextureCoord2 = GL_FALSE; ctx->Eval.Map1TextureCoord3 = GL_FALSE; 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; ctx->Eval.Map2TextureCoord1 = GL_FALSE; ctx->Eval.Map2TextureCoord2 = GL_FALSE; ctx->Eval.Map2TextureCoord3 = GL_FALSE; 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; ctx->Eval.MapGrid1u2 = 1.0; ctx->Eval.MapGrid2un = 1; ctx->Eval.MapGrid2vn = 1; ctx->Eval.MapGrid2u1 = 0.0; ctx->Eval.MapGrid2u2 = 1.0; ctx->Eval.MapGrid2v1 = 0.0; ctx->Eval.MapGrid2v2 = 1.0; /* Evaluator data */ { static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; 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 ); init_1d_map( &ctx->EvalMap.Map1Index, 1, index ); init_1d_map( &ctx->EvalMap.Map1Color4, 4, color ); init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal ); init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord ); 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 ); init_2d_map( &ctx->EvalMap.Map2Index, 1, index ); init_2d_map( &ctx->EvalMap.Map2Color4, 4, color ); init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal ); init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord ); 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 ); }}void _mesa_free_eval_data( GLcontext *ctx ){ int i; /* Free evaluator data */ if (ctx->EvalMap.Map1Vertex3.Points) FREE( ctx->EvalMap.Map1Vertex3.Points ); if (ctx->EvalMap.Map1Vertex4.Points) FREE( ctx->EvalMap.Map1Vertex4.Points ); if (ctx->EvalMap.Map1Index.Points) FREE( ctx->EvalMap.Map1Index.Points ); if (ctx->EvalMap.Map1Color4.Points) FREE( ctx->EvalMap.Map1Color4.Points ); if (ctx->EvalMap.Map1Normal.Points) FREE( ctx->EvalMap.Map1Normal.Points ); if (ctx->EvalMap.Map1Texture1.Points) FREE( ctx->EvalMap.Map1Texture1.Points ); if (ctx->EvalMap.Map1Texture2.Points) FREE( ctx->EvalMap.Map1Texture2.Points ); if (ctx->EvalMap.Map1Texture3.Points) FREE( ctx->EvalMap.Map1Texture3.Points ); if (ctx->EvalMap.Map1Texture4.Points) FREE( ctx->EvalMap.Map1Texture4.Points ); for (i = 0; i < 16; i++) FREE((ctx->EvalMap.Map1Attrib[i].Points)); if (ctx->EvalMap.Map2Vertex3.Points) FREE( ctx->EvalMap.Map2Vertex3.Points ); if (ctx->EvalMap.Map2Vertex4.Points) FREE( ctx->EvalMap.Map2Vertex4.Points ); if (ctx->EvalMap.Map2Index.Points) FREE( ctx->EvalMap.Map2Index.Points ); if (ctx->EvalMap.Map2Color4.Points) FREE( ctx->EvalMap.Map2Color4.Points ); if (ctx->EvalMap.Map2Normal.Points) FREE( ctx->EvalMap.Map2Normal.Points ); if (ctx->EvalMap.Map2Texture1.Points) FREE( ctx->EvalMap.Map2Texture1.Points ); if (ctx->EvalMap.Map2Texture2.Points) FREE( ctx->EvalMap.Map2Texture2.Points ); if (ctx->EvalMap.Map2Texture3.Points) FREE( ctx->EvalMap.Map2Texture3.Points ); if (ctx->EvalMap.Map2Texture4.Points) FREE( ctx->EvalMap.Map2Texture4.Points ); for (i = 0; i < 16; i++) FREE((ctx->EvalMap.Map2Attrib[i].Points));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -