Code:
void SurfaceMesh::pack(){
GLfloat texturecoords[4][2];
/*...................*/
glNewList(getListID(),GL_COMPILE);
for(int n_pts = points.size();n_pts>2;n_pts-=2){
/*...............*/
glMap2f(GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 2, 0.0, 1.0, 6, 2, &ctrlpoints[0][0]);
glMap2f(GL_MAP2_NORMAL, 0.0, 1.0, 3, 2, 0.0, 1.0, 6, 2, &nrmlcompon[0][0]);
if(_texture){
glBindTexture(GL_TEXTURE_2D, _texture->getTextID());
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 4, 2, 0.0 , 1.0, 2, 2, &texturecoords[0][0]);
}else
glMap2f(GL_MAP2_COLOR_4, 0.0, 1.0, 4, 2, 0.0, 1.0, 8, 2, &colrpoints[0][0]);
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_MAP2_NORMAL);
glEnable(GL_MAP2_COLOR_4);
glEnable(GL_MAP2_TEXTURE_COORD_2);
int evx, evz;
/*................*/
glMapGrid2f(evx, 0.0,1.0, evz, 0.0,1.0);
glEvalMesh2(GL_FILL, 0,evx, 0,evz);
}
glEndList();
packed = true;
}
I have a class SurfaceMesh for managing a surface, you can see an excert of the pack function which calculates normals, extra geometry, evaluators and places it in a glList.