Drawing lot's of trails


Hi all,
I’m currently doing a project that requires drawing a lot of trails, in my initial naive tests i tried to make a std::vector of VboMeshes but performance is not good. I can get about 100 trails, but it needs to be something like 6k.

The way I’m doing is similar to this sample that Paul did, but there is probably a better way to do this with cinder-0.9.0+

The only info I found about this in the forum was this post, but I could not connect the dot’s :eyes: on how to even start

anyway, any help is appreciated!

Smooth, efficient, perfect curves

Let us know what you have trouble with. Can you move your particles with transform feedback without any trails?


Hi gabor, thank you for the fast reply.

I forgot to post the test that I made:

For now, I’m not moving the particles with transform feedback, Acctually, for test sake, it’s just the mouse pointer.

What I can’t get my head around is how to draw multiple trails in a single vboMesh ( I think is a lot more performant than drawing each trail as a VboMesh )


I did what was explained by Seph in the post above, but I was not using a VboMesh:

  • one Vbo holds the particle positions
  • and another Vbo holds the indices for the particles in the positions Vbo for each trail


Hi there, sorry for de delay, I was trying to understand how to generate a VBO by “hand”. I’ve made some progress by constructing a mesh with the following structure:

For two particles with a trail of 4 points
Trail 1:
index0, index1, index1, index2, index2, index3

Trail 2:
index4, index5, index6, index6, index6, index7

But for some reason the last point get’s connected to the first point of the next particle ( or vec2(0.f,0.f) , like the picture below shows

(drawing with immediate mode is fine)

I’ve updated the gist: https://gist.github.com/Hperigo/c70d1970a7244f8e367abdfc8d717425

I also did some tests trying to draw 60000 vertices and the performance was not good, so either I’m doing something wrong with the VBO or this is the wrong approach.

Some time ago I did manage to draw multiple lines using instancing, but I’m not sure how I would control each individual vertex position for each instance, maybe with a 32f Texture?



I don’t know if it helps, but I used to have a sample that is still available in the dark history of git. It uses a deque to easily add positions at the end of an array and remove them from the front. While probably not the most efficient way to do things, it’s pretty fast anyway. From it, we update a VboMesh which uses a triangle strip as the primitive. To draw lines, you could simply make the trail very thin.

Remember that the number of vertices or primitives is not the only factor that determines performance. Overdraw can also affect performance greatly, especially on mobile platforms. I think your experiment with 60,000 vertices might be slow because of that.



Hi paul!
thank you for the suggestions! I was actually following your sample and also [sansumbrella line renderer] (https://github.com/sansumbrella/Pockets/blob/master/src/pockets/gl/LineRenderer.cpp)

I tried again and managed to make the thing work, so thank you all =).

But, I’ve encontered another weird obstacle from the OpenGl world. It looks like when I resize the window or the fps is a little bit low I get a weird flicker in the VBO mesh, check it out:

(The compression on the video is horrible, but you can get the point)
any ideas?

The flicker only happens on the VboMesh btw


My guess is that you have an error in they way you add positions. A single error in position offset or index might create a long chain of degenerate triangles, causing the ribbon to not render.

It could also be some kind of buffer overrun. Check the code that writes the new positions.



that was it!

thank’s Paul!