Archived

This topic is now archived and is closed to further replies.

Fill wall with a texture

This topic is 5305 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

Hello I am heaving a little problem on glTexCoord2f: I made a wall with vertex. I have all the sizes of this wall, like Width, height, etc. i want to fill my wall with a texture that i''ve alread loaded. How do i have to calculate the glTexCoord2f to fill my wall with the texture ? (not to strech) Thank you

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
do you have the texture mapped to the wall already and it is stretched?

if so you probly have code like this

glTexCoord2f(1.0f, 0.0f);

try this out:
for every 1.0f change to 2.0f or 3.0f

Share this post


Link to post
Share on other sites
How about the x coord beeing width?
That should be OK if your wall looks ok at 1 by 1 size,
but otherwise just make the coord: width * (value that you decided upon in previous post).

Share this post


Link to post
Share on other sites
Alread did it. Width_of_the_image * width_of_the_wall.

But something wrong happens. Cause the size of the image can be 128 pixels. But if i put a size of 128 in the wall, the wall will be very very bigger than the image. Theyer sizes are in different method. Did u understand ?

Share this post


Link to post
Share on other sites
That don''t sound right...

First: are you sure you are using the width of the wall (not, for instance, the highest x coord)?

I think my last explanation was a bit s***y..

If your wall textured wall looks ok when the wall is rendered by:

glTexCoord2f(0,0); glVertex3f(0,0);
glTexCoord2f(0,1); glVertex3f(0,1);
glTexCoord2f(1,1); glVertex3f(1,1);
glTexCoord2f(1,0); glVertex3f(1,0); //(not checked )

then all you need to do is to render your wall using:

glTexCoord2f(0,0); glVertex3f(*,*);
glTexCoord2f(0,hite); glVertex3f(*,*);
glTexCoord2f(width,hite); glVertex3f(*,*);
glTexCoord2f(width,0); glVertex3f(*,*); //(not checked )

This will make the texture the same streched-ness on both walls.

If not then...

(maybe later)

http://www.fana.co.uk/

Share this post


Link to post
Share on other sites
So, when the wall is rendering from 1,1 to 3,3, what would your system say the width is?

I would say that width = 2 and hite is 2.

This _will_ work with previos system...

Share this post


Link to post
Share on other sites