onally set the color renderer.setColor(1.0f, 0.2f, 0.2f, 0.8f); renderer.draw("Text to draw", xPosition, yPosition); // ... more draw commands, color changes, etc. renderer.endRendering(); Unless you are sharing textures and display lists between OpenGL contexts, you do not need to call the {@link #dispose dispose}method of the TextRenderer; the OpenGL resources it uses internally will be cleaned up automatically when the OpenGL context is destroyed.
Note that the TextRenderer may cause the vertex and texture coordinate array buffer bindings to change, or to be unbound. This is important to note if you are using Vertex Buffer Objects (VBOs) in your application.
Internally, the renderer uses a rectangle packing algorithm to pack both glyphs and full Strings' rendering results (which are variable size) onto a larger OpenGL texture. The internal backing store is maintained using a {@link com.sun.opengl.util.j2d.TextureRenderer TextureRenderer}. A least recently used (LRU) algorithm is used to discard previously rendered strings; the specific algorithm is undefined, but is currently implemented by flushing unused Strings' rendering results every few hundred rendering cycles, where a rendering cycle is defined as a pair of calls to {@link #beginRendering beginRendering} / {@link #endRendering endRendering}.
@author John Burkey
@author Kenneth Russell