Jump to content
  • Advertisement
Sign in to follow this  
invinate

glTexGeni and coords

This topic is 4595 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
Try removing the texture coordinates, as they're allready initialized by the texgen mode and may be overwritten by you own.

Share this post


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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!