The following code can produce desired output:
glBegin(GL_QUADS);
glTexCoord3f(0,0,1);glVertex4f(-0.5,-0.5,0.5,1.0);
glTexCoord3f(0,1.0,1);glVertex4f(0.5,-0.5,0.5,1.0);
glTexCoord3f(1.0,1.0,1);glVertex4f(0.5,0.5,
0.5,1.0);
glTexCoord3f(1.0,0,1);glVertex4f(-0.5,0.5,0.5,1.0);
glEnd();
But If I replace it by the following segment using automatic text-
coordinate generation, it does not work:
static GLfloat sCoeff[] = {0.0, 1.0, 0.0, 0.5};
static GLfloat tCoeff[] = {1.0, 0.0, 0.0, 0.5};
static GLfloat rCoeff[] = {0.0, 0.0, 1.0, 0.5};
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_S, GL_OBJECT_PLANE, sCoeff);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_T, GL_OBJECT_PLANE, tCoeff);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGenfv(GL_R, GL_OBJECT_PLANE, rCoeff);
glBegin(GL_QUADS);
glVertex4f(-0.5,-0.5,0.5,1.0);
glVertex4f(0.5,-0.5,0.5,1.0);
glVertex4f(0.5,0.5, 0.5,1.0);
glVertex4f(-0.5,0.5,0.5,1.0);
glEnd();
But for the four vertex of the quad, their texture coordinate is
exactly the same as the first segment! What is the problem? Thank you.


|