I'm really sad. I'm trying to use LWJGL to draw some text on the screen, nothing fancy, I just need to be able to read some info. I find that I'll need Slick. I get slick. I use this ( http://www.lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_3_-_TrueType_Fonts_for_LWJGL ) to try and draw something with TrueTypeFont. Doesn't work, also deprecated. I find that I need to use "UnicodeFont". I use that, but I get null pointer errors which no one online seems to get (specifically this:)

Exception in thread "Thread-0" java.lang.IllegalStateException: The UnicodeFont must have at least one effect before any glyphs can be loaded. at org.newdawn.slick.UnicodeFont.loadGlyphs(UnicodeFont.java:340) at org.newdawn.slick.UnicodeFont.loadGlyphs(UnicodeFont.java:325)Any API's I find are dead links.

Exception in thread "Thread-0" java.lang.NoSuchMethodError: org.newdawn.slick.opengl.renderer.SGL.glTexSubImage2D(IIIIIIIILjava/nio/ByteBuffer;)V at org.newdawn.slick.font.GlyphPage.renderGlyph(GlyphPage.java:212) at org.newdawn.slick.font.GlyphPage.loadGlyphs(GlyphPage.java:166) at org.newdawn.slick.UnicodeFont.loadGlyphs(UnicodeFont.java:376) at org.newdawn.slick.UnicodeFont.loadGlyphs(UnicodeFont.java:325)

From what this said it's probably an incompatability between you slick.jar and slick_util.jar versions. The latest slick download doesn't even include slick_util so try removing it, maybe the slick_util stuff was combined with slick in the latest version.

glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(0, w, h, 0, 1, -1);// w is the screen width and h is the heightglMatrixMode(GL_MODELVIEW);glLoadIdentity();glEnable(GL_BLEND);glDisable(GL_DEPTH_TEST);font.drawString(10, 10, "Text");//draws text 10 pixels down and to the right of the top left corner

Oh yeah, you need to set the matrices back to what they were again afterwards. I think this should work:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();glOrtho(0, w, h, 0, 1, -1);// w is the screen width and h is the heightglMatrixMode(GL_MODELVIEW);glPushMatrix();glLoadIdentity();glEnable(GL_BLEND);glDisable(GL_DEPTH_TEST);font.drawString(10, 10, "Text");//draws text 10 pixels down and to the right of the top left corner// do rest of text drawing here + any other overlay stuffglMatrixMode(GL_PROJECTION);glPopMatrix();glMatrixMode(GL_MODELVIEW);glPopMatrix();glEnable(GL_DEPTH_TEST);

Also make sure any overlay type stuff is rendered last because if depth test is disabled it draws in the order of the commands.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org