Texture mapping a triangle strip

Started by
6 comments, last by Bleakcabal 21 years, 9 months ago
When I do this

glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 0.0f);
		glVertex2f((GLfloat)0, (GLfloat)0);
		
		glTexCoord2f(1.0f, 0.0f);
		glVertex2f((GLfloat)scr_width, (GLfloat)0);

		glTexCoord2f(1.0f, 1.0f);
		glVertex2f((GLfloat)scr_width, (GLfloat)scr_height);

		glTexCoord2f(0.0f, 1.0f);
		glVertex2f((GLfloat)0, (GLfloat)scr_height);
	glEnd();
 
Everything works fine. But when I do this :

glBegin(GL_TRIANGLE_STRIP);
		glTexCoord2f(0.0f, 0.0f);
		glVertex2f((GLfloat)0, (GLfloat)0);
		
		glTexCoord2f(1.0f, 0.0f);
		glVertex2f((GLfloat)scr_width, (GLfloat)0);

		glTexCoord2f(1.0f, 1.0f);
		glVertex2f((GLfloat)scr_width, (GLfloat)scr_height);

		glTexCoord2f(0.0f, 1.0f);
		glVertex2f((GLfloat)0, (GLfloat)scr_height);
	glEnd();
 
A part of the shape isnt texture mapped, a triangle on the left side of the quad. But I have been using this same triangle strip code to do untextured rectangles and in worked fine. I have read many times on these forums that triangle_strip are faster than quads so I want to use them instead. Does anyone know what I am doing wrong. WHO DO THEY THINK THEY''RE FOOLING : YOU ?
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
Advertisement
refer to this picture right here:


and make sure that your verticies are in the same order as on the picture for GL_TRIANGLE_STRIP (right now they aren''t).

---
shurcool
my project
This fixed my problem but now the texture is flipped 90 degress counter-clockwise. But I know you are supposed to submit the texture coordinates in a clockwise fashion, but I can''t do so if I submit vertexes in the right order for the triangle_strip...

WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?



WHO DO THEYTHINK THEY'REFOOLING : YOU ?
huh? you''re supposed to do that for vertices only, it doesn''t matter in which order your texture coords go!

---
shurcool
my project
Actually it seems to matter for triangle_strips as I can make the texture "flip" a certain way depending on how I submit them.

WHO DO THEY
THINK THEY''RE
FOOLING : YOU ?



WHO DO THEYTHINK THEY'REFOOLING : YOU ?
Just enter the tex coords in the order that makes them look right on the screen. Final output is all that counts, for tex coords at least.
Of course it matters how you input things. What sort of programmer are you?
You can draw tri-strips like:

TOP LEFT - TOP RIGHT - BOTTOM LEFT - BOTTOM RIGHT
or
BOTTOM LEFT - TOP LEFT - BOTTOM RIGHT - TOP RIGHT
and several other combinations

Just visualize what you are doing, and you''ll be able to match things up correctly.

------------
aud.vze.com - The Audacious Engine <-- It''s not much, yet. But it''s mine... my own... my preciousssss...
MSN: nmaster42@hotmail.com, AIM: LockePick42, ICQ: 74128155
_______________________________________Pixelante Game Studios - Fowl Language
quote:Just visualize what you are doing, and you''ll be able to match things up correctly.


...and if you can''t do that, buy the OpenGL Red Book.
masterghttp:/masterg.andyc.org

This topic is closed to new replies.

Advertisement