Slick Text in LWJGL

Hello. I’m new to Java 2d game programming with OpenGL, so I have to stick to tutorials becaus I don’t understand all of the correlations yet. I’ve allready successfully successfully implemented JBox2D in my game but I’ve got a problem:

I try to display text with the Slick library:

private UnicodeFont font;
Font fo = new Font("Times New Roman", Font.BOLD, 18);
font = new UnicodeFont(fo);
font.getEffects().add(new ColorEffect(Color.white));
font.addAsciiGlyphs();
try {
	font.loadGlyphs();
} catch (SlickException e) {
	e.printStackTrace();
}

and in the Draw method in the game loop:

font.drawString(0, 0, "Test");

This works fine, but the text is upside down. I know, that I can fix this by changing

GL11.glOrtho(0, GameSettings.resolutionX, 0, GameSettings.resolutionY, 1, -1);

to

GL11.glOrtho(0, GameSettings.resolutionX, GameSettings.resolutionY, 0, 1, -1);

in my openGL initialization.

But this does not help, because now the textures and physics are upside down. I can solve this by simply draw the textures upside down, but this does not help for the physics.

Thanks for your help.

This is because Slick uses a y-down rendering system while your game uses a y-up.

Do you really need unicode fonts? Why not just use a bitmap font that includes all the ASCII glyphs?

It’s fairly straight-forward to write a bitmap font renderer that should be compatible with Hiero, BMFont, and Matthias’ TWL font tool. See the source code here for reference:

Thank you. I never thought about the possibility of using a bitmap.

I used Unicode, because i need at least the German umlauts ä, ü, ö and ß, but I can include them in the fontmap, too.