This conversation started in another thread about Component Animator, but since this ended up being a sort of general iOS optimization question I wanted to call it out on its own topic. I'm hoping someone with more iOS/GL experience will be able to recommend some improvements here.
Using the OpenGL Renderer in Juce on iOS is really really slow. A good way to see this is to:
- Open the Juce Demo on an iOS device (you must look an a physical device to really see how slow it is -- preferably Retina)
- Go to the Tabs & Widgets demo page. From the Look-and-Feel menu, choose Use OpenGL Renderer
- Switch to the Box2D demo.
What you will see is animation happening at something like 5 frames per second. Ouch!
I am by no means an OpenGL expert, but in Instruments I saw that glBufferSubData seemed to be a bottleneck. So I did some poking around on game forums and tried a few things. In Juce_openGLGraphicsContext.cpp, in draw(), i replaced glBufferSubData with glBufferData, and that alone improved my frame rate by leaps and bounds (i'm not sure what hint to give it here, I tried dynamic, static and stream, didn't seem to make much difference):
context.extensions.glBufferData (GL_ARRAY_BUFFER, (GLsizeiptr) ((size_t) numVertices * sizeof (VertexInfo)), vertexData, GL_DYNAMIC_DRAW);
Still not what I would call smooth animation, but much better (it has improved component animations to the point where I would now ship my app with them, so that's a big improvement, but still not perfect). That's all well and good, but Jules notes that it is a bit counterintuitive that this would speed things up.
Does anyone have any suggestions for a) why this helps and b) what other things could be slowing down OpenGL rendering so much on iOS?