PDA

View Full Version : Partitioning a quad into smaller quads



overloadnn
11-14-2000, 04:09 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;

Antonio
11-14-2000, 04:43 PM
I think you'll have to generate texture coordinates in proportion with the new quads. So if you divide the original quad into four quads, you'll have to map a quarter of the texture to each quad. For instance

glTexCoord2f(0, 0); glVertex2f(0,0);
glTexCoord2f(0.5, 0); glVertex2f(50,0);
glTexCoord2f(0.5, 0.5); glVertex2f(50,50);
glTexCoord2f(0, 0.5); glVertex2f(0,50);


I haven't tried the above code but I believe the underlying reasoning is correct.

Antonio www.fatech.com/tech (http://www.fatech.com/tech)