Hi, it’s the TextRenderer stress maker again!
It literally took me a while to figure out how to combine crisp text rendering (via TextRenderer) and
generating huge screenshots (via TileRenderer). The problem for my specific case is that I have
to render a scene in world coordinates, but for me it is mandatory to render text in pixel coordinates.
Only that way I achieve crisp labels and can assure that labels have the same size in a huge
screenshot (say 8000x8000) and on screen! To create huge screenshots I use the TileRenderer
class. However, since I combine world coordinates rendering (of the scene) and pixel cooridinates
rendering (of the labels), I have to pay special attention to the tiling process.
In any case, I figured out how this works; my scene is always tiled correctly!
BUT, I discovered a strange problem that drove me nuts!!! When I render a few (depends on tile size
and screenshot size) labels to a huge tiled screenshot everything works out well. BUT, when I have
to render more and more labels, some appear in tiles where they should not be and labels that
should be on a tile are not shown!
Since that behavior seemed a bit non-deterministic, I blamed it to the TextRenderer. To support that
hypothesis I added code that draws a simple GL_POINT directly where a label is supposed to appear.
Interestingly, both labels AND points show the same weird erroneous behavior! Since rendering of a
label is independent from rendering a point, I would have expected that at least the points appear
correctly! So, the call to the TextRenderer’s draw(…) method must be the problem. And yes, when I
comment out just the calls to that method, then ALL points are drawn correctly. There must be a problem
with the call of draw(…). It seems the problem also depends on length of labels.
I created a test case, so that you can reproduce my problem. The test case simply shows a torus (the
scene in world coordinates) and draws a circle of labels (and points) (in pixel coordinates).
You can press ‘x’ to render a large tiled screenshot (several .png files will be generated in the working directory).
You will see that the tiles do not have correct labeling!!! You can press ‘l’ to disable calls to draw(…) and
take a new screenshot. Then you will see that all points are rendered correctly!!! You can also use
‘+’ and ‘-’ to inc/decrease the number of labels (recall that fewer labels do not cause the mentioned problem).
Bottom line: My impression is that there is something wrong either with the way I use the TextRenderer or with the
TextRenderer itself. I would very much appreciate if anyone could reproduce the behavior I described above.
I have tested on WindowsXP and Linux and ATI and NVIDIA! I use the latest jogl runtime!
Attached are two tiles. One shows that label positions are correct, but calls to draw(…) have to be disabled
to get to this correct rendering. Once calls to draw(…) labels are shown, BUT labels AND points disappear
somehow??!!! The test case is attached too.