glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex2f(x1, y1);
glTexCoord2f(1.0f, 0.0f); glVertex2f(x2, y1);
glTexCoord2f(1.0f, 1.0f); glVertex2f(x2, y2);
glTexCoord2f(0.0f, 1.0f); glVertex2f(x1, y2);
glEnd();
glPopMatrix();
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glTexGeni and coords
hi. i'm having trouble with glTexGeni. i use this code:
and i get the following: Picture
what's wrong why does it display that way? if i skip glTexGeni() and glEnable() stuff it's ok, but the quality isn't very good. thanks.
Try removing the texture coordinates, as they're allready initialized by the texgen mode and may be overwritten by you own.
If the texgen mode is GL_OBJECT_LINEAR, the texture coordinates are calculated as a function of the values you pass to glVertex. The values are modified by the texgen planes, which when left as default values acts like the identity matrix. So if this is all code you have posted, then the code is equivalent to
Unless (x1, y1)=(0, 0) and (x2, y2)=(1, 1), possibly including an integer offset, don't expect the corner of the texture to be mapped to the corner of the quad.
glTexCoord2f(x1, y1); glVertex2f(x1, y1);glTexCoord2f(x2, y1); glVertex2f(x2, y1);glTexCoord2f(x2, y2); glVertex2f(x2, y2);glTexCoord2f(x1, y2); glVertex2f(x1, y2);
Unless (x1, y1)=(0, 0) and (x2, y2)=(1, 1), possibly including an integer offset, don't expect the corner of the texture to be mapped to the corner of the quad.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement