PDA

View Full Version : Tiled textures?



weebull
03-05-2003, 03:32 AM
How do i do it?? I have been told that you can do this when you are initially binding them, but i cant figure out how?

Anitox
03-05-2003, 05:08 AM
When I tile a texture, I use the glTexCoord2i() function to change how often the texture is repeated.


unsigned int repeats = 2;

glBegin(GL_QUADS);
glTexCoord2i(0, 0);
glVertex3f(-1.0f,-1.0f, 0.0f);
glTexCoord2i(repeats, 0);
glVertex3f( 1.0f,-1.0f, 0.0f);
glTexCoord2i(repeats, repeats);
glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2i(0, repeats);
glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd();

delsydsoft
03-06-2003, 01:08 AM
What Antiox said is true for rendering. When you first create your texture object, you want to use glTexParameter to set up the way that OGL handles your texture coordinates:

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _REPEAT);

I think that OGL defaults to GL_REPEAT, but it's not a bad idea to use these lines of code anyway, just for safety's sake.