
Texturing a quad strip
Quick question, how do you properly texture a GL_QUAD_STRIP
glBegin(GL_QUAD_STRIP) ;
glTexCoord2f(0.0f, 1.0f) ; glVertex3f(xPos, yPos, zPos) ;
glTexCoord2f(1.0f, 1.0f) ; glVertex3f((xPos + playerW), yPos, zPos) ;
glTexCoord2f(1.0f, 0.0f) ; glTexCoord2f(1.0f, 1.0f) ;
glVertex3f((xPos + playerW), (yPos - playerH), zPos) ;
glTexCoord2f(0.0f, 0.0f) ; glTexCoord2f(0.0f, 1.0f) ;
glVertex3f(xPos, (yPos - playerH), zPos) ;
glTexCoord2f(0.0f, 0.0f) ; glTexCoord2f(0.0f, 1.0f) ;
glVertex3f(xPos, (yPos - playerH), (zPos - playerD)) ;
glTexCoord2f(1.0f, 0.0f) ; glTexCoord2f(1.0f, 1.0f) ; glVertex3f((xPos + playerW), (yPos - playerH), (zPos - playerD)) ;
glTexCoord2f(0.0f, 0.0f) ; glTexCoord2f(0.0f, 1.0f) ; glVertex3f (xPos, yPos, (zPos - playerD)) ;
glTexCoord2f(1.0f, 0.0f) ; glTexCoord2f(1.0f, 1.0f) ; glVertex3f((xPos + playerW), yPos, (zPos - playerD)) ;
glTexCoord2f(0.0f, 0.0f) ; glTexCoord2f(0.0f, 1.0f) ; glVertex3f(xPos, yPos, zPos) ;
glTexCoord2f(1.0f, 0.0f) ; glTexCoord2f(1.0f, 1.0f) ; glVertex3f((xPos + playerW), yPos, zPos) ;
glEnd() ;
As above, i tried to specify to texcoords for each vertex, but that didn''t really tetxure it properly (the texture kind of flickers and move''s when the polygons change position). It''s probably a simple fix (i hope
, but i don''t know it.
Any help would be great. Thanks.
MelvinElvin

GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Um... why are you calling the glTexCoord2f() function twice before drawing each vertex?
You''re supposed to go something like:
glTexCoord2f(0,0); glVertex3f(0,0,0);
glTexCoord2f(1,0); glVertex3f(1,0,0);
glTexCoord2f(1,1); glVertex3f(1,1,0);
glTexCoord2f(0,1); glVertex3f(0,1,0);
You''re supposed to go something like:
glTexCoord2f(0,0); glVertex3f(0,0,0);
glTexCoord2f(1,0); glVertex3f(1,0,0);
glTexCoord2f(1,1); glVertex3f(1,1,0);
glTexCoord2f(0,1); glVertex3f(0,1,0);
thanks wavarian, but it''s in a strip, so in the code the 2 specified vertices match up with the last two to draw the quad. Therefore, when i specify each vertex it will have to tex coords, one for the first quad it connects with and one for the other..... that''s why i''ve got 2 texcoords per vertex.
unless i''m missing something.
thanks anyway, MelvinElvin
unless i''m missing something.
thanks anyway, MelvinElvin
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
First things first,
You only need to specify 1 texture coordinate per vertex. A single vertex cannot have two different texture coordinates associated with it.
With that said what you need to do is use texture coordinates greater than 0 and 1, such as 2,3,4,5...etc.
Imagine 4 square quads in a strip like this:
####
now for the first quad the texture coordinates will be:
bottom left (0,0)
top left (0,1)
top right (1,1)
bottom right (1,0)
for the second quad the texture coordinates will be:
bottom left (1,0)
top left (1,1)
top right (2,1)
bottom right (2,0)
for the third quad the texture coordinates will be:
bottom left (2,0)
top left (2,1)
top right (3,1)
bottom right (3,0)
and etc...
Draw this out on a piece of paper and itll make sense. (I hope) =)
HTH,
Gerald Filimonov
-=[ Megahertz ]=-
You only need to specify 1 texture coordinate per vertex. A single vertex cannot have two different texture coordinates associated with it.
With that said what you need to do is use texture coordinates greater than 0 and 1, such as 2,3,4,5...etc.
Imagine 4 square quads in a strip like this:
####
now for the first quad the texture coordinates will be:
bottom left (0,0)
top left (0,1)
top right (1,1)
bottom right (1,0)
for the second quad the texture coordinates will be:
bottom left (1,0)
top left (1,1)
top right (2,1)
bottom right (2,0)
for the third quad the texture coordinates will be:
bottom left (2,0)
top left (2,1)
top right (3,1)
bottom right (3,0)
and etc...
Draw this out on a piece of paper and itll make sense. (I hope) =)
HTH,
Gerald Filimonov
-=[ Megahertz ]=-
-=[Megahertz]=-
quote:
Original post by Megahertz
You only need to specify 1 texture coordinate per vertex. A single vertex cannot have two different texture coordinates associated with it.
You''re correct for this situation, but with multitexturing you can have more than one texture coordinate per vertex

[Resist Windows XP''s Invasive Production Activation Technology!]
Bah, picky picky! =)
Yes in the case of multitexturing you could have more than one texture coordinate per vertex.
Yes in the case of multitexturing you could have more than one texture coordinate per vertex.
-=[Megahertz]=-
quote:
Original post by Megahertz
Bah, picky picky! =)
Yeah, I agree

[Resist Windows XP''s Invasive Production Activation Technology!]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement