Jump to content
  • Advertisement
Sign in to follow this  

glTexGeni and coords

This topic is 4416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!