Results 1 to 4 of 4

Thread: DrawElements and sharing indices

  1. #1
    Senior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Poland
    Posts
    196

    DrawElements and sharing indices

    Hi,

    I've got a model with vertex, normal and texture coordinates data and I want to draw this using DrawElemets. The problem is that each vertex has diffrent normal and texture coordinate.
    DrawElements calls every enabled array element with given index. I want to call vertex array element with vertex index, normal array element with normal index and texcoords array element with texcoord index, respectively. Is it possible using arrays? I tried with InterleavedArrays but it gives no success. For now I've got a code for drawing (face arrays includes indices):
    Code :
    // this is only pseudo code, cutted for better reading
    glBegin( GL_TRIANGLES );
    for( int j = 0; j < numFaces; j++ )
    {	
     
    	glTexCoord2fv( texCoords[ texcoords_faces[j] ] );
    	glNormal3fv( normals[ normal_faces[j] ] );
    	glVertex3fv( vertices[ vertices_faces[j] ] );
    }
    glEnd();
    Thanks for help

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: DrawElements and sharing indices

    That is not possible. There's only one index which is used for all attributes. So duplicate vertices that have different normals/texcoords.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    374

    Re: DrawElements and sharing indices

    Originally posted by glYaro:

    DrawElements calls every enabled array element with given index.
    That is how it is and there is no way around it. You just have to make all your arrays of the same size. This means that you have to dublicate vertices if they have more than one normal or texcoord. But glDrawElements will likely draw faster than immediate mode and it is very easy to implement vbo afterwards.

    hih

  4. #4
    Senior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Poland
    Posts
    196

    Re: DrawElements and sharing indices

    I supposed that. Thanks anyway

Similar Threads

  1. Replies: 2
    Last Post: 12-26-2018, 07:01 AM
  2. drawElements
    By gnitsuk in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-14-2014, 09:30 AM
  3. Uniform sharing, constants sharing
    By V-man in forum OpenGL: GLSL
    Replies: 2
    Last Post: 11-24-2004, 10:41 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