PDA

View Full Version : Rendering a grid with multiple Triangle Strips



ericgorr
12-06-2005, 01:47 PM
From what I understand from what I read at:

http://www.gamedev.net/community/forums/topic.asp?topic_id=311048

I should be able to send multiple GL_TRIANGLE_STRIPs and see vertex 1
of strip 1 connected to vertex 1 of strip 2, etc.

Is this correct (assuming it made sense)?

However, the following render function:

glBegin(GL_TRIANGLE_STRIP);

glVertex3f( -1.0, -1.0, 0 );
glVertex3f( 0, 1.0, 0 );
glVertex3f( 1.0, -1.0, 0 );
glVertex3f( 2.0, 1.0, 0 );

glEnd();

glBegin(GL_TRIANGLE_STRIP);

glVertex3f( -1.0, -1.0, -1 );
glVertex3f( 0, 1.0, -1 );
glVertex3f( 1.0, -1.0, -1 );
glVertex3f( 2.0, 1.0, -1 );

glEnd();

only produces two distinct objects which are not connected.

How can this be accomplished? I assume I am missing some glEnable or
something call.

Thank you.

songho
12-06-2005, 03:41 PM
ericgorr,
There are 4 vertices in your code, therfore you can draw 2 triangles with triangle strip.

The order of vertex winding is not right. (It starts with counter clock wise for front face)

The correct order would be;

glBegin(GL_TRIANGLE_STRIP);
glVertex3f( 2, 1, 0 );
glVertex3f( 0, 1, 0 );
glVertex3f( 1, -1, 0 );
glVertex3f(-1, -1, 0 );
glEnd();

==song==