Results 1 to 4 of 4

Thread: drawArrays vs drawElements

  1. #1

    drawArrays vs drawElements

    So I was checking out c3dl and they exclusively use drawArrays in their engine. Until now I had been using drawElements and now I am questioning which is the better choice.

    With drawArrays I would think that you're vertex/normal/texcoord buffers are going to be larger since you cant index into them and thus consume more memory. However with this you don't have to store an indices buffer at all which saves memory, where as with drawElements you have to store and bind an indices buffer everytime.

    For example:
    gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, getIndexBuffer());
    could be removed from the render calls all together when using drawArrays over drawElements. It may seem like a negligable difference but if you are drawing 50 objects 60 times a second thats 3000 bind and 3000 accessor calls saved per second.

    Could anyone share what they think is the most efficient/preferred format and for what reasons?


  2. #2

    Re: drawArrays vs drawElements


    There are is also cache hit/miss to consider. With well formatted indices you will have more cache hits with drawElements vs the linear pattern of drawArrays.


  3. #3
    Junior Member
    Join Date
    May 2011

    Re: drawArrays vs drawElements

    A lot depends on how you tessellate your surface. drawArrays is good for TRIANGLE_STRIPS and TRIANGLE_FANS where you are not hit with much vertex repetition. If your tessellation is more grid like where the vertex repetition is high drawElements is certainly a more efficient use of memory. You would need someone with deep GPU knowledge to know if the caching advantage outweighs the constant reference to multiple memory areas.

  4. #4

    Re: drawArrays vs drawElements

    I think it also depends on needs as well. Like I'm working with cultural heritage and museum 3D objects, which these laser scanned objects contains lots of triangles. While there is a limit in drawElements of 65k, which sometimes not enough to represent enough details, drawArray can be a better choice if you want to present a high quality mesh.

    So far, the maximum that my application can loads is 500k triangles using drawArray, I can go further but it will not work for Firefox.

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