Search code examples
stringfontslwjglslick2d

How do I fix my Slick UnicodeFont from being upsidedown?


For some reason when I try to print out a string using Slick's UnicodeFont class it is upside-down.

(NOTE: I am also using LWJGL, but I dont think its interfering with what slick is trying to do.)

Initialized Code:

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);

    try {
        normalFont = new UnicodeFont("res/fonts/visitor.ttf", 15, false, false);
        normalFont.addAsciiGlyphs();
        normalFont.addGlyphs(400, 600);
        normalFont.getEffects().add(new ColorEffect());
        normalFont.loadGlyphs();
    } catch (SlickException e) {
        e.printStackTrace();
    }

Draw Code:

    normalFont.drawString(10f, 740f, "HELLO WORLD!");

Does anyone know why my string is being drawn upside down?


Solution

  • I found the answer. I needed to change this:

    GL11.glOrtho(0, Display.getWidth(), 0, Display.getHeight(), 1, -1);
    

    To this:

    GL11.glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);