Repetitive textures (e.g. textures for floor tiles)

Started by
4 comments, last by WilyCoder 16 years, 11 months ago
I know how to apply textures onto basic shapes..I want to know how to apply textures onto a surface in a 'tiling' manner...i.e. suppose I have a texture of about 1meter * 1metre, and I want to replicate it across and entire floor...how would I do that ?? Thanx in advance :D
Advertisement
Its just a matter of setting the wrapping mode of your texture. Set it to repeat throught the geometry.

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

For a 2D texture, this will tile the texture in both X & Y dirextions.

Hope this helps you,
Best Regards,
KumGame07


Best Regards,KumGame07
thanx for the code dude, cant wait to try it out...

the only problem is, is that in my model, the floor is made up of the x and z coordinates....y is going upwards...so I want to texture to 'tile-up' along the x and z axis...what would the code be for that ?
Quote:Original post by ahmadka
thanx for the code dude, cant wait to try it out...

the only problem is, is that in my model, the floor is made up of the x and z coordinates....y is going upwards...so I want to texture to 'tile-up' along the x and z axis...what would the code be for that ?


I am assuming you have xz as flat but Y is up like a math grid. You still repeat the texture coordinates in xy.
OK thanx but I just tried the code...it doesnt seem to work for me...Where exactly do I place this code, and how do I use it ? Also, do you know any tutorial on some website showing how to use texture tiling ?

I have tried placing the code at the following places, but I still see no changes:

-right before defining the textured object
-inside the textured object
-before the following texture definition code:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

..help..
To get a tiling effect, use texture coordinates greater than 1.0

ie

0,0_______________10,0

|-----------------|
|-----------------|
|-----------------|
|-----------------|
|-----------------|

0,10______________10,10

This topic is closed to new replies.

Advertisement