Posted by
asambol on
Jan 18, 2013; 10:31am
URL: https://forum.jogamp.org/TextRenderer-very-low-FPS-with-dynamic-text-tp4027924.html
I'm using the new TextRenderer (from com.jogamp.graph.curve package) to display 20 labels on the screen, together with my model (which runs normally at 60 FPS). The text should update on every draw. However, it is very slow - about 0-2 FPS. If I change it to draw non-dynamic Strings, it works fine, at 60 FPS.
Here's how I initialize it:
ShaderState shaderState = new ShaderState();
RenderState renderState = RenderState.createRenderState( shaderState, SVertex.factory() );
textRenderer = TextRenderer.create(renderState, 0);
textRenderer.init(gl);
textRenderer.setColorStatic( gl, 1.0f, 1.0f, 1.0f );
textRenderer.setAlpha( gl, 1.0f );
And here's the part of my draw method which draws random text:
gl.glUseProgram(textRenderer.getShaderState().shaderProgram().program()); // equivalent to st.glUseProgram(false)
for (int i=0; i<20; i++) {
textRenderer.resetModelview( null );
textRenderer.translate( null, -0.6f, -0.38f+0.03f*i, -1.0f );
textRenderer.scale(gl, .02f, .02f, 1.0f);
textRenderer.drawString3D(gl, font, String.format("%02.0f fps - %06.5f - %d", animator.getLastFPS(), Math.random(), i), position, fontSize, textureSize );
textRenderer.flushCache(gl);
}
When I remove the random number it works much better, although every time FPS changes (DEFAULT_FRAMES_PER_INTERVAL) it stutters and then continues normally until the next FPS change.
CPU consumption:
without labels: ~50%
with labels: ~100%
- only 1 core, other cores are mostly at ~10%
Memory consumption (javaw.exe process):
without labels: 181 MB
with labels: varies between 712 MB and 780 MB
Any advices?