Jump to content
  • Advertisement
Sign in to follow this  
ahmadka

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

This topic is 4075 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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


Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
To get a tiling effect, use texture coordinates greater than 1.0

ie

0,0_______________10,0

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

0,10______________10,10

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!