Login  Register

Re: JOGL - High performance text rendering

Posted by Rbajter on Oct 09, 2011; 2:04pm
URL: https://forum.jogamp.org/JOGL-High-performance-text-rendering-tp1319060p3407415.html

Hi,
I just got a little time to look at the new text rendering api in jogl. Btw, the demos look great. :) I'm really exited to try and get this working in my app. I've scoured the demo code and think I have all the bits required to make it work. Before I start fiddling with a test app I just wanted to check that I haven't missed anything and also ask a few questions.

Below is what I think are the relevant classes and calls:

//Initialization
Font font = FontFactory.get(FontFactory.JAVA ).getDefault();
ShaderState shaderState = new ShaderState();
RenderState renderState = RenderState.createRenderState( shaderState, SVertex.factory() );
int renderModes = 0;
TextRenderer textRenderer = TextRenderer.create( renderState,  renderModes);  //Render modes?

//Rendering
textRenderer.reshapeOrtho( null, width, height, near, far );  //GL context null
textRenderer.setColorStatic( gl, 0.0f, 0.0f, 0.0f );
textRenderer.setAlpha( gl, 1.0f );
textRenderer.resetModelview( null );                    //GL context null
textRenderer.translate( gl, 10.0f, 10.0f, 0.0f );
float[] pos = new float[] {0,0,0};
int fontSize = 10;
int textureSize = 400; 
textRenderer.drawString3D( gl, font, "text", pos, fontSize, textureSize );

1. What are render modes? And why should I care?
2. Apparently I can set a projection directly on the text renderer. Why? Can't I just use whatever projection I already have set up?
3. Some calls to the renderer are done with a null GL context. What does that mean?
4. In the drawString3D call there is a texture size argument for multipass rendering. What size should I set and when is it used?

Now what would be really cool is a blow-by-blow minimal usage example, maybe posted in the blog, but I guess that is just wishful thinking. :)
Anyway, thanks for all the great work!

//Johan