Texture mapping into a square.

Hello,
I have a 3D mesh of a face where I want to map it with a texture.
I need to compute UV texture coordinates from the vertex coordinates.
How can I compute these coordinates? and How can I do it with openGL?

The texture coordinates come from the same source as the vertex coordinates. Your model file or wherever else your vertex data comes from.

The texture coordinate is a vertex attribute. The veretx shader passes it to the fragment shader wich performs the texture lookup.

[QUOTE=Agent D;1259224]The texture coordinates come from the same source as the vertex coordinates. Your model file or wherever else your vertex data comes from.

The texture coordinate is a vertex attribute. The veretx shader passes it to the fragment shader wich performs the texture lookup.[/QUOTE]

I am using OFF (Open File Format) files, where there is only vertex coordinates and face indices.
So I have to compute the texture coordinates by my self.

Do you mean this? It doesn’t even store surface normals or indices. That’s a pretty useless model file format.

If you don’t know preciesly what you are rendering and how it should be texture, I suggest using a better file format.