I am trying to implement a simple 2D camera in LWJGL3.
The camera has an orthographic projection and can move in 2D space.
This is run once at game start-up:
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glLoadIdentity(); GL11.glOrtho(0, graphics.window().width(), graphics.window().height(), 0, 1, -1); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glLoadIdentity();
This is run as part of the draw loop:
GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glTranslatef(-position.x(), -position.y(), 0f); // Draw stuff GL11.glPopMatrix();
Everything looks fine until I move the view, after which everything seems to be closer to the top left (0, 0) than it should be. It seems to be off by a scalar of the window size - the factor is greater in x than y.
How have I misunderstood the OpenGL commands?