glMapGrid and glEvalMesh are used in tandem to efficiently generate and evaluate a series of evenly-spaced map domain values. glEvalMesh steps through the integer domain of a one- or two-dimensional grid, whose range is the domain of the evaluation maps specified by glMap1 and glMap2. mode determines whether the resulting vertices are connected as points, lines, or filled polygons.
In the one-dimensional case, glEvalMesh1, the mesh is generated as if the following code fragment were executed:
glBegin( type ); for ( i = i1; i <= i2; i += 1 ) glEvalCoord1( i*delta_u + u1 ); glEnd();
where
(u2−u1) |
n |
and n, u1, and u2 are the arguments to the most recent glMapGrid1 command. type is GL_POINTS if mode is GL_POINT, or GL_LINES if mode is GL_LINE.
The one absolute numeric requirement is that if i=n, then the value computed from i·Δu+u1 is exactly u2.
In the two-dimensional case, glEvalMesh2, let
Δu=(u2−u1)/n Δv=(v2−v1)/m,
where n, u1, u2, m, v1, and v2 are the arguments to the most recent glMapGrid2 command. Then, if mode is GL_FILL, the glEvalMesh2 command is equivalent to:
for ( j = j1; j < j2; j += 1 ) { glBegin( GL_QUAD_STRIP ); for ( i = i1; i <= i2; i += 1 ) { glEvalCoord2( i·Δu+u1, j·Δv+v1 ); glEvalCoord2( i·Δu+u1, (j+1)·Δv+v1 ); } glEnd(); }
If mode is GL_LINE, then a call to glEvalMesh2 is equivalent to:
for ( j = j1; j <= j2; j += 1 ) { glBegin( GL_LINE_STRIP ); for ( i = i1; i <= i2; i += 1 ) glEvalCoord2( i·Δu+u1, j·Δv+v1 ); glEnd(); } for ( i = i1; i <= i2; i += 1 ) { glBegin( GL_LINE_STRIP ); for ( j = j1; j <= j1; j += 1 ) glEvalCoord2( i·Δu+u1, j·Δv+v1 ); glEnd(); }
And finally, if mode is GL_POINT, then a call to glEvalMesh2 is equivalent to:
glBegin( GL_POINTS ); for ( j = j1; j <= j2; j += 1 ) for ( i = i1; i <= i2; i += 1 ) glEvalCoord2( i·Δu+u1, j·Δv+v1 ); glEnd();
In all three cases, the only absolute numeric requirements are that if i=n, then the value computed from i·Δu+u1 is exactly u2, and if j=m, then the value computed from j·Δv+v1 is exactly v2.
GL_INVALID_ENUM is generated if mode is not an accepted value.
GL_INVALID_OPERATION is generated if glEvalMesh is executed between the execution of glBegin and the corresponding execution of glEnd.