Hi. After scratching my head for a few days, I thought it would be time to scratch elsewhere.
An OpenGL sketch I am working on is giving me a little trouble. Basically, I am drawing text to offscreen 2D buffers, and then moving, rotating and rendering the buffers to screen, which gives something like this:
http://bruno.wyldind.com/cityspeak/imgs/screenshot-05.png
People send SMS, which slowly appear in the bottom-left of the screen, and then move following the different lines to disappear in the back.
My problem is with the rendering of the bottom-left message. Using the code below, the offscreen buffer of the bottom-right text is updated and the text filled in a little more every frame. When the filling is completed, the buffer is 'cached' (not modified anymore), and then it starts moving to the right.
The issue is that, if the buffer of the text is slightly larger than normal (e.g. 2 or more lines of text, as in the image above), the code below takes a constant 20-40ms to execute, EXCEPT for one odd frame that will suddently take 120-220ms, then it goes back to normal, and then the execution time is trivial once the text is cached.
This causes a tiny, but noticeable hang, in the animation.
Code:
if (!cached) {
gBuffer.beginDraw();
gBuffer.pushMatrix();
gBuffer.translate(-theString.bounds.x+getWidthPadding(), -theString.bounds.y+getHeightPadding());
drawMotes(gBuffer); //update and draw motes
gBuffer.popMatrix();
gBuffer.endDraw();
}
//copy the buffer to the main graphics
g.pushMatrix();
g.translate(theString.bounds.x-getWidthPadding(),
theString.bounds.y-getHeightPadding(), theString.position.z);
g.image(gBuffer, 0, 0);
g.popMatrix();
//at some point below this 'cached' is set to true
//...
This is also true when using P3D.
Any idea what might cost 100-200ms to execute, for only one frame, in the Processing code?
EDIT:
If it helps, I have hint(DISABLE_DEPTH_TEST); set.