# texture rectangle questions

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

## Recommended Posts

Using a texture recture rectangle I'd render a quad like this:
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(texSize, 0.0);
glVertex2f(texSize, 0.0);
glTexCoord2f(texSize, texSize);
glVertex2f(texSize, texSize);
glTexCoord2f(0.0, texSize);
glVertex2f(0.0, texSize);
glEnd()

Now say the textsize =100, how doI render so that I miss out the first 4 rows of the texture ? Is the below close?
glBegin(GL_QUADS);
glTexCoord2f(4, 0.0);
glVertex2f(0.0, 0.0);
glTexCoord2f(texSize, 0.0);
glVertex2f(texSize, 0.0);
glTexCoord2f(texSize, texSize);
glVertex2f(texSize, texSize);
glTexCoord2f(4, texSize);
glVertex2f(4, texSize);
glEnd()

cheers

##### Share on other sites
The tex-coords go from 0.0 to 1.0
your Tex has the dimesion = 100, right?

=> something like
glTexCoord2f(4, texSize);
should be replaced with:
glTexCoord2f(1.0*4/dimension, 1.0);

##### Share on other sites
Quote:
 Original post by rotaleverThe tex-coords go from 0.0 to 1.0your Tex has the dimesion = 100, right?=> something likeglTexCoord2f(4, texSize);should be replaced with:glTexCoord2f(1.0*4/dimension, 1.0);

No, texture rectangles use non-normalized texture coordinates. The code is correct as he originally posted it.

• 36
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631359
• Total Posts
2999538
×