Results 1 to 2 of 2

Thread: Normals and textures with GL_TRIANGLE_STRIP

  1. #1
    Member Newbie
    Join Date
    May 2004
    Posts
    46

    Normals and textures with GL_TRIANGLE_STRIP

    Hi

    I'm trying to optimize terrain rendering by replacing GL_TRIANGLES
    with GL_TRIANGLE_STRIP

    1.Is following code correct for normal vector passing for 2 triangles built of 4 vertices - i.e does OpenGL automatically assign normals properly ?

    2.The same question regarding texture coordinates?

    //normal for first triangle
    glNormal3fv(Triangles[iTri].fNorm);

    glTexCoord2f(fTexx1,fTexy1);
    glVertex3f(Vertices[iy][ix].fX,Vertices[iy][ix].fY,Vertices[iy][ix].fZ);

    glTexCoord2f(fTexx2,fTexy1);
    glVertex3f(Vertices[iy][ix+1].fX,Vertices[iy][ix+1].fY,Vertices[iy][ix+1].fZ);

    glTexCoord2f(fTexx1,fTexy2);
    glVertex3f(Vertices[iy+1][ix].fX,Vertices[iy+1][ix].fY,Vertices[iy+1][ix].fZ);

    //normal for second triangle
    glNormal3fv(Triangles[iTri+1].fNorm);

    glTexCoord2f(fTexx2,fTexy2);
    glVertex3f(Vertices[iy+1][ix+1].fX,Vertices[iy+1][ix+1].fY,Vertices[iy+1][ix+1].fZ);


    Thanks



    P.S. Sorry for off-topic - but is it possible to change a nickname? (or delete account ,because opening new requires different valid email?)

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: Normals and textures with GL_TRIANGLE_STRIP

    This is exactly how vertex attributes work in OpenGL. Imagine a set of registers, where each register holds a value. This values are attributes like normal, texcoord, color, etc. The corresponding commands just change the values in this registers, nothing more. And when a vertex is submitted, by calling glVertex, all the attribute values will be submitted along with it. With another words, if you set a normal (or another per-vertex attribute), it will be valid for all subsequent glVertex calls. Even more, you can use the same technique with vertex arrays.

Similar Threads

  1. Normals and GL_TRIANGLE_STRIP
    By ToddAtWSU in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 05-08-2006, 10:22 AM
  2. Normals and GL_TRIANGLE_STRIP
    By ToddAtWSU in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 04-21-2006, 12:26 PM
  3. GL_TRIANGLE_STRIP and Normals
    By jleffelm in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-06-2004, 12:37 PM
  4. Normals for GL_TRIANGLE_STRIP
    By Milo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-19-2003, 10:33 PM
  5. normals and GL_TRIANGLE_STRIP
    By dcd in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-06-2003, 10:27 PM

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