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

Thread: multiple vertex arrays

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Posts
    4

    multiple vertex arrays

    I have several different objects in my scene and would like to render them as vertex arrays. Since I use different arrays for different objects I have to do this for each object in every frame:

    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);

    glVertexPointer(3, GL_FLOAT, 0,vertex_array);
    glNormalPointer(GL_FLOAT, 0, normal_array);
    glTexCoordPointer(2, GL_FLOAT, 0,texcoords_array);

    glDrawArrays(GL_TRIANGLES, 0,num_verticies);

    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);


    I would guess that this is very inefficient but have no other idea how to do this, because I have to switch the pointers to the different arrays...

    Is there a better way to do this when using multiple vertex arrays?

    Thank you in advance

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Slovakia
    Posts
    108

    Re: multiple vertex arrays

    You don't have to do glEnableClientState(...) and glDisableClientState(...) every frame just use glEnableClientState once in initialization and then switch arrays with glVertex(Normal,TexCoord)Pointer(....)

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2004
    Posts
    4

    Re: multiple vertex arrays

    Thank you for that quick answer!

    Some of my objects have no normal verticies. When I switch the pointers, what would I do with the normal array pointer? Does it work like that:

    glNormalPointer(GL_FLOAT, 0, NULL);

    Or do I have to disable that client state explicitly before setting the pointers and drawing the arrays?

    Another question is: how I can lock some of the arrays while others wont be locked (glLockArraysEXT)? Do I have to do this every frame (because the pointers change)? Or is there an internal reference set, the first time I init the arrays?

  4. #4
    Junior Member Newbie
    Join Date
    Jan 2004
    Posts
    4

    Re: multiple vertex arrays

    Sorry. I have to *bump* this...

  5. #5
    Junior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Michigan, USA
    Posts
    184

    Re: multiple vertex arrays

    vertex array locking provides a benifit only if your rendering more than once per lock. That is if your locking and unlocking every time you render you will get little benefit. Take a look at the reference document, available on the opengl extensions registry web site.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Aug 2001
    Location
    Italy
    Posts
    626

    Re: multiple vertex arrays

    Originally posted by maximian:
    vertex array locking provides a benifit only if your rendering more than once per lock. That is if your locking and unlocking every time you render you will get little benefit. Take a look at the reference document, available on the opengl extensions registry web site.
    If you are referring to EXT_compiled_vertex_array, I must say this extension is badly out of date (that's why it's not in core GL). In the tests I ran some time ago (should be about 2-3 months) CVAs proved to be slower than non-compiled arrays.
    Possibly, the gain/loss is dependant from the application, system and implementation.
    I personally suggest to drop them.

  7. #7
    Junior Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Michigan, USA
    Posts
    184

    Re: multiple vertex arrays

    I agree. Use VBOs which seem to work across most modern hardware.

Posting Permissions

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