PDA

View Full Version : Subdividing a textured quad

11-14-2000, 03: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;
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, 10:30 PM
U have to calculate the texture coordinates too.

enable the texture.

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 ?