Texture coordinates

I seem to be rather dislexic or something these days. Either that, or books aren’t telling me the right thing.

I’m trying to go about texturing a quad, and the way TexCoord2f is layed out, everything should be as such:

(0.0, 0.0) UpperLeft corner of the bitmap
(1.0, 0.0) UpperRight corner of the bitmap
(0.0, 1.0) LowerLeft corner of the bitmap
(1.0, 1.0) LowerRight corner of the bitmap

Is this correct?

If so, then why is it that whenever I draw the quad with the texture on it, the texture seems to be rotated 90 degrees clockwise?

And no… I am not rotating the quad or the scene prior.

Also, the bitmap is generated, so its definitely top-down in memory, not read in as bottom-up. Byte 0 (or 1) is the top-left-most pixel. Byte cx*cy is the bottom-right-most pixel.

Am I going insane here?

:stuck_out_tongue:

Siwko

I believe this is the texture coordinate layout:
(0,0) lower left
(1,0) upper left
(0,1) lower right
(1,1) upper right

Glossifah

Originally posted by Glossifah:
I believe this is the texture coordinate layout:
(0,0) lower left
(1,0) upper left
(0,1) lower right
(1,1) upper right

DOH!

Thank you thank you thank you!

I feel like a big dope now. I just went back to the definitive “bible” and reread. It actually does say the in the t axis, 0.0 is the bottom and 1.0 is the top. Except they don’t say that until the SECOND page!!!

No wonder I’m so confused!

But alas… my fears come true… I swap the t-axis values and the image is now rotated counterclockwise.

Here’s the quad with the tex coordinates.

glFrontFace(GL_CW);

glBegin(GL_QUADS);
glVertex3f(-0.5f, -0.5f, -0.5f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(0.5f, -0.5f, -0.5f);
glTexCoord2f(1.0f, 1.0f);
glEnd();

// Map top side

glFrontFace(GL_CCW);

glBegin(GL_QUADS);
glVertex3f(-0.5f, -0.5f, -0.5f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-0.5f, -0.5f, 0.5f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(0.5f, -0.5f, 0.5f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(0.5f, -0.5f, -0.5f);
glTexCoord2f(1.0f, 1.0f);
glEnd();

Tell me what is wrong here!

If I rotate about the X-Axis 90 degrees the the quad is facing, it shows!

Siwko

The glTexCoord() calls must come before the glVertex() call.

Originally posted by cass:
The glTexCoord() calls must come before the glVertex() call.

You’re kidding, right?

I did that?

I am having the worst day today.

Everyone… PLEASE, take this moment to laugh at me. I deserve it.

You realize I’ve been doing OpenGL for nearly a year now, I should know better. I’ve been PROGRAMMING for over 13 years. I SHOULD know better.

It didn’t look wrong to me, so hey, why not! I guess I am dislexic!

(Sorry, I’m really laughing at myself now, having not spotted something that obvious!)

I’m glad you guys are here. I really am… now laugh with me already!!!

Thanks, case closed, its fixed.

Siwko

Hahahahahahah

Don’t you just hate when simple mistakes like that trip you up, then someone comes along and points it out to you.