Performance when drawing Triangles

Hey Guys,

I am quite new to Open Frameworks and I really love using it! I have one question which I couldn’t really solve with google.:

So, I am building a Video Synth based on the Open Frameworks Essentials Book. I wanted to use it at a VJ gig I have in a few days. So the problem I faced was when increasing the CountX and CountY (for duplicating 2d triangles/rectangles) to a certain degree my framerate gets really bad.

So a friend of mine helped me profiling the project in xCode and we saw that most of the performance was drawn by the ofDrawTriangle() function. I think I’ve read somewhere, that when drawing a lot of 2D primitives, the standard functions for doing that are quite bad on the performance side. But I don’t know anymore where I read that and how to approach it…

I hope I did not oversee something easy and essential, but anyway thanks in advance!


Hi David,

For what I understand, sending data to the graphics card item by item is relatively slow and it involves lots of function calls.

What if you create an ofVbo instead, and draw it using GL_TRIANGLES?

Once created you can alter the vertices by using setVertexData (if you want to move them), without creating or deleting any vertices. That way you can maintain a data structure of fixed size and draw it fast.

If you want to draw a subset of all your triangles, you can use drawElements.

I’ll be happy to know how much of a difference it makes in your case.