PDA

View Full Version : How to calculate texture coords?



FoxDie
01-07-2001, 12:42 AM
I'm try to put texture on single
triangle.For example:
glBegin(GL_TRIANGLES);
glTextCoord3f(-0.5,-0.3,1.0); glVertex3f(-0.5,-0.3,1.0);glTexCoord3f((-0.1,-0.3,1.0));glVertex3f(-0.1,-0.3,1.0);
glTexCoord3f3f(-0.3,-0.1,1.0);glVertex3f(-0.3,-0.1,1.0);

The texture was load from BMP file.
When I try to draw this bmp ,it was
properly function.Then I try it put
this texture on the triangle.
All need properties was seted.
Help me.

01-07-2001, 01:31 AM
use glTextCoord2f(x,y) (what you want to map is a surface, not a volume).

spaghetti

FoxDie
01-07-2001, 05:27 AM
You don't understand me.
I don't know to calculate the coords.
The glTexCoord2f has two parameters
s and t.I couldn't calculate s and t.
If x=-0.5f,y=-0.3f,z=1.0 how
value has s and t?

Humus
01-07-2001, 06:01 AM
The texture coordinates are coord on the texture. (0,0) is the upper left, (1,1) is the lower right.

Try this:

glBegin(GL_TRIANGLES);
glTexCoord2f(0,0); glVertex3f(-0.5,-0.3,1.0);
glTexCoord2f(1,0); glVertex3f(-0.1,-0.3,1.0);
glTexCoord2f(0,1); glVertex3f(-0.3,-0.1,1.0);
glEnd();