Search code examples
javaopengl2dlwjglperspective

LWJGL glOrtho and drawing axies


This is on a 2d canvas. Ok i want to make glOrtho add to x when going right and minus when going left and i want to add when going up and minus when going down. But when i draw it draws the objects not from bottom left (which is 0,0) it draws from top right (1, 1). I was wandering is there a solution to this? Here is a diagram:

https://i.sstatic.net/Srqo9.png

Is there anyway i can change the drawing coords to run in the same directions and axies as the camera ]

glOrtho(853, 0, 480, 0, -1, 1);


Solution

  • glOrtho is set like this:

    glOrtho(X start, X length, Y start, Y length, z, z);
    

    if you want to draw from the bottom left and up set it to:

    glOrtho(0, 853, 0, 480, -1, 1);
    

    Also if you want to go back to drawing from the top left just swap the Y's around.