Sign in to follow this  
ade-the-heat

texture rectangle questions

Recommended Posts

ade-the-heat    163
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
rotalever    122
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
Brother Bob    10344
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this