glTexGeni and coords

Started by
4 comments, last by Brother Bob 18 years ago
hi. i'm having trouble with glTexGeni. i use this code:

  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);

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.
Advertisement
Try removing the texture coordinates, as they're allready initialized by the texgen mode and may be overwritten by you own.
i've tried commenting them out but it doesn't help.
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
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.
hmm, thanks for the info. any way to get around this?
Just don't use texture coordinate generation if you want specific texture coordinates.

This topic is closed to new replies.

Advertisement