1

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?

bigbass1997
  • 175
  • 1
  • 2
  • 10

2 Answers2

5

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);
bigbass1997
  • 175
  • 1
  • 2
  • 10
3

A quick little understanding about why your font wasn't working (if you don't already know), glOrtho is called like this:

glOrtho(double left, double right, double bottom, double top, double zNear, double zFar).

This being said, you had the bottom set to 0 where it should have been set to the display's height or a custom bottom if necessary and that is the reason why the text was facing the top of the screen or rather, being drawn up-side down.

Henrik Andersson
  • 45,354
  • 16
  • 98
  • 92