• Advertisement
Sign in to follow this  

texture rectangle questions

This topic is 3951 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

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 this post


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


Link to post
Share on other sites
Quote:
Original post by rotalever
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);


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

Share this post


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

  • Advertisement