I found it helpful to change the BufferedImage.TYPE_INT_RGB to BufferedImage.TYPE_INT_ARGB so that the image supports alpha for transparent backgrounds.
I'm just wondering: Is this method fast enough to modify/replace string dynamically (eg setString, append)? Without generating too many garbage collectible objects?
I'm just wondering: Is this method fast enough to modify/replace string dynamically (eg setString, append)? Without generating too many garbage collectible objects?
I dont know. How many is too many? Currently I'm using it dynamically, creating a new TextLabel for every update.
You could also use JMEDesktop and attach a JTextpane or something but I don't know which method would be the most efficient.
I'm finding that when I create new TextLabels I get a noticeable pause in updates (~500ms). I think there's also some jagginess issues - OpenGL always wants to scale the textures to a power of 2, and I'm not sure it does it very well :?
Thanks for pointing out the jagginess issue. In this version it's taken care of:
I create the BufferedImage with a power of two-size from the start so that the texture doesn't get rescaled. Then I adjust the texture coordinates so that the text fits the quad like before.
Also, you do not need to call the constructor to update the TextLabel anymore. Just call setTextString(String textString), or setTextString(String textString, Font font);
That's much better! Performance seems better too (although I still have a small lag on creation).
I have a slightly modified version, where I ask for a label with a specifed height and or width, which I'll post once I've folded it back into your version.