Slick UnicodeFont messes with textures

zerosp

New Member
I'm trying to create a GUI overlay for a game I'm developing, but I'm having a huge problem drawing strings. First, when the string is drawn, it only displays for a second before vanishing. Second, loading the glyphs (which is obviously required) with UnicodeFont.loadGlyphs() completely bugs textures, replacing them with a block of seemingly random characters. I can fix this by calling GL11.glDisable(GL11.GL_TEXTURE_2D) after drawing the font, but that causes the textures to completely disappear, and I'm not sure when to re-enable them in order to not cause the bug again. Here's the code for initializing the fonts:\[code\]private static void setUpFont(){ Font awtFont = new Font("Verdana", Font.BOLD, 108); font = new UnicodeFont(awtFont); font.getEffects().add(new ColorEffect(Color.RED)); font.addAsciiGlyphs(); try { font.loadGlyphs(); } catch (Exception ex){ ex.printStackTrace(); System.exit(1); }}\[/code\]And here's the method for drawing the font:\[code\]public void drawString(String str){ GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, orthographicProjectionMatrix); GL11.glLoadMatrix(perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(orthographicProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); font.drawString(10, 10, str); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadMatrix(perspectiveProjectionMatrix); GL11.glMatrixMode(GL11.GL_MODELVIEW); }\[/code\]I should also mention that perspectiveProjectionMatrix and orthographicProjectionMatrix are simply FloatBuffers of size 16.
 
Back
Top