Creating text as a texture?

Here's a screenie of the current work I have done.

you will probably have to use java2d to render the text to the textures. (see the HUD example in the wiki)

is your hex grid a single object?

chirstius said:

I'd like to have the capability to have each hex on the gameboard be numbered with it's X and Y gameboard coordinates.

I'm not sure it would be too cluttered, as I intend for the numbering to be fairly small.

As a debugging aid, the coordinates on every hextile make sense.

culli said:

As a debugging aid, the coordinates on every hextile make sense.

of course again i have no clue, but here's my opinion :stuck_out_tongue:

if you generate such a huge texture (because your grid seems quite big) it will have to live in the memory of your graphics card and might give you some serious performance issues.

i understand that using a big texture would be the easiest way to achieve that effect, but why not try using Text for displaying the text at the hex coordinates (i suppose you can determine those, even if you have one single big mesh). just put the text out of the ortho queue and rotate it to be aligned with the hex grid. imho it's quite easy and worth a try.

So does that mean that you can't get the text out of the ortho queue?  Without hacking/fixing the renderer code?



I've seen "taking the text out of ortho" mentioned quite a few times, so did it work at some point?  It seems odd that I would be the first one to complain after seeing it suggested so many times.  Perhaps next weekend I will want it bad enough to take a look at it  :smiley:

sfera said:

of course again i have no clue, but here's my opinion :P
if you generate such a huge texture (because your grid seems quite big) it will have to live in the memory of your graphics card and might give you some serious performance issues.
i understand that using a big texture would be the easiest way to achieve that effect, but why not try using Text for displaying the text at the hex coordinates (i suppose you can determine those, even if you have one single big mesh). just put the text out of the ortho queue and rotate it to be aligned with the hex grid. imho it's quite easy and worth a try.


You hit upon a key point that I could not get working - and I've seen it mentioned before - HOW do I get text out of the ortho queue?!

If I do something like this:


hexNbr = new Text("Hex Number",hexNbrFmt.format(x) +""+ hexNbrFmt.format(y));
hexNbr.setRenderQueueMode(Renderer.QUEUE_OPAQUE);



I get this:


com.jme.system.JmeException: Already in Orthographic mode.
at com.jme.renderer.lwjgl.LWJGLRenderer.setOrtho(LWJGLRenderer.java:483)
at com.jme.renderer.RenderQueue.renderOrthoBucket(RenderQueue.java:281)
at com.jme.renderer.RenderQueue.renderBuckets(RenderQueue.java:224)
at com.jme.renderer.Renderer.renderQueue(Renderer.java:451)
at com.jme.renderer.lwjgl.LWJGLRenderer.displayBackBuffer(LWJGLRenderer.java:449)
at com.jme.app.BaseGame.start(BaseGame.java:72)
at MousePickTest2.main(MousePickTest2.java:85)


I'm showing my idiocy for sure, but how do I fix that?

Hmm, there is something odd going on because strange things happen (no exceptions though) if you set the renderqueue mode of the fps text in other simplegame tests.  (For example, setting it in TestTeapot makes the teapot disappear until the camera moves and once the camera moves, the fps text is gone.)

confirmed. couldn't find the cause. still searching

it seems to me that the renderer doesn't care which queue mode is set for Text. it just uses ortho by default when rendering (see LWJGLFont.print(LWJGLRenderer r, int x, int y, Vector3f scale, StringBuffer text, int set)). so the mode is switched to ortho even if the text is in another queue and when the otho queue has to be rendered, the ortho mode is already active. that's imho the cause of that exception.  :?



edit:

btw, this doesn't make any sense to me:


if (!r.isInOrthoMode()) {
  r.unsetOrtho();
}

Yeah, that code is wrong.  It should keep track of whether we were in ortho already prior to entering the method and only unset it if we weren't. (Fixed in CVS)



As for Text in other queues…  I'd forgotten how lwjglrenderer worked with Text.  Currently it's limited to ortho.  We might be able to change things to pass a flag indicating whether or not we want ortho set though.  I'll leave that up to another dev or someone who wants it bad enough to make a patch.  :slight_smile:

I mentioned that Dirt used text that appeared to be in the scene…  But it was still in ortho mode, it was just positioned and scaled to appear to have some depth in the scene.