Login  Register

Is this the correct way to draw rotated text with TextRenderer?

Posted by farrellf on Nov 22, 2016; 5:04am
URL: https://forum.jogamp.org/Is-this-the-correct-way-to-draw-rotated-text-with-TextRenderer-tp4037443.html

I'm writing a 2D program and I'm using some TextRenderer objects to overlay text in my GLCanvas. I have a weird intermittent problem: when I try to draw rotated text (code below) it usually works perfectly, but sometimes it instead draws the text at the bottom-left of the GLCanvas with no rotation. Sometimes it will flicker between drawing correctly, and drawing at the bottom-left-without-rotation quirk. It's intermittent, but somewhat repeatable. It happens with both an Nvidia card and on another PC with integrated Intel graphics.

Code snippet:
...
import com.jogamp.opengl.util.awt.TextRenderer;
...
myTextRenderer.beginRendering(width, height);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glPushMatrix();
gl.glTranslatef(xOffset, yOffset, 0.0f);
gl.glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
myTextRenderer.setColor(myColor);
myTextRenderer.draw(myText, 0, 0);
myTextRenderer.endRendering();
gl.glPopMatrix();
...

When I render not-rotated text, it always works perfect. Only when I try to rotate does this bug appear.

Thanks,
-Farrell