Search code examples
javalwjglslick2d

Text rotation in slick2d


How can I rotate the text drawing with Unicodefont. I can draw text using any font in this way.

UnicodeFont font = new UnicodeFont(fontpath,fontsize, false, false);
font.drawString(0,0,"hoge");

But I can not find any rotation method. If I can convert the drawing text to Image object, I can rotate.


Solution

  • Kenichi. To rotate the text, you must do the following.
    Add the following line to the top of your file in the imports:

    import static org.lwjgl.opengl.GL11.*;

    After this, you must modify your code to say this:

    UnicodeFont font = new UnicodeFont(fontpath,fontsize, false, false);
    glRotatef(90, 0, 0, 1);
    font.drawString(0,0,"hoge");

    The glRotatef(float, float, float, float) method is part of LWJGL and rotates on the Z axis 90 degrees.