Results 1 to 4 of 4

Thread: drawing polylines in bulk

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    12

    drawing polylines in bulk

    I'm using drawArrays(), with mode LINE_STRIP to draw a polyline. So far, so good - everything works.

    I actually have a number of polylines that I want to render in batch.
    However, it's not clear to me what data I should be binding for the drawElements call.

    I assume that, at least, I need to have a bound buffer containing the concatenated coordinates of all the polylines I'm drawing.

    However, what should the element array buffer contain? Subsequent pairs of start/end indices? Is bulk/batched polyline drawing even supported at all?

  2. #2
    Junior Member
    Join Date
    Mar 2011
    Posts
    12

    Re: drawing polylines in bulk

    I managed to solve this one myself.

    Populate the vertex buffer with all the points from all the polylines.
    Then populate the index buffer with pairs of indices (single lines), each connecting a pair of points.

    It seems not very elegant, but I guess it beats having to make thousands of separate draw calls.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Posts
    11

    Re: drawing polylines in bulk

    Actually that is a very good approach. In OpenGL 3, there is a feature called primitive restart, which allows you to assign an index value that terminates a primitive and starts a new one. This allows you to draw disconnected polylines using LINE_STRIP, so it saves some index data and is, arguably, cleaner. We may or may not see this feature make its way into OpenGL ES / WebGL.

    Patrick

  4. #4
    Junior Member
    Join Date
    Jul 2012
    Posts
    1

    Re: drawing polylines in bulk

    Hi..is there any function like primitive restart for webgl.i need because it may not be very elegant to use index buffer instead of line_strip for drawing polylines

Posting Permissions

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