PDA

View Full Version : tiled texture



12-06-2001, 01:44 AM
Hello,
I have a problem when applying a texture to a quad. I want the texture to appear tiled 5x5 times in the quad. I use the following code :

glBegin (GL_QUADS);
glTexCoord2d (0.0f, 0.0f);
glVertex3f (-1.0f, -1.0f, 0.0f);

glTexCoord2d (0.0f, 5.0f);
glVertex3f ( 1.0f, -1.0f, 0.0f);

glTexCoord2d (5.0f, 5.0f);
glVertex3f ( 1.0f, 1.0f, 0.0f);

glTexCoord2d (5.0f, 0.0f);
glVertex3f (-1.0f, 1.0f, 0.0f);
glEnd ();

This example works but it is very slow.
Is this the way to apply a texture tiled, or Should I try to display 25 quads (5x5) with one texture in each quad ?
Thanks in advance.
(ps. Sorry for my bad English)

Bob
12-06-2001, 01:58 AM
The reason why it's "slow" might be because the texture is faily large, compared to the size of each tile as rendered on screen. A texture that is too large will cause lot's of cache-misses, and might degrade performance. Try upload the texture as a mipmap (using gluBuild2dMipmaps, unless you already do so), and set minmification filter to GL_LINEAR_MIPMAP_LINEAR or one ot it's frieds.

Otherwise, this is more or less the only way to reperat textures. Of course, you can pre-tile the texture, but you loose flexibility.