I’m trying to produce a bezier patch with different textures front/back. It all works but I’d be really grateful if someone could tell me how to get the normals set correctly … they’re not working at all … if I add a glScalef(1,-1,1) then the top face seems to work … it’s as if the normals that are calculated are 180 degrees wrong !
Much appreciated … well an answer / solution will be …
Andrew
const
ControlPoints : Array[0…3, 0…3, 0…2] of GLfloat = (
((-5/2, -1.0, 4), (-5/2, -1.0, 2), (-5/2, -1, -2), (-5/2, -1, -4)),
((-5/4, -1.0, 4), (-5/4, -1.0, 2), (-5/4, -1, -2), (-5/4, -1, -4)),
(( 5/4, -1.0, 4), ( 5/4, -1.0, 2), ( 5/4, -1, -2), ( 5/4, -1, -4)),
(( 5/2, -2.0, 4), ( 5/2, -1.0, 2), ( 5/2, -1, -2), ( 5/2, -1, -4)));
textres: array [0…1, 0…1, 0…1] of GLfloat =
(((0.0, 1.0), (0.0, 0.0)), ((1.0, 1.0), (1.0, 0.0)));
…
…
glMap2f(GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, 0, 1, 4, 2, @textres);
glMap2f(GL_MAP2_VERTEX_3,
0, 1, // The range of the surface's U parameter (usually 0..1).
3, // The number of values between vertices in the U direction.
4, // The order of the curves in the U direction.
0, 1, // The range of the V parameter.
12, // The number of values between consecutive V vertices.
4, // The order of the V curves.
@ControlPoints); // Pointer to the control points.
glEnable(GL_MAP2_VERTEX_3);
glEnable(GL_MAP2_TEXTURE_COORD_2);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glColor3ub(200, 200, 200);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, @cMaterialSpecularFrontCover);
glBindTexture(GL_TEXTURE_2D, GLTextures[cNotebookCover]);
glMapGrid2f(12, 0.0, 1.0, 12, 0.0, 1.0);
glEvalMesh2(GL_FILL, 0, 12, 0, 12);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, @cMaterialSpecularDefault);
glFrontFace(GL_CW); // Draw the back ... reverse the winding.
glBindTexture(GL_TEXTURE_2D, GLTextures[cNotebookBack]);
glEvalMesh2(GL_FILL, 0, 12, 0, 12);
glFrontFace(GL_CCW);
glDisable(GL_MAP2_VERTEX_3);
glDisable(GL_MAP2_TEXTURE_COORD_2);
glDisable(GL_AUTO_NORMAL);