PDA

View Full Version : Subdividing a textured quad



overloadnn
11-14-2000, 04:07 PM
I have a textured quad that I want to divide in smaller quads for better lighting.

How do I draw it ? I tried with a quad strip, but what about texture coords?

This is what I do for my simple quad:

Texture.Enable;
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0,0);
glTexCoord2f(1, 0); glVertex2f(100,0);
glTexCoord2f(1, 1); glVertex2f(100,100);
glTexCoord2f(0, 1); glVertex2f(0,100);
glEnd;

jc
11-14-2000, 11:30 PM
U have to calculate the texture coordinates too.

enable the texture.

glBegin(GL_QUADS);
for (i=0 ; i<NbQuads ; i++)
{
glTexCoord2f(texCoord[i].XMin, texCoord[i].YMin);
glVertex3f(lMax[0], lMin[1], lMin[2]);
glTexCoord2f(texCoord[i].XMin, texCoord[i].YMax);
glVertex3f(lMax[0], lMax[1], lMin[2]);
glTexCoord2f(texCoord[i].XMax, texCoord[i].YMax);
glVertex3f(lMin[0], lMax[1], lMin[2]);
glTexCoord2f(texCoord[i].XMax, texCoord[i].YMin);
glVertex3f(lMin[0], lMin[1], lMin[2]);
}
glEnd();

Where texcoord[i] is a structure that contain the tex coord of each quads ...

Was it clear ?

overloadnn
11-15-2000, 02:25 PM
Not very clear. I dont know how to calculate the coordinates. Just a texture over a quad, nothing else.

Dont I have to use QUADSTRIP instead of QUADS?