Login  Register

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

Posted by Martin on Feb 07, 2022; 3:18pm
URL: https://forum.jogamp.org/Is-this-the-correct-way-to-draw-rotated-text-with-TextRenderer-tp4037443p4041629.html

Hi,

I learn two additional things that are worth knowing when using the TextRenderer

1) It is necessary to reset the polygon mode before using it as follow, otherwise text is invisible

glPolygonMode(PolygonMode.FRONT_AND_BACK, PolygonFill.FILL);

2) The width and height parameters to be given to beginRendering(...) are not the canvas size but rather the current viewport dimension inside this canvas.

In my case I have a canvas where two distinct viewport are used : the left part is for the 3D chart, the right part is for a colorbar. When using the canvas dimension for text that should appear in the left part, then everything is weirdly stretched (see below).

To avoid this, configure beginRendering() with viewport[2] and viewport[3] after retrieving viewport as follow

int viewport[] = new int[4];
glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);