Archived

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

SimonSays

Newbie: glTexCoord2f

Recommended Posts

SimonSays    122
Hi Can someone please better explain to me the parameters glTexCoord2f takes? In Tutorial 6 I encountered this for the first time, and I''m sorry to say this, but I don''t quite get the snag of the explanation Thank you

Share this post


Link to post
Share on other sites
MENTAL    383
glTexCoord2f (TextureCoordinateX, TextureCoordinateY);

e.g.

glTexCoord2f (1.0f, 1.0f);

that would be the far left and far top corner of the texture (texture co-ordinates range from 0-1, so that the user doesnt have to worry what the real dimentions of the texture are, as OpenGL sorts that out.

oh, remember that unlike monitors where 0 on the Y axis is the top of the screen, 0 is at the bottom in OpenGL.


0,1 1,1
________________________
| |
| |
| |
| |
| |
| |
|________________________|
0,0 1,0

layout of an OpenGL texture




hope it helps

MENTAL

Share this post


Link to post
Share on other sites
omega_001    122
Take the example of a square. Say we have an outline of a square we wish to fill, and a texture with which to fill it.
glTexCoord2f is used to specify how the texture is mapped onto the outline at each of the four vertices therefore:
glTexCoord2f(0.0,0.0);glVertex3f(0.0,0.0,0.0); would place the bottom left hand side of the texture in the bottom left hand side of the outline.
By mapping out the remaining four vertices the texture will overlay the outline (like placing a painting into a frame).

hope this helps

Share this post


Link to post
Share on other sites