Slick UnicodeFont displays in different location depending on the screen size?

Posted by Joehot2000 on Game Development See other posts from Game Development or by Joehot2000
Published on 2014-06-06T12:58:41Z Indexed on 2014/06/06 15:43 UTC
Read the original article Hit count: 83

Filed under:
|

I am using the Slick2D library to draw text. The text draws perfectly, however it is in the wrong location!

I could easily draw it in the correct location, however the problem is that the "correct location" is very different depending on the size of the screen - And my game needs to be able to have the screen size changed.

Here is the render method for the text:

 public static void render() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);
    glUseProgram(0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(orthographicProjectionMatrix);
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glLoadIdentity();
    glDisable(GL_LIGHTING);
    font.drawString(0, 0, "OMG ITS TEXT!", Color.green);
    glEnable(GL_LIGHTING);
    glPopMatrix();
    glMatrixMode(GL_PROJECTION);
    glLoadMatrix(perspectiveProjectionMatrix);
    glMatrixMode(GL_MODELVIEW);
}

So, how can I set the text to be in the middle of the screen irrespective of screen size?

Thanks!

© Game Development or respective owner

Related posts about java

Related posts about lwjgl