Advertisement

Place a texture on 2 GLTRIANGLE ?

Started by January 20, 2002 03:52 AM
6 comments, last by niedernsill 23 years, 1 month ago
Hello, Can I place a texture on 2 GL_TRIANGLEs ?: ---------- |\ | | \ | | \ 2 | | \ | | \ | | 1 \ | | \ | ---------- It''s possible with OpenGL ?
You can place a texture onto as many triangles as you wish
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Advertisement
Humm .. Yes but I want to place one texture on 2 TRIANGLES. How can I use the function glTexCoord2f ?
RTFM

Read up on texture coordinates ... it''s about as obvious as it comes with opengl - try the ''Articles and Resources'' link at the top of this site ... and go to the Red or Blue books!
Yes, I''ll read it but why don''t this code run !? :
glBegin GL_TRIANGLES
glTexCoord2f 0#, 0#: glVertex3f -1#, -1#, -1#
glTexCoord2f 1#, 0#: glVertex3f -1#, 1#, -1#
glTexCoord2f 1#, 1#: glVertex3f 1#, 1#, -1#

glVertex3f -1#, -1#, -1#
glTexCoord2f 0#, 1#: glVertex3f 1#, -1#, -1#
glVertex3f 1#, 1#, -1#
glEnd
In fact, how map textures to surfaces made of a set of polygons ...?
Advertisement
First of all, OpenGL uses Counterclockwise face windings by default ... whereas the first triangle you are drawing is clockwise. Try this -

glTexCoord2f : glVertex3f

0, 0 : -1, -1, -1
1, 0 : 1, -1, -1
1, 1 : 1, 1, -1

0, 0 : -1, -1, -1
1, 1 : 1, 1, -1
0, 1 : -1, 1, -1

Make sure that texturing is enabled!
You can also try

glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

This technique is covered in Tutorial #15.

This topic is closed to new replies.

Advertisement