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

Thread: glDrawElements and friends....

  1. #1
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,651

    glDrawElements and friends....

    Hi !

    Is glDrawElements any faster then glVertex if I use iu as it is (no nVIDIA extensions, just ordinary ram) ?

    I have a lot of meshes to render, but they are split up in objects and each object is changed now and then so using display lists is no good idea, I am trying to find the best solution that works on "all" OpenGL implementations (at least all non software OpenGL's).

    Mikael

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    3,768

    Re: glDrawElements and friends....

    The main advantage of pure vertex arrays (without extensions) is simply that they use fewer function calls to get the same effect. There are a few other details that make vertex arrays faster, but that's the main thing.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: glDrawElements and friends....

    The benefit of pure vertex arrays is not only that there's less function call overhead (important in and of itself) but also that you can get vertex re-use. A typical software implementation will mark transformed vertices as "transformed" and not re-do the work when you reference a vertex a second (third, fourth, ...) time within the same index array.

    Also, for HT&L cards, larger vertex buffers will be copied by the driver into an AGP area, from which the card can pull it asynchronously, and the driver can meanwhile return to your program. Thus, your program only has to pay the cost of finding the maximum and minimum index values, and the memory copy; transform/rasterization may be overlapped for you.

    Last, if you use "regular" vertex arrays, you can still get a speed-up by using the LockArrays extension (especially if you multi-pass) and/or using the NV_vertex_array_range extension where available. I e, your code looks the same except for a possible call to VertexArrayRangeNV at the beginning, and possibly bracketing your drawing with LockArraysEXT/UnlockArraysEXT.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

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