Hi all,
switching from 1.1.0 to 1.1.1RC6 I noticed that the position of text rendered by TextRenderer is not affected by any transformations (f.e. glTranslated). All text is rendered at exactly the same position within my 3D scene.
(I just checked again and the code works correctly using Jogl 1.1.0)
Any ideas, anything I have overseen or anything I could help with?
Thx, Martin
protected void renderText(GL gl, GLU glu, TextRenderer textRenderer, OrbitRotation orbitRotation,
String text, Color4f textColor, Vector3d textPosition, double zOffset, double scaleFactor, boolean centered) {
textRenderer.begin3DRendering();
textRenderer.setColor( textColor.x, textColor.y, textColor.z, textColor.w );
gl.glEnable(GL.GL_CULL_FACE);
// Note that the defaults for glCullFace and glFrontFace are
// GL_BACK and GL_CCW, which match the TextRenderer's definition
// of front-facing text.
gl.glPushMatrix();
gl.glTranslated( textPosition.x, textPosition.y, textPosition.z );
gl.glMultMatrixd( orbitRotation.getRotationalInverseOfCameraMatrix(), 0 );
Rectangle2D bounds = textRenderer.getBounds(text);
float w = (float) bounds.getWidth();
float h = (float) bounds.getHeight();
if (centered) {
textRenderer.draw3D(text,
(w / -2.0f * (float)scaleFactor ),
(h / -2.0f * (float)scaleFactor ),
(float)zOffset,
(float)scaleFactor);
} else {
textRenderer.draw3D(text,
0,
0,
(float)zOffset,
(float)scaleFactor);
}
gl.glPopMatrix();
textRenderer.end3DRendering();
}