PDA

View Full Version : Texture stretching question



Ace_Man
10-31-2000, 09:42 AM
When I texture map the floor in my 3d world. It stretches the texture to fid the quad.
I use only one quad. it doesn't look very good (my floor is rather large). Is there a way to get the texture to repeat across the quad?

DFrey
10-31-2000, 10:35 AM
Enable texture wrapping when loading the texture. And then when applying the texture, just use s&t values larger than 1. For example if I had a quad that used the following texture coordinates:



(0,0)...(3,0)
. .
. .
. .
(0,3)...(3,3)

Then the texture would be repeated 3 times both vertically and horizontally.

[This message has been edited by DFrey (edited 10-31-2000).]

10-31-2000, 10:38 AM
use the texture coordinates before each vertex.
glTexCoord2f(u, v);

(0, 0) is bottom left and (1, 1) is top right. If you want the texture to repeat then set coordinates to something like this.
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(x, y, z);
glTexCoord2f(0, 5); glVertex3f(x2, y2, z2);
glTexCoord2f(5, 5); glVertex3f(x3, y3, z3);
...... and so on

This would repeat the texture 25 times on the quad ie 5*5

DFrey
10-31-2000, 11:08 AM
He already knows how to use texture coordinates. He just didn't know how to get it to wrap. You must load the texture with GL_TEXTURE_WRAP_S & GL_TEXTURE_WRAP_T set to GL_REPEAT. Otherwise you'll just get a border if you attempt to use coordinates greater than 1.

Ace_Man
10-31-2000, 01:19 PM
Thank you! It worked