Jones
2006.07.10, 05:51 PM
I'm in a situation where I want to stretch one texture over an entire cube (if possible). So say to myself "Well, I'll test if it's possible with some simple quads."
Here's the code I tried out:
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2i(0, 0);
glVertex2i(16, 0);
glVertex2i(16, 16);
glVertex2i(0, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(1, 0);
glVertex2i(16, 0);
glVertex2i(32, 0);
glVertex2i(32, 16);
glVertex2i(16, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(1, 1);
glVertex2i(0, 16);
glVertex2i(16, 16);
glVertex2i(32, 32);
glVertex2i(0, 32);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0, 1);
glVertex2i(16, 16);
glVertex2i(32, 16);
glVertex2i(32, 32);
glVertex2i(16, 32);
glEnd();
What it was *supposed* to do was draw four quads like this:
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
With one texture stretched over ALL of them. Funnily enough, I didn't even see the quads at all...
So, I tried this:
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2i(0, 0);
glTexCoord2i(0.5, 0);
glVertex2i(16, 0);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glTexCoord2i(0, 0.5);
glVertex2i(0, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0.5, 0);
glVertex2i(16, 0);
glTexCoord2i(1, 0);
glVertex2i(32, 0);
glTexCoord2i(1, 0.5);
glVertex2i(32, 16);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0, 0.5);
glVertex2i(0, 16);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glTexCoord2i(0.5, 1);
glVertex2i(32, 32);
glTexCoord2i(0, 1);
glVertex2i(0, 32);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glTexCoord2i(1, 0.5);
glVertex2i(32, 16);
glTexCoord2i(1, 1);
glVertex2i(32, 32);
glTexCoord2i(0.5, 1);
glVertex2i(16, 32);
glEnd();
And it worked, only my texture was ity-ity-bity. Tiny. I thought it was because I had supplied floats to an int function, so I turned all my TexCoord2i's to TexCoord2f's. And it got a bit bigger, but still not the right size... what could be going wrong?
Thanks for any help!
(Note: Everything is setup right, with texturing enable and stuff. The function I use to load the texture is one of my own, and I'm pretty sure it works fine. I can supply it if it'll help solve this.
Thanks!
Here's the code I tried out:
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2i(0, 0);
glVertex2i(16, 0);
glVertex2i(16, 16);
glVertex2i(0, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(1, 0);
glVertex2i(16, 0);
glVertex2i(32, 0);
glVertex2i(32, 16);
glVertex2i(16, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(1, 1);
glVertex2i(0, 16);
glVertex2i(16, 16);
glVertex2i(32, 32);
glVertex2i(0, 32);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0, 1);
glVertex2i(16, 16);
glVertex2i(32, 16);
glVertex2i(32, 32);
glVertex2i(16, 32);
glEnd();
What it was *supposed* to do was draw four quads like this:
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
With one texture stretched over ALL of them. Funnily enough, I didn't even see the quads at all...
So, I tried this:
glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex2i(0, 0);
glTexCoord2i(0.5, 0);
glVertex2i(16, 0);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glTexCoord2i(0, 0.5);
glVertex2i(0, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0.5, 0);
glVertex2i(16, 0);
glTexCoord2i(1, 0);
glVertex2i(32, 0);
glTexCoord2i(1, 0.5);
glVertex2i(32, 16);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0, 0.5);
glVertex2i(0, 16);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glTexCoord2i(0.5, 1);
glVertex2i(32, 32);
glTexCoord2i(0, 1);
glVertex2i(0, 32);
glEnd();
glBegin(GL_QUADS);
glTexCoord2i(0.5, 0.5);
glVertex2i(16, 16);
glTexCoord2i(1, 0.5);
glVertex2i(32, 16);
glTexCoord2i(1, 1);
glVertex2i(32, 32);
glTexCoord2i(0.5, 1);
glVertex2i(16, 32);
glEnd();
And it worked, only my texture was ity-ity-bity. Tiny. I thought it was because I had supplied floats to an int function, so I turned all my TexCoord2i's to TexCoord2f's. And it got a bit bigger, but still not the right size... what could be going wrong?
Thanks for any help!
(Note: Everything is setup right, with texturing enable and stuff. The function I use to load the texture is one of my own, and I'm pretty sure it works fine. I can supply it if it'll help solve this.
Thanks!