Re: JOGL - High performance text rendering
Posted by Rbajter on Jul 11, 2011; 1:04am
URL: https://forum.jogamp.org/JOGL-High-performance-text-rendering-tp1319060p3157747.html
Hi there, I just stumbled across your post - a bit late perhaps.
Anyway, I'm trying to do the exact same thing as you are/were: Display many thousands of obects with text labels over a map (the google maps kind). My goal was to render 10000 textured quads plus labels with a framerate of about 20 on my hardware. I got 5000 with a framerate of about 15. Close enough. The biggest problem was how to render strings efficiently with TextRenderer.
This is what my text rendering loop looks like (simplified):
String text = "Hello?";
textRenderer.setColor(Color.WHITE);
textRenderer.begin3DRendering();
for (Point2D point : points) {
gl.glPushMatrix();
gl.glTranslated(point.getX(),point.getY(), 0.0);
textRenderer.draw(text, 0, 0);
textRenderer.flush();
gl.glPopMatrix();
}
textRenderer.end3DRendering();
Note that the begin and end are outside the loop and there is a flush call after the draw call instead of having the begin and end surround the draw call inside the loop. This simple restructuring took me from 500 to 5000 objects on screen with similar framerates. Of course, if I drop text rendering altogether I can render 50000 objects instead, but that's not really helpful.
Even though it might be too late I thought I should share this insight.
Cheers!