bigcodeszzer bigcodeszzer - 4 months ago 39
Java Question

Slick2d drawstring draws a box, no text

I've seen references to this error before but no solution.

Where I am drawing the text, there is only a solid box of the specified color being drawn.

The code is like this:

TrueTypeFont font;
Font awtFont = new Font("Arial Unicode MS", Font.BOLD, 12); //name, style (PLAIN, BOLD, or ITALIC), size
font = new TrueTypeFont(awtFont, true); //base Font, anti-aliasing true/false

while (!Display.isCloseRequested() ) {
render();

font.drawString(10, 10, "ABC123", Color.black); //x, y, string to draw, color

Answer
//ENABLE THESE:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


//RENDER LIKE THIS:

glPushMatrix(); 
bodyPosition = body.getPosition().mul(30);
glTranslatef(Position.x, Position.y, 0);
GL11.glDisable(GL11.GL_TEXTURE_2D);
glPopMatrix();