Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Rendering a grid with multiple Triangle Strips

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2005
    Posts
    8

    Rendering a grid with multiple Triangle Strips

    From what I understand from what I read at:

    http://www.gamedev.net/community/for...opic_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.

  2. #2
    Junior Member Regular Contributor songho's Avatar
    Join Date
    May 2003
    Location
    Canada
    Posts
    242

    Re: Rendering a grid with multiple Triangle Strips

    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==

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •