Results 1 to 5 of 5

Thread: Help drawing with TRIANGLE_STRIP

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Leartherhead Surrey England
    Posts
    29

    Help drawing with TRIANGLE_STRIP

    Hi!

    I have defined a plane with a specific mesh. I have created the following arrays:
    xmesh[i][j];
    ymesh[i][j];
    zmesh[i][j] where i=0,dim1-1 j=0,dim2-1

    colors are in ColorP[k][i][j]; where k=0,2 (red, green, blue)
    normals are in Normal[l][i][j] where l=0,2

    Now I would like to display those points with associated colors and normals using TRIANGLE_STRIP, can someone help me do this?

    Thanks,

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Help drawing with TRIANGLE_STRIP

    One change would be you in your variables:

    xmesh[number_of_points][3] = {{x,y,z}};
    ymesh[number_of_points][3] = {{x,y,z}};
    zmesh[number_of_points][3] = {{x,y,z}};

    normal[number_of_triangles] = {{x,y,z}};

    color[number_of_points][3] = {{r,g,b},....,{r,g,b}};


    // there maybe some error's I did this off the top of my head... but should give you an idea.

    glBegin(GL_TRIANGLE_STRIP);

    for(i=0;i <= number_of_points;i++) // number of points to process
    {

    glColor4fv( color[i] );
    glNormal3fv( normal[i] );// maybe add another loop to process normal on a per triangle basis.
    glVertex3f(xmesh[i], ymesh[i], zmesh[i] );
    }

    glEnd();

    Hope this helps

    Originally posted by fcoutel:
    Hi!

    I have defined a plane with a specific mesh. I have created the following arrays:
    xmesh[i][j];
    ymesh[i][j];
    zmesh[i][j] where i=0,dim1-1 j=0,dim2-1

    colors are in ColorP[k][i][j]; where k=0,2 (red, green, blue)
    normals are in Normal[l][i][j] where l=0,2

    Now I would like to display those points with associated colors and normals using TRIANGLE_STRIP, can someone help me do this?

    Thanks,


    [This message has been edited by nexusone (edited 09-10-2002).]

  3. #3
    Senior Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    765

    Re: Help drawing with TRIANGLE_STRIP

    nexusone : that may not work because I think the mesh isa rectangular patch.

    fcoutel : is that right that your mesh[i][j] is organized so that [i] represents rows and [j] represents columns ? If it is the case, then your mesh is is a rectangular patch and it's very easy to render it with triangle strips.

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Leartherhead Surrey England
    Posts
    29

    Re: Help drawing with TRIANGLE_STRIP

    Hi there!

    Thanks guys for your response, yes it is correct that mesh[i][j] is organized so that [i] represents rows and [j] represents columns
    so how can I display the mesh?

  5. #5
    Senior Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    765

    Re: Help drawing with TRIANGLE_STRIP

    for each i from 0 to dim1-2 // not dim1-1
    glBegin(GL_TRIANGLE_STRIP);
    for each j from 0 to dim2-1
    glNormal3f(Normal[0][i][j], Normal[1][i][j], Normal[2][i][j]);
    glColor3ub(Color[0][i][j], Color[1][i][j], Color[2][i][j]);
    glVertex3f(xmesh[i][j], ymesh[i][j], zmesh[i][j]);
    glNormal3f(Normal[0][i+1][j], Normal[1][i+1][j], Normal[2][i+1][j]);
    glColor3ub(Color[0][i+1][j], Color[1][i+1][j], Color[2][i+1][j]);
    glVertex3f(xmesh[i+1][j], ymesh[i+1][j], zmesh[i+1][j]);
    end for
    glEnd();
    end for

    note: I've used "glVertex3f" and "glNormal3f" because I assume your vertex and normal data type is GL_FLOAT, and "glColor3ub" because I assume your color data type is GL_UNSIGNED_BYTE. But if your data types are different, of course you must call something else than glVertex3f, glNormal3f and glColor3ub

    ps: as a matter of optimization, I recommend you to organize your data differently so that you can use vertex arrays.

    [This message has been edited by vincoof (edited 09-11-2002).]

    [This message has been edited by vincoof (edited 09-11-2002).]

Similar Threads

  1. Does TRIANGLE_STRIP vertex drawing order matter?
    By GLRon in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-29-2010, 02:04 AM
  2. TRIANGLE_STRIP + VBO
    By maximian in forum OpenGL: Advanced Coding
    Replies: 19
    Last Post: 12-01-2003, 07:19 PM
  3. TRIANGLE_STRIP vs. TRIANGLE_FAN
    By bleifrei in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-06-2003, 12:48 PM
  4. Using QUAD_STRIP or TRIANGLE_STRIP ?
    By Structural in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 01-09-2003, 11:10 AM
  5. triangle -----> triangle_strip ????
    By celic in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 02-28-2002, 12:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean